babylon.module.d.ts 5.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Engines/IPipelineContext" {
  5234. /**
  5235. * Class used to store and describe the pipeline context associated with an effect
  5236. */
  5237. export interface IPipelineContext {
  5238. /**
  5239. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5240. */
  5241. isAsync: boolean;
  5242. /**
  5243. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5244. */
  5245. isReady: boolean;
  5246. /** @hidden */
  5247. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5248. }
  5249. }
  5250. declare module "babylonjs/Meshes/dataBuffer" {
  5251. /**
  5252. * Class used to store gfx data (like WebGLBuffer)
  5253. */
  5254. export class DataBuffer {
  5255. /**
  5256. * Gets or sets the number of objects referencing this buffer
  5257. */
  5258. references: number;
  5259. /** Gets or sets the size of the underlying buffer */
  5260. capacity: number;
  5261. /**
  5262. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5263. */
  5264. is32Bits: boolean;
  5265. /**
  5266. * Gets the underlying buffer
  5267. */
  5268. readonly underlyingResource: any;
  5269. }
  5270. }
  5271. declare module "babylonjs/Misc/performanceMonitor" {
  5272. /**
  5273. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5274. */
  5275. export class PerformanceMonitor {
  5276. private _enabled;
  5277. private _rollingFrameTime;
  5278. private _lastFrameTimeMs;
  5279. /**
  5280. * constructor
  5281. * @param frameSampleSize The number of samples required to saturate the sliding window
  5282. */
  5283. constructor(frameSampleSize?: number);
  5284. /**
  5285. * Samples current frame
  5286. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5287. */
  5288. sampleFrame(timeMs?: number): void;
  5289. /**
  5290. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5291. */
  5292. readonly averageFrameTime: number;
  5293. /**
  5294. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5295. */
  5296. readonly averageFrameTimeVariance: number;
  5297. /**
  5298. * Returns the frame time of the most recent frame
  5299. */
  5300. readonly instantaneousFrameTime: number;
  5301. /**
  5302. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5303. */
  5304. readonly averageFPS: number;
  5305. /**
  5306. * Returns the average framerate in frames per second using the most recent frame time
  5307. */
  5308. readonly instantaneousFPS: number;
  5309. /**
  5310. * Returns true if enough samples have been taken to completely fill the sliding window
  5311. */
  5312. readonly isSaturated: boolean;
  5313. /**
  5314. * Enables contributions to the sliding window sample set
  5315. */
  5316. enable(): void;
  5317. /**
  5318. * Disables contributions to the sliding window sample set
  5319. * Samples will not be interpolated over the disabled period
  5320. */
  5321. disable(): void;
  5322. /**
  5323. * Returns true if sampling is enabled
  5324. */
  5325. readonly isEnabled: boolean;
  5326. /**
  5327. * Resets performance monitor
  5328. */
  5329. reset(): void;
  5330. }
  5331. /**
  5332. * RollingAverage
  5333. *
  5334. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5335. */
  5336. export class RollingAverage {
  5337. /**
  5338. * Current average
  5339. */
  5340. average: number;
  5341. /**
  5342. * Current variance
  5343. */
  5344. variance: number;
  5345. protected _samples: Array<number>;
  5346. protected _sampleCount: number;
  5347. protected _pos: number;
  5348. protected _m2: number;
  5349. /**
  5350. * constructor
  5351. * @param length The number of samples required to saturate the sliding window
  5352. */
  5353. constructor(length: number);
  5354. /**
  5355. * Adds a sample to the sample set
  5356. * @param v The sample value
  5357. */
  5358. add(v: number): void;
  5359. /**
  5360. * Returns previously added values or null if outside of history or outside the sliding window domain
  5361. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5362. * @return Value previously recorded with add() or null if outside of range
  5363. */
  5364. history(i: number): number;
  5365. /**
  5366. * Returns true if enough samples have been taken to completely fill the sliding window
  5367. * @return true if sample-set saturated
  5368. */
  5369. isSaturated(): boolean;
  5370. /**
  5371. * Resets the rolling average (equivalent to 0 samples taken so far)
  5372. */
  5373. reset(): void;
  5374. /**
  5375. * Wraps a value around the sample range boundaries
  5376. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5377. * @return Wrapped position in sample range
  5378. */
  5379. protected _wrapPosition(i: number): number;
  5380. }
  5381. }
  5382. declare module "babylonjs/Misc/stringDictionary" {
  5383. import { Nullable } from "babylonjs/types";
  5384. /**
  5385. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5386. * The underlying implementation relies on an associative array to ensure the best performances.
  5387. * The value can be anything including 'null' but except 'undefined'
  5388. */
  5389. export class StringDictionary<T> {
  5390. /**
  5391. * This will clear this dictionary and copy the content from the 'source' one.
  5392. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5393. * @param source the dictionary to take the content from and copy to this dictionary
  5394. */
  5395. copyFrom(source: StringDictionary<T>): void;
  5396. /**
  5397. * Get a value based from its key
  5398. * @param key the given key to get the matching value from
  5399. * @return the value if found, otherwise undefined is returned
  5400. */
  5401. get(key: string): T | undefined;
  5402. /**
  5403. * Get a value from its key or add it if it doesn't exist.
  5404. * This method will ensure you that a given key/data will be present in the dictionary.
  5405. * @param key the given key to get the matching value from
  5406. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5407. * The factory will only be invoked if there's no data for the given key.
  5408. * @return the value corresponding to the key.
  5409. */
  5410. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5411. /**
  5412. * Get a value from its key if present in the dictionary otherwise add it
  5413. * @param key the key to get the value from
  5414. * @param val if there's no such key/value pair in the dictionary add it with this value
  5415. * @return the value corresponding to the key
  5416. */
  5417. getOrAdd(key: string, val: T): T;
  5418. /**
  5419. * Check if there's a given key in the dictionary
  5420. * @param key the key to check for
  5421. * @return true if the key is present, false otherwise
  5422. */
  5423. contains(key: string): boolean;
  5424. /**
  5425. * Add a new key and its corresponding value
  5426. * @param key the key to add
  5427. * @param value the value corresponding to the key
  5428. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5429. */
  5430. add(key: string, value: T): boolean;
  5431. /**
  5432. * Update a specific value associated to a key
  5433. * @param key defines the key to use
  5434. * @param value defines the value to store
  5435. * @returns true if the value was updated (or false if the key was not found)
  5436. */
  5437. set(key: string, value: T): boolean;
  5438. /**
  5439. * Get the element of the given key and remove it from the dictionary
  5440. * @param key defines the key to search
  5441. * @returns the value associated with the key or null if not found
  5442. */
  5443. getAndRemove(key: string): Nullable<T>;
  5444. /**
  5445. * Remove a key/value from the dictionary.
  5446. * @param key the key to remove
  5447. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5448. */
  5449. remove(key: string): boolean;
  5450. /**
  5451. * Clear the whole content of the dictionary
  5452. */
  5453. clear(): void;
  5454. /**
  5455. * Gets the current count
  5456. */
  5457. readonly count: number;
  5458. /**
  5459. * Execute a callback on each key/val of the dictionary.
  5460. * Note that you can remove any element in this dictionary in the callback implementation
  5461. * @param callback the callback to execute on a given key/value pair
  5462. */
  5463. forEach(callback: (key: string, val: T) => void): void;
  5464. /**
  5465. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5466. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5467. * Note that you can remove any element in this dictionary in the callback implementation
  5468. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5469. * @returns the first item
  5470. */
  5471. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5472. private _count;
  5473. private _data;
  5474. }
  5475. }
  5476. declare module "babylonjs/Misc/promise" {
  5477. /**
  5478. * Helper class that provides a small promise polyfill
  5479. */
  5480. export class PromisePolyfill {
  5481. /**
  5482. * Static function used to check if the polyfill is required
  5483. * If this is the case then the function will inject the polyfill to window.Promise
  5484. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5485. */
  5486. static Apply(force?: boolean): void;
  5487. }
  5488. }
  5489. declare module "babylonjs/Meshes/buffer" {
  5490. import { Nullable, DataArray } from "babylonjs/types";
  5491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5492. /**
  5493. * Class used to store data that will be store in GPU memory
  5494. */
  5495. export class Buffer {
  5496. private _engine;
  5497. private _buffer;
  5498. /** @hidden */
  5499. _data: Nullable<DataArray>;
  5500. private _updatable;
  5501. private _instanced;
  5502. /**
  5503. * Gets the byte stride.
  5504. */
  5505. readonly byteStride: number;
  5506. /**
  5507. * Constructor
  5508. * @param engine the engine
  5509. * @param data the data to use for this buffer
  5510. * @param updatable whether the data is updatable
  5511. * @param stride the stride (optional)
  5512. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5513. * @param instanced whether the buffer is instanced (optional)
  5514. * @param useBytes set to true if the stride in in bytes (optional)
  5515. */
  5516. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5517. /**
  5518. * Create a new VertexBuffer based on the current buffer
  5519. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5520. * @param offset defines offset in the buffer (0 by default)
  5521. * @param size defines the size in floats of attributes (position is 3 for instance)
  5522. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5523. * @param instanced defines if the vertex buffer contains indexed data
  5524. * @param useBytes defines if the offset and stride are in bytes
  5525. * @returns the new vertex buffer
  5526. */
  5527. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5528. /**
  5529. * Gets a boolean indicating if the Buffer is updatable?
  5530. * @returns true if the buffer is updatable
  5531. */
  5532. isUpdatable(): boolean;
  5533. /**
  5534. * Gets current buffer's data
  5535. * @returns a DataArray or null
  5536. */
  5537. getData(): Nullable<DataArray>;
  5538. /**
  5539. * Gets underlying native buffer
  5540. * @returns underlying native buffer
  5541. */
  5542. getBuffer(): Nullable<DataBuffer>;
  5543. /**
  5544. * Gets the stride in float32 units (i.e. byte stride / 4).
  5545. * May not be an integer if the byte stride is not divisible by 4.
  5546. * DEPRECATED. Use byteStride instead.
  5547. * @returns the stride in float32 units
  5548. */
  5549. getStrideSize(): number;
  5550. /**
  5551. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5552. * @param data defines the data to store
  5553. */
  5554. create(data?: Nullable<DataArray>): void;
  5555. /** @hidden */
  5556. _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */
  5580. _buffer: Buffer;
  5581. private _kind;
  5582. private _size;
  5583. private _ownsBuffer;
  5584. private _instanced;
  5585. private _instanceDivisor;
  5586. /**
  5587. * The byte type.
  5588. */
  5589. static readonly BYTE: number;
  5590. /**
  5591. * The unsigned byte type.
  5592. */
  5593. static readonly UNSIGNED_BYTE: number;
  5594. /**
  5595. * The short type.
  5596. */
  5597. static readonly SHORT: number;
  5598. /**
  5599. * The unsigned short type.
  5600. */
  5601. static readonly UNSIGNED_SHORT: number;
  5602. /**
  5603. * The integer type.
  5604. */
  5605. static readonly INT: number;
  5606. /**
  5607. * The unsigned integer type.
  5608. */
  5609. static readonly UNSIGNED_INT: number;
  5610. /**
  5611. * The float type.
  5612. */
  5613. static readonly FLOAT: number;
  5614. /**
  5615. * Gets or sets the instance divisor when in instanced mode
  5616. */
  5617. instanceDivisor: number;
  5618. /**
  5619. * Gets the byte stride.
  5620. */
  5621. readonly byteStride: number;
  5622. /**
  5623. * Gets the byte offset.
  5624. */
  5625. readonly byteOffset: number;
  5626. /**
  5627. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5628. */
  5629. readonly normalized: boolean;
  5630. /**
  5631. * Gets the data type of each component in the array.
  5632. */
  5633. readonly type: number;
  5634. /**
  5635. * Constructor
  5636. * @param engine the engine
  5637. * @param data the data to use for this vertex buffer
  5638. * @param kind the vertex buffer kind
  5639. * @param updatable whether the data is updatable
  5640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5641. * @param stride the stride (optional)
  5642. * @param instanced whether the buffer is instanced (optional)
  5643. * @param offset the offset of the data (optional)
  5644. * @param size the number of components (optional)
  5645. * @param type the type of the component (optional)
  5646. * @param normalized whether the data contains normalized data (optional)
  5647. * @param useBytes set to true if stride and offset are in bytes (optional)
  5648. */
  5649. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5650. /** @hidden */
  5651. _rebuild(): void;
  5652. /**
  5653. * Returns the kind of the VertexBuffer (string)
  5654. * @returns a string
  5655. */
  5656. getKind(): string;
  5657. /**
  5658. * Gets a boolean indicating if the VertexBuffer is updatable?
  5659. * @returns true if the buffer is updatable
  5660. */
  5661. isUpdatable(): boolean;
  5662. /**
  5663. * Gets current buffer's data
  5664. * @returns a DataArray or null
  5665. */
  5666. getData(): Nullable<DataArray>;
  5667. /**
  5668. * Gets underlying native buffer
  5669. * @returns underlying native buffer
  5670. */
  5671. getBuffer(): Nullable<DataBuffer>;
  5672. /**
  5673. * Gets the stride in float32 units (i.e. byte stride / 4).
  5674. * May not be an integer if the byte stride is not divisible by 4.
  5675. * DEPRECATED. Use byteStride instead.
  5676. * @returns the stride in float32 units
  5677. */
  5678. getStrideSize(): number;
  5679. /**
  5680. * Returns the offset as a multiple of the type byte length.
  5681. * DEPRECATED. Use byteOffset instead.
  5682. * @returns the offset in bytes
  5683. */
  5684. getOffset(): number;
  5685. /**
  5686. * Returns the number of components per vertex attribute (integer)
  5687. * @returns the size in float
  5688. */
  5689. getSize(): number;
  5690. /**
  5691. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5692. * @returns true if this buffer is instanced
  5693. */
  5694. getIsInstanced(): boolean;
  5695. /**
  5696. * Returns the instancing divisor, zero for non-instanced (integer).
  5697. * @returns a number
  5698. */
  5699. getInstanceDivisor(): number;
  5700. /**
  5701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5702. * @param data defines the data to store
  5703. */
  5704. create(data?: DataArray): void;
  5705. /**
  5706. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5707. * This function will create a new buffer if the current one is not updatable
  5708. * @param data defines the data to store
  5709. */
  5710. update(data: DataArray): void;
  5711. /**
  5712. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5713. * Returns the directly updated WebGLBuffer.
  5714. * @param data the new data
  5715. * @param offset the new offset
  5716. * @param useBytes set to true if the offset is in bytes
  5717. */
  5718. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5719. /**
  5720. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5721. */
  5722. dispose(): void;
  5723. /**
  5724. * Enumerates each value of this vertex buffer as numbers.
  5725. * @param count the number of values to enumerate
  5726. * @param callback the callback function called for each value
  5727. */
  5728. forEach(count: number, callback: (value: number, index: number) => void): void;
  5729. /**
  5730. * Positions
  5731. */
  5732. static readonly PositionKind: string;
  5733. /**
  5734. * Normals
  5735. */
  5736. static readonly NormalKind: string;
  5737. /**
  5738. * Tangents
  5739. */
  5740. static readonly TangentKind: string;
  5741. /**
  5742. * Texture coordinates
  5743. */
  5744. static readonly UVKind: string;
  5745. /**
  5746. * Texture coordinates 2
  5747. */
  5748. static readonly UV2Kind: string;
  5749. /**
  5750. * Texture coordinates 3
  5751. */
  5752. static readonly UV3Kind: string;
  5753. /**
  5754. * Texture coordinates 4
  5755. */
  5756. static readonly UV4Kind: string;
  5757. /**
  5758. * Texture coordinates 5
  5759. */
  5760. static readonly UV5Kind: string;
  5761. /**
  5762. * Texture coordinates 6
  5763. */
  5764. static readonly UV6Kind: string;
  5765. /**
  5766. * Colors
  5767. */
  5768. static readonly ColorKind: string;
  5769. /**
  5770. * Matrix indices (for bones)
  5771. */
  5772. static readonly MatricesIndicesKind: string;
  5773. /**
  5774. * Matrix weights (for bones)
  5775. */
  5776. static readonly MatricesWeightsKind: string;
  5777. /**
  5778. * Additional matrix indices (for bones)
  5779. */
  5780. static readonly MatricesIndicesExtraKind: string;
  5781. /**
  5782. * Additional matrix weights (for bones)
  5783. */
  5784. static readonly MatricesWeightsExtraKind: string;
  5785. /**
  5786. * Deduces the stride given a kind.
  5787. * @param kind The kind string to deduce
  5788. * @returns The deduced stride
  5789. */
  5790. static DeduceStride(kind: string): number;
  5791. /**
  5792. * Gets the byte length of the given type.
  5793. * @param type the type
  5794. * @returns the number of bytes
  5795. */
  5796. static GetTypeByteLength(type: number): number;
  5797. /**
  5798. * Enumerates each value of the given parameters as numbers.
  5799. * @param data the data to enumerate
  5800. * @param byteOffset the byte offset of the data
  5801. * @param byteStride the byte stride of the data
  5802. * @param componentCount the number of components per element
  5803. * @param componentType the type of the component
  5804. * @param count the total number of components
  5805. * @param normalized whether the data is normalized
  5806. * @param callback the callback function called for each value
  5807. */
  5808. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5809. private static _GetFloatValue;
  5810. }
  5811. }
  5812. declare module "babylonjs/Maths/sphericalPolynomial" {
  5813. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5814. /**
  5815. * Class representing spherical harmonics coefficients to the 3rd degree
  5816. */
  5817. export class SphericalHarmonics {
  5818. /**
  5819. * Defines whether or not the harmonics have been prescaled for rendering.
  5820. */
  5821. preScaled: boolean;
  5822. /**
  5823. * The l0,0 coefficients of the spherical harmonics
  5824. */
  5825. l00: Vector3;
  5826. /**
  5827. * The l1,-1 coefficients of the spherical harmonics
  5828. */
  5829. l1_1: Vector3;
  5830. /**
  5831. * The l1,0 coefficients of the spherical harmonics
  5832. */
  5833. l10: Vector3;
  5834. /**
  5835. * The l1,1 coefficients of the spherical harmonics
  5836. */
  5837. l11: Vector3;
  5838. /**
  5839. * The l2,-2 coefficients of the spherical harmonics
  5840. */
  5841. l2_2: Vector3;
  5842. /**
  5843. * The l2,-1 coefficients of the spherical harmonics
  5844. */
  5845. l2_1: Vector3;
  5846. /**
  5847. * The l2,0 coefficients of the spherical harmonics
  5848. */
  5849. l20: Vector3;
  5850. /**
  5851. * The l2,1 coefficients of the spherical harmonics
  5852. */
  5853. l21: Vector3;
  5854. /**
  5855. * The l2,2 coefficients of the spherical harmonics
  5856. */
  5857. l22: Vector3;
  5858. /**
  5859. * Adds a light to the spherical harmonics
  5860. * @param direction the direction of the light
  5861. * @param color the color of the light
  5862. * @param deltaSolidAngle the delta solid angle of the light
  5863. */
  5864. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5865. /**
  5866. * Scales the spherical harmonics by the given amount
  5867. * @param scale the amount to scale
  5868. */
  5869. scaleInPlace(scale: number): void;
  5870. /**
  5871. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5872. *
  5873. * ```
  5874. * E_lm = A_l * L_lm
  5875. * ```
  5876. *
  5877. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5878. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5879. * the scaling factors are given in equation 9.
  5880. */
  5881. convertIncidentRadianceToIrradiance(): void;
  5882. /**
  5883. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5884. *
  5885. * ```
  5886. * L = (1/pi) * E * rho
  5887. * ```
  5888. *
  5889. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5890. */
  5891. convertIrradianceToLambertianRadiance(): void;
  5892. /**
  5893. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5894. * required operations at run time.
  5895. *
  5896. * This is simply done by scaling back the SH with Ylm constants parameter.
  5897. * The trigonometric part being applied by the shader at run time.
  5898. */
  5899. preScaleForRendering(): void;
  5900. /**
  5901. * Constructs a spherical harmonics from an array.
  5902. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5903. * @returns the spherical harmonics
  5904. */
  5905. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. }
  5913. /**
  5914. * Class representing spherical polynomial coefficients to the 3rd degree
  5915. */
  5916. export class SphericalPolynomial {
  5917. private _harmonics;
  5918. /**
  5919. * The spherical harmonics used to create the polynomials.
  5920. */
  5921. readonly preScaledHarmonics: SphericalHarmonics;
  5922. /**
  5923. * The x coefficients of the spherical polynomial
  5924. */
  5925. x: Vector3;
  5926. /**
  5927. * The y coefficients of the spherical polynomial
  5928. */
  5929. y: Vector3;
  5930. /**
  5931. * The z coefficients of the spherical polynomial
  5932. */
  5933. z: Vector3;
  5934. /**
  5935. * The xx coefficients of the spherical polynomial
  5936. */
  5937. xx: Vector3;
  5938. /**
  5939. * The yy coefficients of the spherical polynomial
  5940. */
  5941. yy: Vector3;
  5942. /**
  5943. * The zz coefficients of the spherical polynomial
  5944. */
  5945. zz: Vector3;
  5946. /**
  5947. * The xy coefficients of the spherical polynomial
  5948. */
  5949. xy: Vector3;
  5950. /**
  5951. * The yz coefficients of the spherical polynomial
  5952. */
  5953. yz: Vector3;
  5954. /**
  5955. * The zx coefficients of the spherical polynomial
  5956. */
  5957. zx: Vector3;
  5958. /**
  5959. * Adds an ambient color to the spherical polynomial
  5960. * @param color the color to add
  5961. */
  5962. addAmbient(color: Color3): void;
  5963. /**
  5964. * Scales the spherical polynomial by the given amount
  5965. * @param scale the amount to scale
  5966. */
  5967. scaleInPlace(scale: number): void;
  5968. /**
  5969. * Gets the spherical polynomial from harmonics
  5970. * @param harmonics the spherical harmonics
  5971. * @returns the spherical polynomial
  5972. */
  5973. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5974. /**
  5975. * Constructs a spherical polynomial from an array.
  5976. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5977. * @returns the spherical polynomial
  5978. */
  5979. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5983. import { Nullable } from "babylonjs/types";
  5984. /**
  5985. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5986. */
  5987. export interface CubeMapInfo {
  5988. /**
  5989. * The pixel array for the front face.
  5990. * This is stored in format, left to right, up to down format.
  5991. */
  5992. front: Nullable<ArrayBufferView>;
  5993. /**
  5994. * The pixel array for the back face.
  5995. * This is stored in format, left to right, up to down format.
  5996. */
  5997. back: Nullable<ArrayBufferView>;
  5998. /**
  5999. * The pixel array for the left face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. left: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the right face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. right: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the up face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. up: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the down face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. down: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The size of the cubemap stored.
  6020. *
  6021. * Each faces will be size * size pixels.
  6022. */
  6023. size: number;
  6024. /**
  6025. * The format of the texture.
  6026. *
  6027. * RGBA, RGB.
  6028. */
  6029. format: number;
  6030. /**
  6031. * The type of the texture data.
  6032. *
  6033. * UNSIGNED_INT, FLOAT.
  6034. */
  6035. type: number;
  6036. /**
  6037. * Specifies whether the texture is in gamma space.
  6038. */
  6039. gammaSpace: boolean;
  6040. }
  6041. /**
  6042. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6043. */
  6044. export class PanoramaToCubeMapTools {
  6045. private static FACE_FRONT;
  6046. private static FACE_BACK;
  6047. private static FACE_RIGHT;
  6048. private static FACE_LEFT;
  6049. private static FACE_DOWN;
  6050. private static FACE_UP;
  6051. /**
  6052. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6053. *
  6054. * @param float32Array The source data.
  6055. * @param inputWidth The width of the input panorama.
  6056. * @param inputHeight The height of the input panorama.
  6057. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6058. * @return The cubemap data
  6059. */
  6060. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6061. private static CreateCubemapTexture;
  6062. private static CalcProjectionSpherical;
  6063. }
  6064. }
  6065. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6066. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6068. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6069. /**
  6070. * Helper class dealing with the extraction of spherical polynomial dataArray
  6071. * from a cube map.
  6072. */
  6073. export class CubeMapToSphericalPolynomialTools {
  6074. private static FileFaces;
  6075. /**
  6076. * Converts a texture to the according Spherical Polynomial data.
  6077. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6078. *
  6079. * @param texture The texture to extract the information from.
  6080. * @return The Spherical Polynomial data.
  6081. */
  6082. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6083. /**
  6084. * Converts a cubemap to the according Spherical Polynomial data.
  6085. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6086. *
  6087. * @param cubeInfo The Cube map to extract the information from.
  6088. * @return The Spherical Polynomial data.
  6089. */
  6090. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6091. }
  6092. }
  6093. declare module "babylonjs/Engines/engineStore" {
  6094. import { Nullable } from "babylonjs/types";
  6095. import { Engine } from "babylonjs/Engines/engine";
  6096. import { Scene } from "babylonjs/scene";
  6097. /**
  6098. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6099. * during the life time of the application.
  6100. */
  6101. export class EngineStore {
  6102. /** Gets the list of created engines */
  6103. static Instances: import("babylonjs/Engines/engine").Engine[];
  6104. /**
  6105. * Gets the latest created engine
  6106. */
  6107. static readonly LastCreatedEngine: Nullable<Engine>;
  6108. /**
  6109. * Gets the latest created scene
  6110. */
  6111. static readonly LastCreatedScene: Nullable<Scene>;
  6112. }
  6113. }
  6114. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6115. /**
  6116. * Define options used to create a render target texture
  6117. */
  6118. export class RenderTargetCreationOptions {
  6119. /**
  6120. * Specifies is mipmaps must be generated
  6121. */
  6122. generateMipMaps?: boolean;
  6123. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6124. generateDepthBuffer?: boolean;
  6125. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6126. generateStencilBuffer?: boolean;
  6127. /** Defines texture type (int by default) */
  6128. type?: number;
  6129. /** Defines sampling mode (trilinear by default) */
  6130. samplingMode?: number;
  6131. /** Defines format (RGBA by default) */
  6132. format?: number;
  6133. }
  6134. }
  6135. declare module "babylonjs/States/alphaCullingState" {
  6136. /**
  6137. * @hidden
  6138. **/
  6139. export class _AlphaState {
  6140. private _isAlphaBlendDirty;
  6141. private _isBlendFunctionParametersDirty;
  6142. private _isBlendEquationParametersDirty;
  6143. private _isBlendConstantsDirty;
  6144. private _alphaBlend;
  6145. private _blendFunctionParameters;
  6146. private _blendEquationParameters;
  6147. private _blendConstants;
  6148. /**
  6149. * Initializes the state.
  6150. */
  6151. constructor();
  6152. readonly isDirty: boolean;
  6153. alphaBlend: boolean;
  6154. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6155. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6156. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/depthCullingState" {
  6162. import { Nullable } from "babylonjs/types";
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _DepthCullingState {
  6167. private _isDepthTestDirty;
  6168. private _isDepthMaskDirty;
  6169. private _isDepthFuncDirty;
  6170. private _isCullFaceDirty;
  6171. private _isCullDirty;
  6172. private _isZOffsetDirty;
  6173. private _isFrontFaceDirty;
  6174. private _depthTest;
  6175. private _depthMask;
  6176. private _depthFunc;
  6177. private _cull;
  6178. private _cullFace;
  6179. private _zOffset;
  6180. private _frontFace;
  6181. /**
  6182. * Initializes the state.
  6183. */
  6184. constructor();
  6185. readonly isDirty: boolean;
  6186. zOffset: number;
  6187. cullFace: Nullable<number>;
  6188. cull: Nullable<boolean>;
  6189. depthFunc: Nullable<number>;
  6190. depthMask: boolean;
  6191. depthTest: boolean;
  6192. frontFace: Nullable<number>;
  6193. reset(): void;
  6194. apply(gl: WebGLRenderingContext): void;
  6195. }
  6196. }
  6197. declare module "babylonjs/States/stencilState" {
  6198. /**
  6199. * @hidden
  6200. **/
  6201. export class _StencilState {
  6202. /** 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 */
  6203. static readonly ALWAYS: number;
  6204. /** Passed to stencilOperation to specify that stencil value must be kept */
  6205. static readonly KEEP: number;
  6206. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6207. static readonly REPLACE: number;
  6208. private _isStencilTestDirty;
  6209. private _isStencilMaskDirty;
  6210. private _isStencilFuncDirty;
  6211. private _isStencilOpDirty;
  6212. private _stencilTest;
  6213. private _stencilMask;
  6214. private _stencilFunc;
  6215. private _stencilFuncRef;
  6216. private _stencilFuncMask;
  6217. private _stencilOpStencilFail;
  6218. private _stencilOpDepthFail;
  6219. private _stencilOpStencilDepthPass;
  6220. readonly isDirty: boolean;
  6221. stencilFunc: number;
  6222. stencilFuncRef: number;
  6223. stencilFuncMask: number;
  6224. stencilOpStencilFail: number;
  6225. stencilOpDepthFail: number;
  6226. stencilOpStencilDepthPass: number;
  6227. stencilMask: number;
  6228. stencilTest: boolean;
  6229. constructor();
  6230. reset(): void;
  6231. apply(gl: WebGLRenderingContext): void;
  6232. }
  6233. }
  6234. declare module "babylonjs/States/index" {
  6235. export * from "babylonjs/States/alphaCullingState";
  6236. export * from "babylonjs/States/depthCullingState";
  6237. export * from "babylonjs/States/stencilState";
  6238. }
  6239. declare module "babylonjs/Instrumentation/timeToken" {
  6240. import { Nullable } from "babylonjs/types";
  6241. /**
  6242. * @hidden
  6243. **/
  6244. export class _TimeToken {
  6245. _startTimeQuery: Nullable<WebGLQuery>;
  6246. _endTimeQuery: Nullable<WebGLQuery>;
  6247. _timeElapsedQuery: Nullable<WebGLQuery>;
  6248. _timeElapsedQueryEnded: boolean;
  6249. }
  6250. }
  6251. declare module "babylonjs/Materials/Textures/internalTexture" {
  6252. import { Observable } from "babylonjs/Misc/observable";
  6253. import { Nullable, int } from "babylonjs/types";
  6254. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6255. import { Engine } from "babylonjs/Engines/engine";
  6256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6257. /**
  6258. * Class used to store data associated with WebGL texture data for the engine
  6259. * This class should not be used directly
  6260. */
  6261. export class InternalTexture {
  6262. /** hidden */
  6263. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6264. /**
  6265. * The source of the texture data is unknown
  6266. */
  6267. static DATASOURCE_UNKNOWN: number;
  6268. /**
  6269. * Texture data comes from an URL
  6270. */
  6271. static DATASOURCE_URL: number;
  6272. /**
  6273. * Texture data is only used for temporary storage
  6274. */
  6275. static DATASOURCE_TEMP: number;
  6276. /**
  6277. * Texture data comes from raw data (ArrayBuffer)
  6278. */
  6279. static DATASOURCE_RAW: number;
  6280. /**
  6281. * Texture content is dynamic (video or dynamic texture)
  6282. */
  6283. static DATASOURCE_DYNAMIC: number;
  6284. /**
  6285. * Texture content is generated by rendering to it
  6286. */
  6287. static DATASOURCE_RENDERTARGET: number;
  6288. /**
  6289. * Texture content is part of a multi render target process
  6290. */
  6291. static DATASOURCE_MULTIRENDERTARGET: number;
  6292. /**
  6293. * Texture data comes from a cube data file
  6294. */
  6295. static DATASOURCE_CUBE: number;
  6296. /**
  6297. * Texture data comes from a raw cube data
  6298. */
  6299. static DATASOURCE_CUBERAW: number;
  6300. /**
  6301. * Texture data come from a prefiltered cube data file
  6302. */
  6303. static DATASOURCE_CUBEPREFILTERED: number;
  6304. /**
  6305. * Texture content is raw 3D data
  6306. */
  6307. static DATASOURCE_RAW3D: number;
  6308. /**
  6309. * Texture content is a depth texture
  6310. */
  6311. static DATASOURCE_DEPTHTEXTURE: number;
  6312. /**
  6313. * Texture data comes from a raw cube data encoded with RGBD
  6314. */
  6315. static DATASOURCE_CUBERAW_RGBD: number;
  6316. /**
  6317. * Defines if the texture is ready
  6318. */
  6319. isReady: boolean;
  6320. /**
  6321. * Defines if the texture is a cube texture
  6322. */
  6323. isCube: boolean;
  6324. /**
  6325. * Defines if the texture contains 3D data
  6326. */
  6327. is3D: boolean;
  6328. /**
  6329. * Defines if the texture contains multiview data
  6330. */
  6331. isMultiview: boolean;
  6332. /**
  6333. * Gets the URL used to load this texture
  6334. */
  6335. url: string;
  6336. /**
  6337. * Gets the sampling mode of the texture
  6338. */
  6339. samplingMode: number;
  6340. /**
  6341. * Gets a boolean indicating if the texture needs mipmaps generation
  6342. */
  6343. generateMipMaps: boolean;
  6344. /**
  6345. * Gets the number of samples used by the texture (WebGL2+ only)
  6346. */
  6347. samples: number;
  6348. /**
  6349. * Gets the type of the texture (int, float...)
  6350. */
  6351. type: number;
  6352. /**
  6353. * Gets the format of the texture (RGB, RGBA...)
  6354. */
  6355. format: number;
  6356. /**
  6357. * Observable called when the texture is loaded
  6358. */
  6359. onLoadedObservable: Observable<InternalTexture>;
  6360. /**
  6361. * Gets the width of the texture
  6362. */
  6363. width: number;
  6364. /**
  6365. * Gets the height of the texture
  6366. */
  6367. height: number;
  6368. /**
  6369. * Gets the depth of the texture
  6370. */
  6371. depth: number;
  6372. /**
  6373. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6374. */
  6375. baseWidth: number;
  6376. /**
  6377. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6378. */
  6379. baseHeight: number;
  6380. /**
  6381. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6382. */
  6383. baseDepth: number;
  6384. /**
  6385. * Gets a boolean indicating if the texture is inverted on Y axis
  6386. */
  6387. invertY: boolean;
  6388. /** @hidden */
  6389. _invertVScale: boolean;
  6390. /** @hidden */
  6391. _associatedChannel: number;
  6392. /** @hidden */
  6393. _dataSource: number;
  6394. /** @hidden */
  6395. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6396. /** @hidden */
  6397. _bufferView: Nullable<ArrayBufferView>;
  6398. /** @hidden */
  6399. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6400. /** @hidden */
  6401. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6402. /** @hidden */
  6403. _size: number;
  6404. /** @hidden */
  6405. _extension: string;
  6406. /** @hidden */
  6407. _files: Nullable<string[]>;
  6408. /** @hidden */
  6409. _workingCanvas: Nullable<HTMLCanvasElement>;
  6410. /** @hidden */
  6411. _workingContext: Nullable<CanvasRenderingContext2D>;
  6412. /** @hidden */
  6413. _framebuffer: Nullable<WebGLFramebuffer>;
  6414. /** @hidden */
  6415. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6416. /** @hidden */
  6417. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6418. /** @hidden */
  6419. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6420. /** @hidden */
  6421. _attachments: Nullable<number[]>;
  6422. /** @hidden */
  6423. _cachedCoordinatesMode: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedWrapU: Nullable<number>;
  6426. /** @hidden */
  6427. _cachedWrapV: Nullable<number>;
  6428. /** @hidden */
  6429. _cachedWrapR: Nullable<number>;
  6430. /** @hidden */
  6431. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6432. /** @hidden */
  6433. _isDisabled: boolean;
  6434. /** @hidden */
  6435. _compression: Nullable<string>;
  6436. /** @hidden */
  6437. _generateStencilBuffer: boolean;
  6438. /** @hidden */
  6439. _generateDepthBuffer: boolean;
  6440. /** @hidden */
  6441. _comparisonFunction: number;
  6442. /** @hidden */
  6443. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6444. /** @hidden */
  6445. _lodGenerationScale: number;
  6446. /** @hidden */
  6447. _lodGenerationOffset: number;
  6448. /** @hidden */
  6449. _colorTextureArray: Nullable<WebGLTexture>;
  6450. /** @hidden */
  6451. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6452. /** @hidden */
  6453. _lodTextureHigh: Nullable<BaseTexture>;
  6454. /** @hidden */
  6455. _lodTextureMid: Nullable<BaseTexture>;
  6456. /** @hidden */
  6457. _lodTextureLow: Nullable<BaseTexture>;
  6458. /** @hidden */
  6459. _isRGBD: boolean;
  6460. /** @hidden */
  6461. _webGLTexture: Nullable<WebGLTexture>;
  6462. /** @hidden */
  6463. _references: number;
  6464. private _engine;
  6465. /**
  6466. * Gets the Engine the texture belongs to.
  6467. * @returns The babylon engine
  6468. */
  6469. getEngine(): Engine;
  6470. /**
  6471. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6472. */
  6473. readonly dataSource: number;
  6474. /**
  6475. * Creates a new InternalTexture
  6476. * @param engine defines the engine to use
  6477. * @param dataSource defines the type of data that will be used
  6478. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6479. */
  6480. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6481. /**
  6482. * Increments the number of references (ie. the number of Texture that point to it)
  6483. */
  6484. incrementReferences(): void;
  6485. /**
  6486. * Change the size of the texture (not the size of the content)
  6487. * @param width defines the new width
  6488. * @param height defines the new height
  6489. * @param depth defines the new depth (1 by default)
  6490. */
  6491. updateSize(width: int, height: int, depth?: int): void;
  6492. /** @hidden */
  6493. _rebuild(): void;
  6494. /** @hidden */
  6495. _swapAndDie(target: InternalTexture): void;
  6496. /**
  6497. * Dispose the current allocated resources
  6498. */
  6499. dispose(): void;
  6500. }
  6501. }
  6502. declare module "babylonjs/Animations/easing" {
  6503. /**
  6504. * This represents the main contract an easing function should follow.
  6505. * Easing functions are used throughout the animation system.
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export interface IEasingFunction {
  6509. /**
  6510. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6511. * of the easing function.
  6512. * The link below provides some of the most common examples of easing functions.
  6513. * @see https://easings.net/
  6514. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6515. * @returns the corresponding value on the curve defined by the easing function
  6516. */
  6517. ease(gradient: number): number;
  6518. }
  6519. /**
  6520. * Base class used for every default easing function.
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class EasingFunction implements IEasingFunction {
  6524. /**
  6525. * Interpolation follows the mathematical formula associated with the easing function.
  6526. */
  6527. static readonly EASINGMODE_EASEIN: number;
  6528. /**
  6529. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6530. */
  6531. static readonly EASINGMODE_EASEOUT: number;
  6532. /**
  6533. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6534. */
  6535. static readonly EASINGMODE_EASEINOUT: number;
  6536. private _easingMode;
  6537. /**
  6538. * Sets the easing mode of the current function.
  6539. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6540. */
  6541. setEasingMode(easingMode: number): void;
  6542. /**
  6543. * Gets the current easing mode.
  6544. * @returns the easing mode
  6545. */
  6546. getEasingMode(): number;
  6547. /**
  6548. * @hidden
  6549. */
  6550. easeInCore(gradient: number): number;
  6551. /**
  6552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6553. * of the easing function.
  6554. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6555. * @returns the corresponding value on the curve defined by the easing function
  6556. */
  6557. ease(gradient: number): number;
  6558. }
  6559. /**
  6560. * Easing function with a circle shape (see link below).
  6561. * @see https://easings.net/#easeInCirc
  6562. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6563. */
  6564. export class CircleEase extends EasingFunction implements IEasingFunction {
  6565. /** @hidden */
  6566. easeInCore(gradient: number): number;
  6567. }
  6568. /**
  6569. * Easing function with a ease back shape (see link below).
  6570. * @see https://easings.net/#easeInBack
  6571. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6572. */
  6573. export class BackEase extends EasingFunction implements IEasingFunction {
  6574. /** Defines the amplitude of the function */
  6575. amplitude: number;
  6576. /**
  6577. * Instantiates a back ease easing
  6578. * @see https://easings.net/#easeInBack
  6579. * @param amplitude Defines the amplitude of the function
  6580. */
  6581. constructor(
  6582. /** Defines the amplitude of the function */
  6583. amplitude?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a bouncing shape (see link below).
  6589. * @see https://easings.net/#easeInBounce
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class BounceEase extends EasingFunction implements IEasingFunction {
  6593. /** Defines the number of bounces */
  6594. bounces: number;
  6595. /** Defines the amplitude of the bounce */
  6596. bounciness: number;
  6597. /**
  6598. * Instantiates a bounce easing
  6599. * @see https://easings.net/#easeInBounce
  6600. * @param bounces Defines the number of bounces
  6601. * @param bounciness Defines the amplitude of the bounce
  6602. */
  6603. constructor(
  6604. /** Defines the number of bounces */
  6605. bounces?: number,
  6606. /** Defines the amplitude of the bounce */
  6607. bounciness?: number);
  6608. /** @hidden */
  6609. easeInCore(gradient: number): number;
  6610. }
  6611. /**
  6612. * Easing function with a power of 3 shape (see link below).
  6613. * @see https://easings.net/#easeInCubic
  6614. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6615. */
  6616. export class CubicEase extends EasingFunction implements IEasingFunction {
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an elastic shape (see link below).
  6622. * @see https://easings.net/#easeInElastic
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the number of oscillations*/
  6627. oscillations: number;
  6628. /** Defines the amplitude of the oscillations*/
  6629. springiness: number;
  6630. /**
  6631. * Instantiates an elastic easing function
  6632. * @see https://easings.net/#easeInElastic
  6633. * @param oscillations Defines the number of oscillations
  6634. * @param springiness Defines the amplitude of the oscillations
  6635. */
  6636. constructor(
  6637. /** Defines the number of oscillations*/
  6638. oscillations?: number,
  6639. /** Defines the amplitude of the oscillations*/
  6640. springiness?: number);
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with an exponential shape (see link below).
  6646. * @see https://easings.net/#easeInExpo
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6650. /** Defines the exponent of the function */
  6651. exponent: number;
  6652. /**
  6653. * Instantiates an exponential easing function
  6654. * @see https://easings.net/#easeInExpo
  6655. * @param exponent Defines the exponent of the function
  6656. */
  6657. constructor(
  6658. /** Defines the exponent of the function */
  6659. exponent?: number);
  6660. /** @hidden */
  6661. easeInCore(gradient: number): number;
  6662. }
  6663. /**
  6664. * Easing function with a power shape (see link below).
  6665. * @see https://easings.net/#easeInQuad
  6666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6667. */
  6668. export class PowerEase extends EasingFunction implements IEasingFunction {
  6669. /** Defines the power of the function */
  6670. power: number;
  6671. /**
  6672. * Instantiates an power base easing function
  6673. * @see https://easings.net/#easeInQuad
  6674. * @param power Defines the power of the function
  6675. */
  6676. constructor(
  6677. /** Defines the power of the function */
  6678. power?: number);
  6679. /** @hidden */
  6680. easeInCore(gradient: number): number;
  6681. }
  6682. /**
  6683. * Easing function with a power of 2 shape (see link below).
  6684. * @see https://easings.net/#easeInQuad
  6685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6686. */
  6687. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6688. /** @hidden */
  6689. easeInCore(gradient: number): number;
  6690. }
  6691. /**
  6692. * Easing function with a power of 4 shape (see link below).
  6693. * @see https://easings.net/#easeInQuart
  6694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6695. */
  6696. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6697. /** @hidden */
  6698. easeInCore(gradient: number): number;
  6699. }
  6700. /**
  6701. * Easing function with a power of 5 shape (see link below).
  6702. * @see https://easings.net/#easeInQuint
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a sin shape (see link below).
  6711. * @see https://easings.net/#easeInSine
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class SineEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a bezier shape (see link below).
  6720. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6724. /** Defines the x component of the start tangent in the bezier curve */
  6725. x1: number;
  6726. /** Defines the y component of the start tangent in the bezier curve */
  6727. y1: number;
  6728. /** Defines the x component of the end tangent in the bezier curve */
  6729. x2: number;
  6730. /** Defines the y component of the end tangent in the bezier curve */
  6731. y2: number;
  6732. /**
  6733. * Instantiates a bezier function
  6734. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6735. * @param x1 Defines the x component of the start tangent in the bezier curve
  6736. * @param y1 Defines the y component of the start tangent in the bezier curve
  6737. * @param x2 Defines the x component of the end tangent in the bezier curve
  6738. * @param y2 Defines the y component of the end tangent in the bezier curve
  6739. */
  6740. constructor(
  6741. /** Defines the x component of the start tangent in the bezier curve */
  6742. x1?: number,
  6743. /** Defines the y component of the start tangent in the bezier curve */
  6744. y1?: number,
  6745. /** Defines the x component of the end tangent in the bezier curve */
  6746. x2?: number,
  6747. /** Defines the y component of the end tangent in the bezier curve */
  6748. y2?: number);
  6749. /** @hidden */
  6750. easeInCore(gradient: number): number;
  6751. }
  6752. }
  6753. declare module "babylonjs/Animations/animationKey" {
  6754. /**
  6755. * Defines an interface which represents an animation key frame
  6756. */
  6757. export interface IAnimationKey {
  6758. /**
  6759. * Frame of the key frame
  6760. */
  6761. frame: number;
  6762. /**
  6763. * Value at the specifies key frame
  6764. */
  6765. value: any;
  6766. /**
  6767. * The input tangent for the cubic hermite spline
  6768. */
  6769. inTangent?: any;
  6770. /**
  6771. * The output tangent for the cubic hermite spline
  6772. */
  6773. outTangent?: any;
  6774. /**
  6775. * The animation interpolation type
  6776. */
  6777. interpolation?: AnimationKeyInterpolation;
  6778. }
  6779. /**
  6780. * Enum for the animation key frame interpolation type
  6781. */
  6782. export enum AnimationKeyInterpolation {
  6783. /**
  6784. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6785. */
  6786. STEP = 1
  6787. }
  6788. }
  6789. declare module "babylonjs/Animations/animationRange" {
  6790. /**
  6791. * Represents the range of an animation
  6792. */
  6793. export class AnimationRange {
  6794. /**The name of the animation range**/
  6795. name: string;
  6796. /**The starting frame of the animation */
  6797. from: number;
  6798. /**The ending frame of the animation*/
  6799. to: number;
  6800. /**
  6801. * Initializes the range of an animation
  6802. * @param name The name of the animation range
  6803. * @param from The starting frame of the animation
  6804. * @param to The ending frame of the animation
  6805. */
  6806. constructor(
  6807. /**The name of the animation range**/
  6808. name: string,
  6809. /**The starting frame of the animation */
  6810. from: number,
  6811. /**The ending frame of the animation*/
  6812. to: number);
  6813. /**
  6814. * Makes a copy of the animation range
  6815. * @returns A copy of the animation range
  6816. */
  6817. clone(): AnimationRange;
  6818. }
  6819. }
  6820. declare module "babylonjs/Animations/animationEvent" {
  6821. /**
  6822. * Composed of a frame, and an action function
  6823. */
  6824. export class AnimationEvent {
  6825. /** The frame for which the event is triggered **/
  6826. frame: number;
  6827. /** The event to perform when triggered **/
  6828. action: (currentFrame: number) => void;
  6829. /** Specifies if the event should be triggered only once**/
  6830. onlyOnce?: boolean | undefined;
  6831. /**
  6832. * Specifies if the animation event is done
  6833. */
  6834. isDone: boolean;
  6835. /**
  6836. * Initializes the animation event
  6837. * @param frame The frame for which the event is triggered
  6838. * @param action The event to perform when triggered
  6839. * @param onlyOnce Specifies if the event should be triggered only once
  6840. */
  6841. constructor(
  6842. /** The frame for which the event is triggered **/
  6843. frame: number,
  6844. /** The event to perform when triggered **/
  6845. action: (currentFrame: number) => void,
  6846. /** Specifies if the event should be triggered only once**/
  6847. onlyOnce?: boolean | undefined);
  6848. /** @hidden */
  6849. _clone(): AnimationEvent;
  6850. }
  6851. }
  6852. declare module "babylonjs/Behaviors/behavior" {
  6853. import { Nullable } from "babylonjs/types";
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module "babylonjs/Collisions/intersectionInfo" {
  6899. import { Nullable } from "babylonjs/types";
  6900. /**
  6901. * @hidden
  6902. */
  6903. export class IntersectionInfo {
  6904. bu: Nullable<number>;
  6905. bv: Nullable<number>;
  6906. distance: number;
  6907. faceId: number;
  6908. subMeshId: number;
  6909. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6910. }
  6911. }
  6912. declare module "babylonjs/Culling/boundingSphere" {
  6913. import { DeepImmutable } from "babylonjs/types";
  6914. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6915. /**
  6916. * Class used to store bounding sphere information
  6917. */
  6918. export class BoundingSphere {
  6919. /**
  6920. * Gets the center of the bounding sphere in local space
  6921. */
  6922. readonly center: Vector3;
  6923. /**
  6924. * Radius of the bounding sphere in local space
  6925. */
  6926. radius: number;
  6927. /**
  6928. * Gets the center of the bounding sphere in world space
  6929. */
  6930. readonly centerWorld: Vector3;
  6931. /**
  6932. * Radius of the bounding sphere in world space
  6933. */
  6934. radiusWorld: number;
  6935. /**
  6936. * Gets the minimum vector in local space
  6937. */
  6938. readonly minimum: Vector3;
  6939. /**
  6940. * Gets the maximum vector in local space
  6941. */
  6942. readonly maximum: Vector3;
  6943. private _worldMatrix;
  6944. private static readonly TmpVector3;
  6945. /**
  6946. * Creates a new bounding sphere
  6947. * @param min defines the minimum vector (in local space)
  6948. * @param max defines the maximum vector (in local space)
  6949. * @param worldMatrix defines the new world matrix
  6950. */
  6951. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6952. /**
  6953. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6954. * @param min defines the new minimum vector (in local space)
  6955. * @param max defines the new maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6959. /**
  6960. * Scale the current bounding sphere by applying a scale factor
  6961. * @param factor defines the scale factor to apply
  6962. * @returns the current bounding box
  6963. */
  6964. scale(factor: number): BoundingSphere;
  6965. /**
  6966. * Gets the world matrix of the bounding box
  6967. * @returns a matrix
  6968. */
  6969. getWorldMatrix(): DeepImmutable<Matrix>;
  6970. /** @hidden */
  6971. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding sphere is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding sphere center is in between the frustum planes.
  6980. * Used for optimistic fast inclusion.
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if the sphere center is in between the frustum planes
  6983. */
  6984. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if a point is inside the bounding sphere
  6987. * @param point defines the point to test
  6988. * @returns true if the point is inside the bounding sphere
  6989. */
  6990. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6991. /**
  6992. * Checks if two sphere intersct
  6993. * @param sphere0 sphere 0
  6994. * @param sphere1 sphere 1
  6995. * @returns true if the speres intersect
  6996. */
  6997. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Culling/boundingBox" {
  7001. import { DeepImmutable } from "babylonjs/types";
  7002. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7003. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7004. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7005. /**
  7006. * Class used to store bounding box information
  7007. */
  7008. export class BoundingBox implements ICullable {
  7009. /**
  7010. * Gets the 8 vectors representing the bounding box in local space
  7011. */
  7012. readonly vectors: Vector3[];
  7013. /**
  7014. * Gets the center of the bounding box in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Gets the center of the bounding box in world space
  7019. */
  7020. readonly centerWorld: Vector3;
  7021. /**
  7022. * Gets the extend size in local space
  7023. */
  7024. readonly extendSize: Vector3;
  7025. /**
  7026. * Gets the extend size in world space
  7027. */
  7028. readonly extendSizeWorld: Vector3;
  7029. /**
  7030. * Gets the OBB (object bounding box) directions
  7031. */
  7032. readonly directions: Vector3[];
  7033. /**
  7034. * Gets the 8 vectors representing the bounding box in world space
  7035. */
  7036. readonly vectorsWorld: Vector3[];
  7037. /**
  7038. * Gets the minimum vector in world space
  7039. */
  7040. readonly minimumWorld: Vector3;
  7041. /**
  7042. * Gets the maximum vector in world space
  7043. */
  7044. readonly maximumWorld: Vector3;
  7045. /**
  7046. * Gets the minimum vector in local space
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * Gets the maximum vector in local space
  7051. */
  7052. readonly maximum: Vector3;
  7053. private _worldMatrix;
  7054. private static readonly TmpVector3;
  7055. /**
  7056. * @hidden
  7057. */
  7058. _tag: number;
  7059. /**
  7060. * Creates a new bounding box
  7061. * @param min defines the minimum vector (in local space)
  7062. * @param max defines the maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7066. /**
  7067. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7068. * @param min defines the new minimum vector (in local space)
  7069. * @param max defines the new maximum vector (in local space)
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7073. /**
  7074. * Scale the current bounding box by applying a scale factor
  7075. * @param factor defines the scale factor to apply
  7076. * @returns the current bounding box
  7077. */
  7078. scale(factor: number): BoundingBox;
  7079. /**
  7080. * Gets the world matrix of the bounding box
  7081. * @returns a matrix
  7082. */
  7083. getWorldMatrix(): DeepImmutable<Matrix>;
  7084. /** @hidden */
  7085. _update(world: DeepImmutable<Matrix>): void;
  7086. /**
  7087. * Tests if the bounding box is intersecting the frustum planes
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if the bounding box is entirely inside the frustum planes
  7094. * @param frustumPlanes defines the frustum planes to test
  7095. * @returns true if there is an inclusion
  7096. */
  7097. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7098. /**
  7099. * Tests if a point is inside the bounding box
  7100. * @param point defines the point to test
  7101. * @returns true if the point is inside the bounding box
  7102. */
  7103. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7104. /**
  7105. * Tests if the bounding box intersects with a bounding sphere
  7106. * @param sphere defines the sphere to test
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7110. /**
  7111. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7112. * @param min defines the min vector to use
  7113. * @param max defines the max vector to use
  7114. * @returns true if there is an intersection
  7115. */
  7116. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Tests if two bounding boxes are intersections
  7119. * @param box0 defines the first box to test
  7120. * @param box1 defines the second box to test
  7121. * @returns true if there is an intersection
  7122. */
  7123. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7124. /**
  7125. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7126. * @param minPoint defines the minimum vector of the bounding box
  7127. * @param maxPoint defines the maximum vector of the bounding box
  7128. * @param sphereCenter defines the sphere center
  7129. * @param sphereRadius defines the sphere radius
  7130. * @returns true if there is an intersection
  7131. */
  7132. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an inclusion
  7138. */
  7139. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. /**
  7141. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7142. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @return true if there is an intersection
  7145. */
  7146. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. }
  7148. }
  7149. declare module "babylonjs/Collisions/collider" {
  7150. import { Nullable, IndicesArray } from "babylonjs/types";
  7151. import { Vector3, Plane } from "babylonjs/Maths/math";
  7152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7153. /** @hidden */
  7154. export class Collider {
  7155. /** Define if a collision was found */
  7156. collisionFound: boolean;
  7157. /**
  7158. * Define last intersection point in local space
  7159. */
  7160. intersectionPoint: Vector3;
  7161. /**
  7162. * Define last collided mesh
  7163. */
  7164. collidedMesh: Nullable<AbstractMesh>;
  7165. private _collisionPoint;
  7166. private _planeIntersectionPoint;
  7167. private _tempVector;
  7168. private _tempVector2;
  7169. private _tempVector3;
  7170. private _tempVector4;
  7171. private _edge;
  7172. private _baseToVertex;
  7173. private _destinationPoint;
  7174. private _slidePlaneNormal;
  7175. private _displacementVector;
  7176. /** @hidden */
  7177. _radius: Vector3;
  7178. /** @hidden */
  7179. _retry: number;
  7180. private _velocity;
  7181. private _basePoint;
  7182. private _epsilon;
  7183. /** @hidden */
  7184. _velocityWorldLength: number;
  7185. /** @hidden */
  7186. _basePointWorld: Vector3;
  7187. private _velocityWorld;
  7188. private _normalizedVelocity;
  7189. /** @hidden */
  7190. _initialVelocity: Vector3;
  7191. /** @hidden */
  7192. _initialPosition: Vector3;
  7193. private _nearestDistance;
  7194. private _collisionMask;
  7195. collisionMask: number;
  7196. /**
  7197. * Gets the plane normal used to compute the sliding response (in local space)
  7198. */
  7199. readonly slidePlaneNormal: Vector3;
  7200. /** @hidden */
  7201. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7202. /** @hidden */
  7203. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7204. /** @hidden */
  7205. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7206. /** @hidden */
  7207. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7208. /** @hidden */
  7209. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7210. /** @hidden */
  7211. _getResponse(pos: Vector3, vel: Vector3): void;
  7212. }
  7213. }
  7214. declare module "babylonjs/Culling/boundingInfo" {
  7215. import { DeepImmutable } from "babylonjs/types";
  7216. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7217. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7218. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7219. import { Collider } from "babylonjs/Collisions/collider";
  7220. /**
  7221. * Interface for cullable objects
  7222. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7223. */
  7224. export interface ICullable {
  7225. /**
  7226. * Checks if the object or part of the object is in the frustum
  7227. * @param frustumPlanes Camera near/planes
  7228. * @returns true if the object is in frustum otherwise false
  7229. */
  7230. isInFrustum(frustumPlanes: Plane[]): boolean;
  7231. /**
  7232. * Checks if a cullable object (mesh...) is in the camera frustum
  7233. * Unlike isInFrustum this cheks the full bounding box
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7238. }
  7239. /**
  7240. * Info for a bounding data of a mesh
  7241. */
  7242. export class BoundingInfo implements ICullable {
  7243. /**
  7244. * Bounding box for the mesh
  7245. */
  7246. readonly boundingBox: BoundingBox;
  7247. /**
  7248. * Bounding sphere for the mesh
  7249. */
  7250. readonly boundingSphere: BoundingSphere;
  7251. private _isLocked;
  7252. private static readonly TmpVector3;
  7253. /**
  7254. * Constructs bounding info
  7255. * @param minimum min vector of the bounding box/sphere
  7256. * @param maximum max vector of the bounding box/sphere
  7257. * @param worldMatrix defines the new world matrix
  7258. */
  7259. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7260. /**
  7261. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7262. * @param min defines the new minimum vector (in local space)
  7263. * @param max defines the new maximum vector (in local space)
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7267. /**
  7268. * min vector of the bounding box/sphere
  7269. */
  7270. readonly minimum: Vector3;
  7271. /**
  7272. * max vector of the bounding box/sphere
  7273. */
  7274. readonly maximum: Vector3;
  7275. /**
  7276. * If the info is locked and won't be updated to avoid perf overhead
  7277. */
  7278. isLocked: boolean;
  7279. /**
  7280. * Updates the bounding sphere and box
  7281. * @param world world matrix to be used to update
  7282. */
  7283. update(world: DeepImmutable<Matrix>): void;
  7284. /**
  7285. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7286. * @param center New center of the bounding info
  7287. * @param extend New extend of the bounding info
  7288. * @returns the current bounding info
  7289. */
  7290. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7291. /**
  7292. * Scale the current bounding info by applying a scale factor
  7293. * @param factor defines the scale factor to apply
  7294. * @returns the current bounding info
  7295. */
  7296. scale(factor: number): BoundingInfo;
  7297. /**
  7298. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7299. * @param frustumPlanes defines the frustum to test
  7300. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7301. * @returns true if the bounding info is in the frustum planes
  7302. */
  7303. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7304. /**
  7305. * Gets the world distance between the min and max points of the bounding box
  7306. */
  7307. readonly diagonalLength: number;
  7308. /**
  7309. * Checks if a cullable object (mesh...) is in the camera frustum
  7310. * Unlike isInFrustum this cheks the full bounding box
  7311. * @param frustumPlanes Camera near/planes
  7312. * @returns true if the object is in frustum otherwise false
  7313. */
  7314. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7315. /** @hidden */
  7316. _checkCollision(collider: Collider): boolean;
  7317. /**
  7318. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7319. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7320. * @param point the point to check intersection with
  7321. * @returns if the point intersects
  7322. */
  7323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7324. /**
  7325. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param boundingInfo the bounding info to check intersection with
  7328. * @param precise if the intersection should be done using OBB
  7329. * @returns if the bounding info intersects
  7330. */
  7331. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7332. }
  7333. }
  7334. declare module "babylonjs/Misc/smartArray" {
  7335. /**
  7336. * Defines an array and its length.
  7337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7338. */
  7339. export interface ISmartArrayLike<T> {
  7340. /**
  7341. * The data of the array.
  7342. */
  7343. data: Array<T>;
  7344. /**
  7345. * The active length of the array.
  7346. */
  7347. length: number;
  7348. }
  7349. /**
  7350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7351. */
  7352. export class SmartArray<T> implements ISmartArrayLike<T> {
  7353. /**
  7354. * The full set of data from the array.
  7355. */
  7356. data: Array<T>;
  7357. /**
  7358. * The active length of the array.
  7359. */
  7360. length: number;
  7361. protected _id: number;
  7362. /**
  7363. * Instantiates a Smart Array.
  7364. * @param capacity defines the default capacity of the array.
  7365. */
  7366. constructor(capacity: number);
  7367. /**
  7368. * Pushes a value at the end of the active data.
  7369. * @param value defines the object to push in the array.
  7370. */
  7371. push(value: T): void;
  7372. /**
  7373. * Iterates over the active data and apply the lambda to them.
  7374. * @param func defines the action to apply on each value.
  7375. */
  7376. forEach(func: (content: T) => void): void;
  7377. /**
  7378. * Sorts the full sets of data.
  7379. * @param compareFn defines the comparison function to apply.
  7380. */
  7381. sort(compareFn: (a: T, b: T) => number): void;
  7382. /**
  7383. * Resets the active data to an empty array.
  7384. */
  7385. reset(): void;
  7386. /**
  7387. * Releases all the data from the array as well as the array.
  7388. */
  7389. dispose(): void;
  7390. /**
  7391. * Concats the active data with a given array.
  7392. * @param array defines the data to concatenate with.
  7393. */
  7394. concat(array: any): void;
  7395. /**
  7396. * Returns the position of a value in the active data.
  7397. * @param value defines the value to find the index for
  7398. * @returns the index if found in the active data otherwise -1
  7399. */
  7400. indexOf(value: T): number;
  7401. /**
  7402. * Returns whether an element is part of the active data.
  7403. * @param value defines the value to look for
  7404. * @returns true if found in the active data otherwise false
  7405. */
  7406. contains(value: T): boolean;
  7407. private static _GlobalId;
  7408. }
  7409. /**
  7410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7411. * The data in this array can only be present once
  7412. */
  7413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7414. private _duplicateId;
  7415. /**
  7416. * Pushes a value at the end of the active data.
  7417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7418. * @param value defines the object to push in the array.
  7419. */
  7420. push(value: T): void;
  7421. /**
  7422. * Pushes a value at the end of the active data.
  7423. * If the data is already present, it won t be added again
  7424. * @param value defines the object to push in the array.
  7425. * @returns true if added false if it was already present
  7426. */
  7427. pushNoDuplicate(value: T): boolean;
  7428. /**
  7429. * Resets the active data to an empty array.
  7430. */
  7431. reset(): void;
  7432. /**
  7433. * Concats the active data with a given array.
  7434. * This ensures no dupplicate will be present in the result.
  7435. * @param array defines the data to concatenate with.
  7436. */
  7437. concatWithNoDuplicate(array: any): void;
  7438. }
  7439. }
  7440. declare module "babylonjs/Materials/multiMaterial" {
  7441. import { Nullable } from "babylonjs/types";
  7442. import { Scene } from "babylonjs/scene";
  7443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7444. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7446. import { Material } from "babylonjs/Materials/material";
  7447. /**
  7448. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7449. * separate meshes. This can be use to improve performances.
  7450. * @see http://doc.babylonjs.com/how_to/multi_materials
  7451. */
  7452. export class MultiMaterial extends Material {
  7453. private _subMaterials;
  7454. /**
  7455. * Gets or Sets the list of Materials used within the multi material.
  7456. * They need to be ordered according to the submeshes order in the associated mesh
  7457. */
  7458. subMaterials: Nullable<Material>[];
  7459. /**
  7460. * Function used to align with Node.getChildren()
  7461. * @returns the list of Materials used within the multi material
  7462. */
  7463. getChildren(): Nullable<Material>[];
  7464. /**
  7465. * Instantiates a new Multi Material
  7466. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7467. * separate meshes. This can be use to improve performances.
  7468. * @see http://doc.babylonjs.com/how_to/multi_materials
  7469. * @param name Define the name in the scene
  7470. * @param scene Define the scene the material belongs to
  7471. */
  7472. constructor(name: string, scene: Scene);
  7473. private _hookArray;
  7474. /**
  7475. * Get one of the submaterial by its index in the submaterials array
  7476. * @param index The index to look the sub material at
  7477. * @returns The Material if the index has been defined
  7478. */
  7479. getSubMaterial(index: number): Nullable<Material>;
  7480. /**
  7481. * Get the list of active textures for the whole sub materials list.
  7482. * @returns All the textures that will be used during the rendering
  7483. */
  7484. getActiveTextures(): BaseTexture[];
  7485. /**
  7486. * Gets the current class name of the material e.g. "MultiMaterial"
  7487. * Mainly use in serialization.
  7488. * @returns the class name
  7489. */
  7490. getClassName(): string;
  7491. /**
  7492. * Checks if the material is ready to render the requested sub mesh
  7493. * @param mesh Define the mesh the submesh belongs to
  7494. * @param subMesh Define the sub mesh to look readyness for
  7495. * @param useInstances Define whether or not the material is used with instances
  7496. * @returns true if ready, otherwise false
  7497. */
  7498. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7499. /**
  7500. * Clones the current material and its related sub materials
  7501. * @param name Define the name of the newly cloned material
  7502. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7503. * @returns the cloned material
  7504. */
  7505. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7506. /**
  7507. * Serializes the materials into a JSON representation.
  7508. * @returns the JSON representation
  7509. */
  7510. serialize(): any;
  7511. /**
  7512. * Dispose the material and release its associated resources
  7513. * @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)
  7514. * @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)
  7515. * @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)
  7516. */
  7517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7518. /**
  7519. * Creates a MultiMaterial from parsed MultiMaterial data.
  7520. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7521. * @param scene defines the hosting scene
  7522. * @returns a new MultiMaterial
  7523. */
  7524. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7525. }
  7526. }
  7527. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7528. /**
  7529. * Class used to represent data loading progression
  7530. */
  7531. export class SceneLoaderFlags {
  7532. private static _ForceFullSceneLoadingForIncremental;
  7533. private static _ShowLoadingScreen;
  7534. private static _CleanBoneMatrixWeights;
  7535. private static _loggingLevel;
  7536. /**
  7537. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7538. */
  7539. static ForceFullSceneLoadingForIncremental: boolean;
  7540. /**
  7541. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7542. */
  7543. static ShowLoadingScreen: boolean;
  7544. /**
  7545. * Defines the current logging level (while loading the scene)
  7546. * @ignorenaming
  7547. */
  7548. static loggingLevel: number;
  7549. /**
  7550. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7551. */
  7552. static CleanBoneMatrixWeights: boolean;
  7553. }
  7554. }
  7555. declare module "babylonjs/Meshes/transformNode" {
  7556. import { DeepImmutable } from "babylonjs/types";
  7557. import { Observable } from "babylonjs/Misc/observable";
  7558. import { Nullable } from "babylonjs/types";
  7559. import { Camera } from "babylonjs/Cameras/camera";
  7560. import { Scene } from "babylonjs/scene";
  7561. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7562. import { Node } from "babylonjs/node";
  7563. import { Bone } from "babylonjs/Bones/bone";
  7564. /**
  7565. * 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.
  7566. * @see https://doc.babylonjs.com/how_to/transformnode
  7567. */
  7568. export class TransformNode extends Node {
  7569. /**
  7570. * Object will not rotate to face the camera
  7571. */
  7572. static BILLBOARDMODE_NONE: number;
  7573. /**
  7574. * Object will rotate to face the camera but only on the x axis
  7575. */
  7576. static BILLBOARDMODE_X: number;
  7577. /**
  7578. * Object will rotate to face the camera but only on the y axis
  7579. */
  7580. static BILLBOARDMODE_Y: number;
  7581. /**
  7582. * Object will rotate to face the camera but only on the z axis
  7583. */
  7584. static BILLBOARDMODE_Z: number;
  7585. /**
  7586. * Object will rotate to face the camera
  7587. */
  7588. static BILLBOARDMODE_ALL: number;
  7589. private _forward;
  7590. private _forwardInverted;
  7591. private _up;
  7592. private _right;
  7593. private _rightInverted;
  7594. private _position;
  7595. private _rotation;
  7596. private _rotationQuaternion;
  7597. protected _scaling: Vector3;
  7598. protected _isDirty: boolean;
  7599. private _transformToBoneReferal;
  7600. private _billboardMode;
  7601. /**
  7602. * Gets or sets the billboard mode. Default is 0.
  7603. *
  7604. * | Value | Type | Description |
  7605. * | --- | --- | --- |
  7606. * | 0 | BILLBOARDMODE_NONE | |
  7607. * | 1 | BILLBOARDMODE_X | |
  7608. * | 2 | BILLBOARDMODE_Y | |
  7609. * | 4 | BILLBOARDMODE_Z | |
  7610. * | 7 | BILLBOARDMODE_ALL | |
  7611. *
  7612. */
  7613. billboardMode: number;
  7614. private _preserveParentRotationForBillboard;
  7615. /**
  7616. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7617. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7618. */
  7619. preserveParentRotationForBillboard: boolean;
  7620. /**
  7621. * 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
  7622. */
  7623. scalingDeterminant: number;
  7624. private _infiniteDistance;
  7625. /**
  7626. * Gets or sets the distance of the object to max, often used by skybox
  7627. */
  7628. infiniteDistance: boolean;
  7629. /**
  7630. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7631. * By default the system will update normals to compensate
  7632. */
  7633. ignoreNonUniformScaling: boolean;
  7634. /**
  7635. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7636. */
  7637. reIntegrateRotationIntoRotationQuaternion: boolean;
  7638. /** @hidden */
  7639. _poseMatrix: Nullable<Matrix>;
  7640. /** @hidden */
  7641. _localMatrix: Matrix;
  7642. private _usePivotMatrix;
  7643. private _absolutePosition;
  7644. private _pivotMatrix;
  7645. private _pivotMatrixInverse;
  7646. protected _postMultiplyPivotMatrix: boolean;
  7647. protected _isWorldMatrixFrozen: boolean;
  7648. /** @hidden */
  7649. _indexInSceneTransformNodesArray: number;
  7650. /**
  7651. * An event triggered after the world matrix is updated
  7652. */
  7653. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7654. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7655. /**
  7656. * Gets a string identifying the name of the class
  7657. * @returns "TransformNode" string
  7658. */
  7659. getClassName(): string;
  7660. /**
  7661. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7662. */
  7663. position: Vector3;
  7664. /**
  7665. * 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)).
  7666. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7667. */
  7668. rotation: Vector3;
  7669. /**
  7670. * 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)).
  7671. */
  7672. scaling: Vector3;
  7673. /**
  7674. * 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).
  7675. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7676. */
  7677. rotationQuaternion: Nullable<Quaternion>;
  7678. /**
  7679. * The forward direction of that transform in world space.
  7680. */
  7681. readonly forward: Vector3;
  7682. /**
  7683. * The up direction of that transform in world space.
  7684. */
  7685. readonly up: Vector3;
  7686. /**
  7687. * The right direction of that transform in world space.
  7688. */
  7689. readonly right: Vector3;
  7690. /**
  7691. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7692. * @param matrix the matrix to copy the pose from
  7693. * @returns this TransformNode.
  7694. */
  7695. updatePoseMatrix(matrix: Matrix): TransformNode;
  7696. /**
  7697. * Returns the mesh Pose matrix.
  7698. * @returns the pose matrix
  7699. */
  7700. getPoseMatrix(): Matrix;
  7701. /** @hidden */
  7702. _isSynchronized(): boolean;
  7703. /** @hidden */
  7704. _initCache(): void;
  7705. /**
  7706. * Flag the transform node as dirty (Forcing it to update everything)
  7707. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7708. * @returns this transform node
  7709. */
  7710. markAsDirty(property: string): TransformNode;
  7711. /**
  7712. * Returns the current mesh absolute position.
  7713. * Returns a Vector3.
  7714. */
  7715. readonly absolutePosition: Vector3;
  7716. /**
  7717. * Sets a new matrix to apply before all other transformation
  7718. * @param matrix defines the transform matrix
  7719. * @returns the current TransformNode
  7720. */
  7721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7722. /**
  7723. * Sets a new pivot matrix to the current node
  7724. * @param matrix defines the new pivot matrix to use
  7725. * @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
  7726. * @returns the current TransformNode
  7727. */
  7728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7729. /**
  7730. * Returns the mesh pivot matrix.
  7731. * Default : Identity.
  7732. * @returns the matrix
  7733. */
  7734. getPivotMatrix(): Matrix;
  7735. /**
  7736. * Prevents the World matrix to be computed any longer.
  7737. * @returns the TransformNode.
  7738. */
  7739. freezeWorldMatrix(): TransformNode;
  7740. /**
  7741. * Allows back the World matrix computation.
  7742. * @returns the TransformNode.
  7743. */
  7744. unfreezeWorldMatrix(): this;
  7745. /**
  7746. * True if the World matrix has been frozen.
  7747. */
  7748. readonly isWorldMatrixFrozen: boolean;
  7749. /**
  7750. * Retuns the mesh absolute position in the World.
  7751. * @returns a Vector3.
  7752. */
  7753. getAbsolutePosition(): Vector3;
  7754. /**
  7755. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7756. * @param absolutePosition the absolute position to set
  7757. * @returns the TransformNode.
  7758. */
  7759. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7760. /**
  7761. * Sets the mesh position in its local space.
  7762. * @param vector3 the position to set in localspace
  7763. * @returns the TransformNode.
  7764. */
  7765. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7766. /**
  7767. * Returns the mesh position in the local space from the current World matrix values.
  7768. * @returns a new Vector3.
  7769. */
  7770. getPositionExpressedInLocalSpace(): Vector3;
  7771. /**
  7772. * Translates the mesh along the passed Vector3 in its local space.
  7773. * @param vector3 the distance to translate in localspace
  7774. * @returns the TransformNode.
  7775. */
  7776. locallyTranslate(vector3: Vector3): TransformNode;
  7777. private static _lookAtVectorCache;
  7778. /**
  7779. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7780. * @param targetPoint the position (must be in same space as current mesh) to look at
  7781. * @param yawCor optional yaw (y-axis) correction in radians
  7782. * @param pitchCor optional pitch (x-axis) correction in radians
  7783. * @param rollCor optional roll (z-axis) correction in radians
  7784. * @param space the choosen space of the target
  7785. * @returns the TransformNode.
  7786. */
  7787. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7788. /**
  7789. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7790. * This Vector3 is expressed in the World space.
  7791. * @param localAxis axis to rotate
  7792. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7793. */
  7794. getDirection(localAxis: Vector3): Vector3;
  7795. /**
  7796. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7797. * localAxis is expressed in the mesh local space.
  7798. * result is computed in the Wordl space from the mesh World matrix.
  7799. * @param localAxis axis to rotate
  7800. * @param result the resulting transformnode
  7801. * @returns this TransformNode.
  7802. */
  7803. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7804. /**
  7805. * Sets this transform node rotation to the given local axis.
  7806. * @param localAxis the axis in local space
  7807. * @param yawCor optional yaw (y-axis) correction in radians
  7808. * @param pitchCor optional pitch (x-axis) correction in radians
  7809. * @param rollCor optional roll (z-axis) correction in radians
  7810. * @returns this TransformNode
  7811. */
  7812. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7813. /**
  7814. * Sets a new pivot point to the current node
  7815. * @param point defines the new pivot point to use
  7816. * @param space defines if the point is in world or local space (local by default)
  7817. * @returns the current TransformNode
  7818. */
  7819. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7820. /**
  7821. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7822. * @returns the pivot point
  7823. */
  7824. getPivotPoint(): Vector3;
  7825. /**
  7826. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7827. * @param result the vector3 to store the result
  7828. * @returns this TransformNode.
  7829. */
  7830. getPivotPointToRef(result: Vector3): TransformNode;
  7831. /**
  7832. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7833. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7834. */
  7835. getAbsolutePivotPoint(): Vector3;
  7836. /**
  7837. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7838. * @param result vector3 to store the result
  7839. * @returns this TransformNode.
  7840. */
  7841. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7842. /**
  7843. * Defines the passed node as the parent of the current node.
  7844. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7845. * @see https://doc.babylonjs.com/how_to/parenting
  7846. * @param node the node ot set as the parent
  7847. * @returns this TransformNode.
  7848. */
  7849. setParent(node: Nullable<Node>): TransformNode;
  7850. private _nonUniformScaling;
  7851. /**
  7852. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7853. */
  7854. readonly nonUniformScaling: boolean;
  7855. /** @hidden */
  7856. _updateNonUniformScalingState(value: boolean): boolean;
  7857. /**
  7858. * Attach the current TransformNode to another TransformNode associated with a bone
  7859. * @param bone Bone affecting the TransformNode
  7860. * @param affectedTransformNode TransformNode associated with the bone
  7861. * @returns this object
  7862. */
  7863. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7864. /**
  7865. * Detach the transform node if its associated with a bone
  7866. * @returns this object
  7867. */
  7868. detachFromBone(): TransformNode;
  7869. private static _rotationAxisCache;
  7870. /**
  7871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7872. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7874. * The passed axis is also normalized.
  7875. * @param axis the axis to rotate around
  7876. * @param amount the amount to rotate in radians
  7877. * @param space Space to rotate in (Default: local)
  7878. * @returns the TransformNode.
  7879. */
  7880. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7881. /**
  7882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7883. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7884. * The passed axis is also normalized. .
  7885. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7886. * @param point the point to rotate around
  7887. * @param axis the axis to rotate around
  7888. * @param amount the amount to rotate in radians
  7889. * @returns the TransformNode
  7890. */
  7891. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7892. /**
  7893. * Translates the mesh along the axis vector for the passed distance in the given space.
  7894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7895. * @param axis the axis to translate in
  7896. * @param distance the distance to translate
  7897. * @param space Space to rotate in (Default: local)
  7898. * @returns the TransformNode.
  7899. */
  7900. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7901. /**
  7902. * Adds a rotation step to the mesh current rotation.
  7903. * x, y, z are Euler angles expressed in radians.
  7904. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7905. * This means this rotation is made in the mesh local space only.
  7906. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7907. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7908. * ```javascript
  7909. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7910. * ```
  7911. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7912. * 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.
  7913. * @param x Rotation to add
  7914. * @param y Rotation to add
  7915. * @param z Rotation to add
  7916. * @returns the TransformNode.
  7917. */
  7918. addRotation(x: number, y: number, z: number): TransformNode;
  7919. /**
  7920. * @hidden
  7921. */
  7922. protected _getEffectiveParent(): Nullable<Node>;
  7923. /**
  7924. * Computes the world matrix of the node
  7925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7926. * @returns the world matrix
  7927. */
  7928. computeWorldMatrix(force?: boolean): Matrix;
  7929. protected _afterComputeWorldMatrix(): void;
  7930. /**
  7931. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7932. * @param func callback function to add
  7933. *
  7934. * @returns the TransformNode.
  7935. */
  7936. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7937. /**
  7938. * Removes a registered callback function.
  7939. * @param func callback function to remove
  7940. * @returns the TransformNode.
  7941. */
  7942. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7943. /**
  7944. * Gets the position of the current mesh in camera space
  7945. * @param camera defines the camera to use
  7946. * @returns a position
  7947. */
  7948. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7949. /**
  7950. * Returns the distance from the mesh to the active camera
  7951. * @param camera defines the camera to use
  7952. * @returns the distance
  7953. */
  7954. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7955. /**
  7956. * Clone the current transform node
  7957. * @param name Name of the new clone
  7958. * @param newParent New parent for the clone
  7959. * @param doNotCloneChildren Do not clone children hierarchy
  7960. * @returns the new transform node
  7961. */
  7962. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7963. /**
  7964. * Serializes the objects information.
  7965. * @param currentSerializationObject defines the object to serialize in
  7966. * @returns the serialized object
  7967. */
  7968. serialize(currentSerializationObject?: any): any;
  7969. /**
  7970. * Returns a new TransformNode object parsed from the source provided.
  7971. * @param parsedTransformNode is the source.
  7972. * @param scene the scne the object belongs to
  7973. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7974. * @returns a new TransformNode object parsed from the source provided.
  7975. */
  7976. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7977. /**
  7978. * Get all child-transformNodes of this node
  7979. * @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
  7980. * @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
  7981. * @returns an array of TransformNode
  7982. */
  7983. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7984. /**
  7985. * Releases resources associated with this transform node.
  7986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7988. */
  7989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7990. }
  7991. }
  7992. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7993. /**
  7994. * Class used to override all child animations of a given target
  7995. */
  7996. export class AnimationPropertiesOverride {
  7997. /**
  7998. * Gets or sets a value indicating if animation blending must be used
  7999. */
  8000. enableBlending: boolean;
  8001. /**
  8002. * Gets or sets the blending speed to use when enableBlending is true
  8003. */
  8004. blendingSpeed: number;
  8005. /**
  8006. * Gets or sets the default loop mode to use
  8007. */
  8008. loopMode: number;
  8009. }
  8010. }
  8011. declare module "babylonjs/Bones/bone" {
  8012. import { Skeleton } from "babylonjs/Bones/skeleton";
  8013. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8017. import { Node } from "babylonjs/node";
  8018. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8019. /**
  8020. * Class used to store bone information
  8021. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8022. */
  8023. export class Bone extends Node {
  8024. /**
  8025. * defines the bone name
  8026. */
  8027. name: string;
  8028. private static _tmpVecs;
  8029. private static _tmpQuat;
  8030. private static _tmpMats;
  8031. /**
  8032. * Gets the list of child bones
  8033. */
  8034. children: Bone[];
  8035. /** Gets the animations associated with this bone */
  8036. animations: import("babylonjs/Animations/animation").Animation[];
  8037. /**
  8038. * Gets or sets bone length
  8039. */
  8040. length: number;
  8041. /**
  8042. * @hidden Internal only
  8043. * Set this value to map this bone to a different index in the transform matrices
  8044. * Set this value to -1 to exclude the bone from the transform matrices
  8045. */
  8046. _index: Nullable<number>;
  8047. private _skeleton;
  8048. private _localMatrix;
  8049. private _restPose;
  8050. private _baseMatrix;
  8051. private _absoluteTransform;
  8052. private _invertedAbsoluteTransform;
  8053. private _parent;
  8054. private _scalingDeterminant;
  8055. private _worldTransform;
  8056. private _localScaling;
  8057. private _localRotation;
  8058. private _localPosition;
  8059. private _needToDecompose;
  8060. private _needToCompose;
  8061. /** @hidden */
  8062. _linkedTransformNode: Nullable<TransformNode>;
  8063. /** @hidden */
  8064. /** @hidden */
  8065. _matrix: Matrix;
  8066. /**
  8067. * Create a new bone
  8068. * @param name defines the bone name
  8069. * @param skeleton defines the parent skeleton
  8070. * @param parentBone defines the parent (can be null if the bone is the root)
  8071. * @param localMatrix defines the local matrix
  8072. * @param restPose defines the rest pose matrix
  8073. * @param baseMatrix defines the base matrix
  8074. * @param index defines index of the bone in the hiearchy
  8075. */
  8076. constructor(
  8077. /**
  8078. * defines the bone name
  8079. */
  8080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8081. /**
  8082. * Gets the current object class name.
  8083. * @return the class name
  8084. */
  8085. getClassName(): string;
  8086. /**
  8087. * Gets the parent skeleton
  8088. * @returns a skeleton
  8089. */
  8090. getSkeleton(): Skeleton;
  8091. /**
  8092. * Gets parent bone
  8093. * @returns a bone or null if the bone is the root of the bone hierarchy
  8094. */
  8095. getParent(): Nullable<Bone>;
  8096. /**
  8097. * Returns an array containing the root bones
  8098. * @returns an array containing the root bones
  8099. */
  8100. getChildren(): Array<Bone>;
  8101. /**
  8102. * Sets the parent bone
  8103. * @param parent defines the parent (can be null if the bone is the root)
  8104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8105. */
  8106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8107. /**
  8108. * Gets the local matrix
  8109. * @returns a matrix
  8110. */
  8111. getLocalMatrix(): Matrix;
  8112. /**
  8113. * Gets the base matrix (initial matrix which remains unchanged)
  8114. * @returns a matrix
  8115. */
  8116. getBaseMatrix(): Matrix;
  8117. /**
  8118. * Gets the rest pose matrix
  8119. * @returns a matrix
  8120. */
  8121. getRestPose(): Matrix;
  8122. /**
  8123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8124. */
  8125. getWorldMatrix(): Matrix;
  8126. /**
  8127. * Sets the local matrix to rest pose matrix
  8128. */
  8129. returnToRest(): void;
  8130. /**
  8131. * Gets the inverse of the absolute transform matrix.
  8132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8133. * @returns a matrix
  8134. */
  8135. getInvertedAbsoluteTransform(): Matrix;
  8136. /**
  8137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8138. * @returns a matrix
  8139. */
  8140. getAbsoluteTransform(): Matrix;
  8141. /**
  8142. * Links with the given transform node.
  8143. * The local matrix of this bone is copied from the transform node every frame.
  8144. * @param transformNode defines the transform node to link to
  8145. */
  8146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8147. /** Gets or sets current position (in local space) */
  8148. position: Vector3;
  8149. /** Gets or sets current rotation (in local space) */
  8150. rotation: Vector3;
  8151. /** Gets or sets current rotation quaternion (in local space) */
  8152. rotationQuaternion: Quaternion;
  8153. /** Gets or sets current scaling (in local space) */
  8154. scaling: Vector3;
  8155. /**
  8156. * Gets the animation properties override
  8157. */
  8158. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8159. private _decompose;
  8160. private _compose;
  8161. /**
  8162. * Update the base and local matrices
  8163. * @param matrix defines the new base or local matrix
  8164. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8165. * @param updateLocalMatrix defines if the local matrix should be updated
  8166. */
  8167. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8168. /** @hidden */
  8169. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8170. /**
  8171. * Flag the bone as dirty (Forcing it to update everything)
  8172. */
  8173. markAsDirty(): void;
  8174. private _markAsDirtyAndCompose;
  8175. private _markAsDirtyAndDecompose;
  8176. /**
  8177. * Translate the bone in local or world space
  8178. * @param vec The amount to translate the bone
  8179. * @param space The space that the translation is in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. */
  8182. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8183. /**
  8184. * Set the postion of the bone in local or world space
  8185. * @param position The position to set the bone
  8186. * @param space The space that the position is in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. */
  8189. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8190. /**
  8191. * Set the absolute position of the bone (world space)
  8192. * @param position The position to set the bone
  8193. * @param mesh The mesh that this bone is attached to
  8194. */
  8195. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8196. /**
  8197. * Scale the bone on the x, y and z axes (in local space)
  8198. * @param x The amount to scale the bone on the x axis
  8199. * @param y The amount to scale the bone on the y axis
  8200. * @param z The amount to scale the bone on the z axis
  8201. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8202. */
  8203. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8204. /**
  8205. * Set the bone scaling in local space
  8206. * @param scale defines the scaling vector
  8207. */
  8208. setScale(scale: Vector3): void;
  8209. /**
  8210. * Gets the current scaling in local space
  8211. * @returns the current scaling vector
  8212. */
  8213. getScale(): Vector3;
  8214. /**
  8215. * Gets the current scaling in local space and stores it in a target vector
  8216. * @param result defines the target vector
  8217. */
  8218. getScaleToRef(result: Vector3): void;
  8219. /**
  8220. * Set the yaw, pitch, and roll of the bone in local or world space
  8221. * @param yaw The rotation of the bone on the y axis
  8222. * @param pitch The rotation of the bone on the x axis
  8223. * @param roll The rotation of the bone on the z axis
  8224. * @param space The space that the axes of rotation are in
  8225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8226. */
  8227. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8228. /**
  8229. * Add a rotation to the bone on an axis in local or world space
  8230. * @param axis The axis to rotate the bone on
  8231. * @param amount The amount to rotate the bone
  8232. * @param space The space that the axis is in
  8233. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8234. */
  8235. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8236. /**
  8237. * Set the rotation of the bone to a particular axis angle in local or world space
  8238. * @param axis The axis to rotate the bone on
  8239. * @param angle The angle that the bone should be rotated to
  8240. * @param space The space that the axis is in
  8241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8242. */
  8243. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8244. /**
  8245. * Set the euler rotation of the bone in local of world space
  8246. * @param rotation The euler rotation that the bone should be set to
  8247. * @param space The space that the rotation is in
  8248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8249. */
  8250. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8251. /**
  8252. * Set the quaternion rotation of the bone in local of world space
  8253. * @param quat The quaternion rotation that the bone should be set to
  8254. * @param space The space that the rotation is in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. */
  8257. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8258. /**
  8259. * Set the rotation matrix of the bone in local of world space
  8260. * @param rotMat The rotation matrix that the bone should be set to
  8261. * @param space The space that the rotation is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8265. private _rotateWithMatrix;
  8266. private _getNegativeRotationToRef;
  8267. /**
  8268. * Get the position of the bone in local or world space
  8269. * @param space The space that the returned position is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. * @returns The position of the bone
  8272. */
  8273. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8274. /**
  8275. * Copy the position of the bone to a vector3 in local or world space
  8276. * @param space The space that the returned position is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. * @param result The vector3 to copy the position to
  8279. */
  8280. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8281. /**
  8282. * Get the absolute position of the bone (world space)
  8283. * @param mesh The mesh that this bone is attached to
  8284. * @returns The absolute position of the bone
  8285. */
  8286. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8287. /**
  8288. * Copy the absolute position of the bone (world space) to the result param
  8289. * @param mesh The mesh that this bone is attached to
  8290. * @param result The vector3 to copy the absolute position to
  8291. */
  8292. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8293. /**
  8294. * Compute the absolute transforms of this bone and its children
  8295. */
  8296. computeAbsoluteTransforms(): void;
  8297. /**
  8298. * Get the world direction from an axis that is in the local space of the bone
  8299. * @param localAxis The local direction that is used to compute the world direction
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world direction
  8302. */
  8303. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8306. * @param localAxis The local direction that is used to compute the world direction
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world direction will be copied to
  8309. */
  8310. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the euler rotation of the bone in local or world space
  8313. * @param space The space that the rotation should be in
  8314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8315. * @returns The euler rotation
  8316. */
  8317. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8320. * @param space The space that the rotation should be in
  8321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8322. * @param result The vector3 that the rotation should be copied to
  8323. */
  8324. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. /**
  8326. * Get the quaternion rotation of the bone in either local or world space
  8327. * @param space The space that the rotation should be in
  8328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8329. * @returns The quaternion rotation
  8330. */
  8331. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8332. /**
  8333. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8334. * @param space The space that the rotation should be in
  8335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8336. * @param result The quaternion that the rotation should be copied to
  8337. */
  8338. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8339. /**
  8340. * Get the rotation matrix of the bone in local or world space
  8341. * @param space The space that the rotation should be in
  8342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8343. * @returns The rotation matrix
  8344. */
  8345. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8346. /**
  8347. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8348. * @param space The space that the rotation should be in
  8349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8350. * @param result The quaternion that the rotation should be copied to
  8351. */
  8352. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8353. /**
  8354. * Get the world position of a point that is in the local space of the bone
  8355. * @param position The local position
  8356. * @param mesh The mesh that this bone is attached to
  8357. * @returns The world position
  8358. */
  8359. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8360. /**
  8361. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8362. * @param position The local position
  8363. * @param mesh The mesh that this bone is attached to
  8364. * @param result The vector3 that the world position should be copied to
  8365. */
  8366. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8367. /**
  8368. * Get the local position of a point that is in world space
  8369. * @param position The world position
  8370. * @param mesh The mesh that this bone is attached to
  8371. * @returns The local position
  8372. */
  8373. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8374. /**
  8375. * Get the local position of a point that is in world space and copy it to the result param
  8376. * @param position The world position
  8377. * @param mesh The mesh that this bone is attached to
  8378. * @param result The vector3 that the local position should be copied to
  8379. */
  8380. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8381. }
  8382. }
  8383. declare module "babylonjs/Misc/iInspectable" {
  8384. /**
  8385. * Enum that determines the text-wrapping mode to use.
  8386. */
  8387. export enum InspectableType {
  8388. /**
  8389. * Checkbox for booleans
  8390. */
  8391. Checkbox = 0,
  8392. /**
  8393. * Sliders for numbers
  8394. */
  8395. Slider = 1,
  8396. /**
  8397. * Vector3
  8398. */
  8399. Vector3 = 2,
  8400. /**
  8401. * Quaternions
  8402. */
  8403. Quaternion = 3,
  8404. /**
  8405. * Color3
  8406. */
  8407. Color3 = 4
  8408. }
  8409. /**
  8410. * Interface used to define custom inspectable properties.
  8411. * This interface is used by the inspector to display custom property grids
  8412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8413. */
  8414. export interface IInspectable {
  8415. /**
  8416. * Gets the label to display
  8417. */
  8418. label: string;
  8419. /**
  8420. * Gets the name of the property to edit
  8421. */
  8422. propertyName: string;
  8423. /**
  8424. * Gets the type of the editor to use
  8425. */
  8426. type: InspectableType;
  8427. /**
  8428. * Gets the minimum value of the property when using in "slider" mode
  8429. */
  8430. min?: number;
  8431. /**
  8432. * Gets the maximum value of the property when using in "slider" mode
  8433. */
  8434. max?: number;
  8435. /**
  8436. * Gets the setp to use when using in "slider" mode
  8437. */
  8438. step?: number;
  8439. }
  8440. }
  8441. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8442. import { Nullable } from "babylonjs/types";
  8443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8444. /**
  8445. * This represents the required contract to create a new type of texture loader.
  8446. */
  8447. export interface IInternalTextureLoader {
  8448. /**
  8449. * Defines wether the loader supports cascade loading the different faces.
  8450. */
  8451. supportCascades: boolean;
  8452. /**
  8453. * This returns if the loader support the current file information.
  8454. * @param extension defines the file extension of the file being loaded
  8455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8456. * @param fallback defines the fallback internal texture if any
  8457. * @param isBase64 defines whether the texture is encoded as a base64
  8458. * @param isBuffer defines whether the texture data are stored as a buffer
  8459. * @returns true if the loader can load the specified file
  8460. */
  8461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8462. /**
  8463. * Transform the url before loading if required.
  8464. * @param rootUrl the url of the texture
  8465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8466. * @returns the transformed texture
  8467. */
  8468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8469. /**
  8470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8471. * @param rootUrl the url of the texture
  8472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8473. * @returns the fallback texture
  8474. */
  8475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8476. /**
  8477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8478. * @param data contains the texture data
  8479. * @param texture defines the BabylonJS internal texture
  8480. * @param createPolynomials will be true if polynomials have been requested
  8481. * @param onLoad defines the callback to trigger once the texture is ready
  8482. * @param onError defines the callback to trigger in case of error
  8483. */
  8484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8485. /**
  8486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8487. * @param data contains the texture data
  8488. * @param texture defines the BabylonJS internal texture
  8489. * @param callback defines the method to call once ready to upload
  8490. */
  8491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8492. }
  8493. }
  8494. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8496. import { Nullable } from "babylonjs/types";
  8497. import { Scene } from "babylonjs/scene";
  8498. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8499. module "babylonjs/Engines/engine" {
  8500. interface Engine {
  8501. /**
  8502. * Creates a depth stencil cube texture.
  8503. * This is only available in WebGL 2.
  8504. * @param size The size of face edge in the cube texture.
  8505. * @param options The options defining the cube texture.
  8506. * @returns The cube texture
  8507. */
  8508. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8509. /**
  8510. * Creates a cube texture
  8511. * @param rootUrl defines the url where the files to load is located
  8512. * @param scene defines the current scene
  8513. * @param files defines the list of files to load (1 per face)
  8514. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8515. * @param onLoad defines an optional callback raised when the texture is loaded
  8516. * @param onError defines an optional callback raised if there is an issue to load the texture
  8517. * @param format defines the format of the data
  8518. * @param forcedExtension defines the extension to use to pick the right loader
  8519. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8522. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8523. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8524. * @returns the cube texture as an InternalTexture
  8525. */
  8526. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8527. /**
  8528. * Creates a cube texture
  8529. * @param rootUrl defines the url where the files to load is located
  8530. * @param scene defines the current scene
  8531. * @param files defines the list of files to load (1 per face)
  8532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8533. * @param onLoad defines an optional callback raised when the texture is loaded
  8534. * @param onError defines an optional callback raised if there is an issue to load the texture
  8535. * @param format defines the format of the data
  8536. * @param forcedExtension defines the extension to use to pick the right loader
  8537. * @returns the cube texture as an InternalTexture
  8538. */
  8539. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8540. /**
  8541. * Creates a cube texture
  8542. * @param rootUrl defines the url where the files to load is located
  8543. * @param scene defines the current scene
  8544. * @param files defines the list of files to load (1 per face)
  8545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8546. * @param onLoad defines an optional callback raised when the texture is loaded
  8547. * @param onError defines an optional callback raised if there is an issue to load the texture
  8548. * @param format defines the format of the data
  8549. * @param forcedExtension defines the extension to use to pick the right loader
  8550. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8556. /** @hidden */
  8557. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8558. /** @hidden */
  8559. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8560. /** @hidden */
  8561. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8562. /** @hidden */
  8563. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8564. }
  8565. }
  8566. }
  8567. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { Scene } from "babylonjs/scene";
  8570. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8572. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8573. /**
  8574. * Class for creating a cube texture
  8575. */
  8576. export class CubeTexture extends BaseTexture {
  8577. private _delayedOnLoad;
  8578. /**
  8579. * The url of the texture
  8580. */
  8581. url: string;
  8582. /**
  8583. * Gets or sets the center of the bounding box associated with the cube texture.
  8584. * It must define where the camera used to render the texture was set
  8585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8586. */
  8587. boundingBoxPosition: Vector3;
  8588. private _boundingBoxSize;
  8589. /**
  8590. * Gets or sets the size of the bounding box associated with the cube texture
  8591. * When defined, the cubemap will switch to local mode
  8592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8593. * @example https://www.babylonjs-playground.com/#RNASML
  8594. */
  8595. /**
  8596. * Returns the bounding box size
  8597. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8598. */
  8599. boundingBoxSize: Vector3;
  8600. protected _rotationY: number;
  8601. /**
  8602. * Sets texture matrix rotation angle around Y axis in radians.
  8603. */
  8604. /**
  8605. * Gets texture matrix rotation angle around Y axis radians.
  8606. */
  8607. rotationY: number;
  8608. /**
  8609. * Are mip maps generated for this texture or not.
  8610. */
  8611. readonly noMipmap: boolean;
  8612. private _noMipmap;
  8613. private _files;
  8614. private _extensions;
  8615. private _textureMatrix;
  8616. private _format;
  8617. private _createPolynomials;
  8618. /** @hidden */
  8619. _prefiltered: boolean;
  8620. /**
  8621. * Creates a cube texture from an array of image urls
  8622. * @param files defines an array of image urls
  8623. * @param scene defines the hosting scene
  8624. * @param noMipmap specifies if mip maps are not used
  8625. * @returns a cube texture
  8626. */
  8627. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8628. /**
  8629. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8630. * @param url defines the url of the prefiltered texture
  8631. * @param scene defines the scene the texture is attached to
  8632. * @param forcedExtension defines the extension of the file if different from the url
  8633. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8634. * @return the prefiltered texture
  8635. */
  8636. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8637. /**
  8638. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8639. * as prefiltered data.
  8640. * @param rootUrl defines the url of the texture or the root name of the six images
  8641. * @param scene defines the scene the texture is attached to
  8642. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8643. * @param noMipmap defines if mipmaps should be created or not
  8644. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8645. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8646. * @param onError defines a callback triggered in case of error during load
  8647. * @param format defines the internal format to use for the texture once loaded
  8648. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8649. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8650. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8651. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8652. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8653. * @return the cube texture
  8654. */
  8655. 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);
  8656. /**
  8657. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8658. */
  8659. readonly isPrefiltered: boolean;
  8660. /**
  8661. * Get the current class name of the texture useful for serialization or dynamic coding.
  8662. * @returns "CubeTexture"
  8663. */
  8664. getClassName(): string;
  8665. /**
  8666. * Update the url (and optional buffer) of this texture if url was null during construction.
  8667. * @param url the url of the texture
  8668. * @param forcedExtension defines the extension to use
  8669. * @param onLoad callback called when the texture is loaded (defaults to null)
  8670. */
  8671. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8672. /**
  8673. * Delays loading of the cube texture
  8674. * @param forcedExtension defines the extension to use
  8675. */
  8676. delayLoad(forcedExtension?: string): void;
  8677. /**
  8678. * Returns the reflection texture matrix
  8679. * @returns the reflection texture matrix
  8680. */
  8681. getReflectionTextureMatrix(): Matrix;
  8682. /**
  8683. * Sets the reflection texture matrix
  8684. * @param value Reflection texture matrix
  8685. */
  8686. setReflectionTextureMatrix(value: Matrix): void;
  8687. /**
  8688. * Parses text to create a cube texture
  8689. * @param parsedTexture define the serialized text to read from
  8690. * @param scene defines the hosting scene
  8691. * @param rootUrl defines the root url of the cube texture
  8692. * @returns a cube texture
  8693. */
  8694. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8695. /**
  8696. * Makes a clone, or deep copy, of the cube texture
  8697. * @returns a new cube texture
  8698. */
  8699. clone(): CubeTexture;
  8700. }
  8701. }
  8702. declare module "babylonjs/Shaders/postprocess.vertex" {
  8703. /** @hidden */
  8704. export var postprocessVertexShader: {
  8705. name: string;
  8706. shader: string;
  8707. };
  8708. }
  8709. declare module "babylonjs/Cameras/targetCamera" {
  8710. import { Nullable } from "babylonjs/types";
  8711. import { Camera } from "babylonjs/Cameras/camera";
  8712. import { Scene } from "babylonjs/scene";
  8713. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8714. /**
  8715. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8716. * This is the base of the follow, arc rotate cameras and Free camera
  8717. * @see http://doc.babylonjs.com/features/cameras
  8718. */
  8719. export class TargetCamera extends Camera {
  8720. private static _RigCamTransformMatrix;
  8721. private static _TargetTransformMatrix;
  8722. private static _TargetFocalPoint;
  8723. /**
  8724. * Define the current direction the camera is moving to
  8725. */
  8726. cameraDirection: Vector3;
  8727. /**
  8728. * Define the current rotation the camera is rotating to
  8729. */
  8730. cameraRotation: Vector2;
  8731. /**
  8732. * When set, the up vector of the camera will be updated by the rotation of the camera
  8733. */
  8734. updateUpVectorFromRotation: boolean;
  8735. private _tmpQuaternion;
  8736. /**
  8737. * Define the current rotation of the camera
  8738. */
  8739. rotation: Vector3;
  8740. /**
  8741. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8742. */
  8743. rotationQuaternion: Quaternion;
  8744. /**
  8745. * Define the current speed of the camera
  8746. */
  8747. speed: number;
  8748. /**
  8749. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8750. * around all axis.
  8751. */
  8752. noRotationConstraint: boolean;
  8753. /**
  8754. * Define the current target of the camera as an object or a position.
  8755. */
  8756. lockedTarget: any;
  8757. /** @hidden */
  8758. _currentTarget: Vector3;
  8759. /** @hidden */
  8760. _initialFocalDistance: number;
  8761. /** @hidden */
  8762. _viewMatrix: Matrix;
  8763. /** @hidden */
  8764. _camMatrix: Matrix;
  8765. /** @hidden */
  8766. _cameraTransformMatrix: Matrix;
  8767. /** @hidden */
  8768. _cameraRotationMatrix: Matrix;
  8769. /** @hidden */
  8770. _referencePoint: Vector3;
  8771. /** @hidden */
  8772. _transformedReferencePoint: Vector3;
  8773. protected _globalCurrentTarget: Vector3;
  8774. protected _globalCurrentUpVector: Vector3;
  8775. /** @hidden */
  8776. _reset: () => void;
  8777. private _defaultUp;
  8778. /**
  8779. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8780. * This is the base of the follow, arc rotate cameras and Free camera
  8781. * @see http://doc.babylonjs.com/features/cameras
  8782. * @param name Defines the name of the camera in the scene
  8783. * @param position Defines the start position of the camera in the scene
  8784. * @param scene Defines the scene the camera belongs to
  8785. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8786. */
  8787. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8788. /**
  8789. * Gets the position in front of the camera at a given distance.
  8790. * @param distance The distance from the camera we want the position to be
  8791. * @returns the position
  8792. */
  8793. getFrontPosition(distance: number): Vector3;
  8794. /** @hidden */
  8795. _getLockedTargetPosition(): Nullable<Vector3>;
  8796. private _storedPosition;
  8797. private _storedRotation;
  8798. private _storedRotationQuaternion;
  8799. /**
  8800. * Store current camera state of the camera (fov, position, rotation, etc..)
  8801. * @returns the camera
  8802. */
  8803. storeState(): Camera;
  8804. /**
  8805. * Restored camera state. You must call storeState() first
  8806. * @returns whether it was successful or not
  8807. * @hidden
  8808. */
  8809. _restoreStateValues(): boolean;
  8810. /** @hidden */
  8811. _initCache(): void;
  8812. /** @hidden */
  8813. _updateCache(ignoreParentClass?: boolean): void;
  8814. /** @hidden */
  8815. _isSynchronizedViewMatrix(): boolean;
  8816. /** @hidden */
  8817. _computeLocalCameraSpeed(): number;
  8818. /**
  8819. * Defines the target the camera should look at.
  8820. * This will automatically adapt alpha beta and radius to fit within the new target.
  8821. * @param target Defines the new target as a Vector or a mesh
  8822. */
  8823. setTarget(target: Vector3): void;
  8824. /**
  8825. * Return the current target position of the camera. This value is expressed in local space.
  8826. * @returns the target position
  8827. */
  8828. getTarget(): Vector3;
  8829. /** @hidden */
  8830. _decideIfNeedsToMove(): boolean;
  8831. /** @hidden */
  8832. _updatePosition(): void;
  8833. /** @hidden */
  8834. _checkInputs(): void;
  8835. protected _updateCameraRotationMatrix(): void;
  8836. /**
  8837. * 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)
  8838. * @returns the current camera
  8839. */
  8840. private _rotateUpVectorWithCameraRotationMatrix;
  8841. private _cachedRotationZ;
  8842. private _cachedQuaternionRotationZ;
  8843. /** @hidden */
  8844. _getViewMatrix(): Matrix;
  8845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8846. /**
  8847. * @hidden
  8848. */
  8849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8850. /**
  8851. * @hidden
  8852. */
  8853. _updateRigCameras(): void;
  8854. private _getRigCamPositionAndTarget;
  8855. /**
  8856. * Gets the current object class name.
  8857. * @return the class name
  8858. */
  8859. getClassName(): string;
  8860. }
  8861. }
  8862. declare module "babylonjs/Cameras/cameraInputsManager" {
  8863. import { Nullable } from "babylonjs/types";
  8864. import { Camera } from "babylonjs/Cameras/camera";
  8865. /**
  8866. * @ignore
  8867. * This is a list of all the different input types that are available in the application.
  8868. * Fo instance: ArcRotateCameraGamepadInput...
  8869. */
  8870. export var CameraInputTypes: {};
  8871. /**
  8872. * This is the contract to implement in order to create a new input class.
  8873. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8874. */
  8875. export interface ICameraInput<TCamera extends Camera> {
  8876. /**
  8877. * Defines the camera the input is attached to.
  8878. */
  8879. camera: Nullable<TCamera>;
  8880. /**
  8881. * Gets the class name of the current intput.
  8882. * @returns the class name
  8883. */
  8884. getClassName(): string;
  8885. /**
  8886. * Get the friendly name associated with the input class.
  8887. * @returns the input friendly name
  8888. */
  8889. getSimpleName(): string;
  8890. /**
  8891. * Attach the input controls to a specific dom element to get the input from.
  8892. * @param element Defines the element the controls should be listened from
  8893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8894. */
  8895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8896. /**
  8897. * Detach the current controls from the specified dom element.
  8898. * @param element Defines the element to stop listening the inputs from
  8899. */
  8900. detachControl(element: Nullable<HTMLElement>): void;
  8901. /**
  8902. * Update the current camera state depending on the inputs that have been used this frame.
  8903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8904. */
  8905. checkInputs?: () => void;
  8906. }
  8907. /**
  8908. * Represents a map of input types to input instance or input index to input instance.
  8909. */
  8910. export interface CameraInputsMap<TCamera extends Camera> {
  8911. /**
  8912. * Accessor to the input by input type.
  8913. */
  8914. [name: string]: ICameraInput<TCamera>;
  8915. /**
  8916. * Accessor to the input by input index.
  8917. */
  8918. [idx: number]: ICameraInput<TCamera>;
  8919. }
  8920. /**
  8921. * This represents the input manager used within a camera.
  8922. * It helps dealing with all the different kind of input attached to a camera.
  8923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8924. */
  8925. export class CameraInputsManager<TCamera extends Camera> {
  8926. /**
  8927. * Defines the list of inputs attahed to the camera.
  8928. */
  8929. attached: CameraInputsMap<TCamera>;
  8930. /**
  8931. * Defines the dom element the camera is collecting inputs from.
  8932. * This is null if the controls have not been attached.
  8933. */
  8934. attachedElement: Nullable<HTMLElement>;
  8935. /**
  8936. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8937. */
  8938. noPreventDefault: boolean;
  8939. /**
  8940. * Defined the camera the input manager belongs to.
  8941. */
  8942. camera: TCamera;
  8943. /**
  8944. * Update the current camera state depending on the inputs that have been used this frame.
  8945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8946. */
  8947. checkInputs: () => void;
  8948. /**
  8949. * Instantiate a new Camera Input Manager.
  8950. * @param camera Defines the camera the input manager blongs to
  8951. */
  8952. constructor(camera: TCamera);
  8953. /**
  8954. * Add an input method to a camera
  8955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8956. * @param input camera input method
  8957. */
  8958. add(input: ICameraInput<TCamera>): void;
  8959. /**
  8960. * Remove a specific input method from a camera
  8961. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8962. * @param inputToRemove camera input method
  8963. */
  8964. remove(inputToRemove: ICameraInput<TCamera>): void;
  8965. /**
  8966. * Remove a specific input type from a camera
  8967. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8968. * @param inputType the type of the input to remove
  8969. */
  8970. removeByType(inputType: string): void;
  8971. private _addCheckInputs;
  8972. /**
  8973. * Attach the input controls to the currently attached dom element to listen the events from.
  8974. * @param input Defines the input to attach
  8975. */
  8976. attachInput(input: ICameraInput<TCamera>): void;
  8977. /**
  8978. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8979. * @param element Defines the dom element to collect the events from
  8980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8981. */
  8982. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8983. /**
  8984. * Detach the current manager inputs controls from a specific dom element.
  8985. * @param element Defines the dom element to collect the events from
  8986. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8987. */
  8988. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8989. /**
  8990. * Rebuild the dynamic inputCheck function from the current list of
  8991. * defined inputs in the manager.
  8992. */
  8993. rebuildInputCheck(): void;
  8994. /**
  8995. * Remove all attached input methods from a camera
  8996. */
  8997. clear(): void;
  8998. /**
  8999. * Serialize the current input manager attached to a camera.
  9000. * This ensures than once parsed,
  9001. * the input associated to the camera will be identical to the current ones
  9002. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9003. */
  9004. serialize(serializedCamera: any): void;
  9005. /**
  9006. * Parses an input manager serialized JSON to restore the previous list of inputs
  9007. * and states associated to a camera.
  9008. * @param parsedCamera Defines the JSON to parse
  9009. */
  9010. parse(parsedCamera: any): void;
  9011. }
  9012. }
  9013. declare module "babylonjs/Events/keyboardEvents" {
  9014. /**
  9015. * Gather the list of keyboard event types as constants.
  9016. */
  9017. export class KeyboardEventTypes {
  9018. /**
  9019. * The keydown event is fired when a key becomes active (pressed).
  9020. */
  9021. static readonly KEYDOWN: number;
  9022. /**
  9023. * The keyup event is fired when a key has been released.
  9024. */
  9025. static readonly KEYUP: number;
  9026. }
  9027. /**
  9028. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9029. */
  9030. export class KeyboardInfo {
  9031. /**
  9032. * Defines the type of event (KeyboardEventTypes)
  9033. */
  9034. type: number;
  9035. /**
  9036. * Defines the related dom event
  9037. */
  9038. event: KeyboardEvent;
  9039. /**
  9040. * Instantiates a new keyboard info.
  9041. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9042. * @param type Defines the type of event (KeyboardEventTypes)
  9043. * @param event Defines the related dom event
  9044. */
  9045. constructor(
  9046. /**
  9047. * Defines the type of event (KeyboardEventTypes)
  9048. */
  9049. type: number,
  9050. /**
  9051. * Defines the related dom event
  9052. */
  9053. event: KeyboardEvent);
  9054. }
  9055. /**
  9056. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9057. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9058. */
  9059. export class KeyboardInfoPre extends KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9070. */
  9071. skipOnPointerObservable: boolean;
  9072. /**
  9073. * Instantiates a new keyboard pre info.
  9074. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9075. * @param type Defines the type of event (KeyboardEventTypes)
  9076. * @param event Defines the related dom event
  9077. */
  9078. constructor(
  9079. /**
  9080. * Defines the type of event (KeyboardEventTypes)
  9081. */
  9082. type: number,
  9083. /**
  9084. * Defines the related dom event
  9085. */
  9086. event: KeyboardEvent);
  9087. }
  9088. }
  9089. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9090. import { Nullable } from "babylonjs/types";
  9091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9093. /**
  9094. * Manage the keyboard inputs to control the movement of a free camera.
  9095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9096. */
  9097. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9098. /**
  9099. * Defines the camera the input is attached to.
  9100. */
  9101. camera: FreeCamera;
  9102. /**
  9103. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9104. */
  9105. keysUp: number[];
  9106. /**
  9107. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9108. */
  9109. keysDown: number[];
  9110. /**
  9111. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9112. */
  9113. keysLeft: number[];
  9114. /**
  9115. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9116. */
  9117. keysRight: number[];
  9118. private _keys;
  9119. private _onCanvasBlurObserver;
  9120. private _onKeyboardObserver;
  9121. private _engine;
  9122. private _scene;
  9123. /**
  9124. * Attach the input controls to a specific dom element to get the input from.
  9125. * @param element Defines the element the controls should be listened from
  9126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9127. */
  9128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9129. /**
  9130. * Detach the current controls from the specified dom element.
  9131. * @param element Defines the element to stop listening the inputs from
  9132. */
  9133. detachControl(element: Nullable<HTMLElement>): void;
  9134. /**
  9135. * Update the current camera state depending on the inputs that have been used this frame.
  9136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9137. */
  9138. checkInputs(): void;
  9139. /**
  9140. * Gets the class name of the current intput.
  9141. * @returns the class name
  9142. */
  9143. getClassName(): string;
  9144. /** @hidden */
  9145. _onLostFocus(): void;
  9146. /**
  9147. * Get the friendly name associated with the input class.
  9148. * @returns the input friendly name
  9149. */
  9150. getSimpleName(): string;
  9151. }
  9152. }
  9153. declare module "babylonjs/Lights/shadowLight" {
  9154. import { Camera } from "babylonjs/Cameras/camera";
  9155. import { Scene } from "babylonjs/scene";
  9156. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9158. import { Light } from "babylonjs/Lights/light";
  9159. /**
  9160. * Interface describing all the common properties and methods a shadow light needs to implement.
  9161. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9162. * as well as binding the different shadow properties to the effects.
  9163. */
  9164. export interface IShadowLight extends Light {
  9165. /**
  9166. * The light id in the scene (used in scene.findLighById for instance)
  9167. */
  9168. id: string;
  9169. /**
  9170. * The position the shdow will be casted from.
  9171. */
  9172. position: Vector3;
  9173. /**
  9174. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9175. */
  9176. direction: Vector3;
  9177. /**
  9178. * The transformed position. Position of the light in world space taking parenting in account.
  9179. */
  9180. transformedPosition: Vector3;
  9181. /**
  9182. * The transformed direction. Direction of the light in world space taking parenting in account.
  9183. */
  9184. transformedDirection: Vector3;
  9185. /**
  9186. * The friendly name of the light in the scene.
  9187. */
  9188. name: string;
  9189. /**
  9190. * Defines the shadow projection clipping minimum z value.
  9191. */
  9192. shadowMinZ: number;
  9193. /**
  9194. * Defines the shadow projection clipping maximum z value.
  9195. */
  9196. shadowMaxZ: number;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Gets the scene the light belongs to.
  9204. * @returns The scene
  9205. */
  9206. getScene(): Scene;
  9207. /**
  9208. * Callback defining a custom Projection Matrix Builder.
  9209. * This can be used to override the default projection matrix computation.
  9210. */
  9211. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9212. /**
  9213. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9214. * @param matrix The materix to updated with the projection information
  9215. * @param viewMatrix The transform matrix of the light
  9216. * @param renderList The list of mesh to render in the map
  9217. * @returns The current light
  9218. */
  9219. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9220. /**
  9221. * Gets the current depth scale used in ESM.
  9222. * @returns The scale
  9223. */
  9224. getDepthScale(): number;
  9225. /**
  9226. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9227. * @returns true if a cube texture needs to be use
  9228. */
  9229. needCube(): boolean;
  9230. /**
  9231. * Detects if the projection matrix requires to be recomputed this frame.
  9232. * @returns true if it requires to be recomputed otherwise, false.
  9233. */
  9234. needProjectionMatrixCompute(): boolean;
  9235. /**
  9236. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9237. */
  9238. forceProjectionMatrixCompute(): void;
  9239. /**
  9240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9243. */
  9244. getShadowDirection(faceIndex?: number): Vector3;
  9245. /**
  9246. * Gets the minZ used for shadow according to both the scene and the light.
  9247. * @param activeCamera The camera we are returning the min for
  9248. * @returns the depth min z
  9249. */
  9250. getDepthMinZ(activeCamera: Camera): number;
  9251. /**
  9252. * Gets the maxZ used for shadow according to both the scene and the light.
  9253. * @param activeCamera The camera we are returning the max for
  9254. * @returns the depth max z
  9255. */
  9256. getDepthMaxZ(activeCamera: Camera): number;
  9257. }
  9258. /**
  9259. * Base implementation IShadowLight
  9260. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9261. */
  9262. export abstract class ShadowLight extends Light implements IShadowLight {
  9263. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9264. protected _position: Vector3;
  9265. protected _setPosition(value: Vector3): void;
  9266. /**
  9267. * Sets the position the shadow will be casted from. Also use as the light position for both
  9268. * point and spot lights.
  9269. */
  9270. /**
  9271. * Sets the position the shadow will be casted from. Also use as the light position for both
  9272. * point and spot lights.
  9273. */
  9274. position: Vector3;
  9275. protected _direction: Vector3;
  9276. protected _setDirection(value: Vector3): void;
  9277. /**
  9278. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9279. * Also use as the light direction on spot and directional lights.
  9280. */
  9281. /**
  9282. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9283. * Also use as the light direction on spot and directional lights.
  9284. */
  9285. direction: Vector3;
  9286. private _shadowMinZ;
  9287. /**
  9288. * Gets the shadow projection clipping minimum z value.
  9289. */
  9290. /**
  9291. * Sets the shadow projection clipping minimum z value.
  9292. */
  9293. shadowMinZ: number;
  9294. private _shadowMaxZ;
  9295. /**
  9296. * Sets the shadow projection clipping maximum z value.
  9297. */
  9298. /**
  9299. * Gets the shadow projection clipping maximum z value.
  9300. */
  9301. shadowMaxZ: number;
  9302. /**
  9303. * Callback defining a custom Projection Matrix Builder.
  9304. * This can be used to override the default projection matrix computation.
  9305. */
  9306. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9307. /**
  9308. * The transformed position. Position of the light in world space taking parenting in account.
  9309. */
  9310. transformedPosition: Vector3;
  9311. /**
  9312. * The transformed direction. Direction of the light in world space taking parenting in account.
  9313. */
  9314. transformedDirection: Vector3;
  9315. private _needProjectionMatrixCompute;
  9316. /**
  9317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9319. */
  9320. computeTransformedInformation(): boolean;
  9321. /**
  9322. * Return the depth scale used for the shadow map.
  9323. * @returns the depth scale.
  9324. */
  9325. getDepthScale(): number;
  9326. /**
  9327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9330. */
  9331. getShadowDirection(faceIndex?: number): Vector3;
  9332. /**
  9333. * Returns the ShadowLight absolute position in the World.
  9334. * @returns the position vector in world space
  9335. */
  9336. getAbsolutePosition(): Vector3;
  9337. /**
  9338. * Sets the ShadowLight direction toward the passed target.
  9339. * @param target The point to target in local space
  9340. * @returns the updated ShadowLight direction
  9341. */
  9342. setDirectionToTarget(target: Vector3): Vector3;
  9343. /**
  9344. * Returns the light rotation in euler definition.
  9345. * @returns the x y z rotation in local space.
  9346. */
  9347. getRotation(): Vector3;
  9348. /**
  9349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9350. * @returns true if a cube texture needs to be use
  9351. */
  9352. needCube(): boolean;
  9353. /**
  9354. * Detects if the projection matrix requires to be recomputed this frame.
  9355. * @returns true if it requires to be recomputed otherwise, false.
  9356. */
  9357. needProjectionMatrixCompute(): boolean;
  9358. /**
  9359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9360. */
  9361. forceProjectionMatrixCompute(): void;
  9362. /** @hidden */
  9363. _initCache(): void;
  9364. /** @hidden */
  9365. _isSynchronized(): boolean;
  9366. /**
  9367. * Computes the world matrix of the node
  9368. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9369. * @returns the world matrix
  9370. */
  9371. computeWorldMatrix(force?: boolean): Matrix;
  9372. /**
  9373. * Gets the minZ used for shadow according to both the scene and the light.
  9374. * @param activeCamera The camera we are returning the min for
  9375. * @returns the depth min z
  9376. */
  9377. getDepthMinZ(activeCamera: Camera): number;
  9378. /**
  9379. * Gets the maxZ used for shadow according to both the scene and the light.
  9380. * @param activeCamera The camera we are returning the max for
  9381. * @returns the depth max z
  9382. */
  9383. getDepthMaxZ(activeCamera: Camera): number;
  9384. /**
  9385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9386. * @param matrix The materix to updated with the projection information
  9387. * @param viewMatrix The transform matrix of the light
  9388. * @param renderList The list of mesh to render in the map
  9389. * @returns The current light
  9390. */
  9391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9392. }
  9393. }
  9394. declare module "babylonjs/Materials/materialHelper" {
  9395. import { Nullable } from "babylonjs/types";
  9396. import { Scene } from "babylonjs/scene";
  9397. import { Engine } from "babylonjs/Engines/engine";
  9398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9399. import { Light } from "babylonjs/Lights/light";
  9400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9401. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9403. /**
  9404. * "Static Class" containing the most commonly used helper while dealing with material for
  9405. * rendering purpose.
  9406. *
  9407. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9408. *
  9409. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9410. */
  9411. export class MaterialHelper {
  9412. /**
  9413. * Bind the current view position to an effect.
  9414. * @param effect The effect to be bound
  9415. * @param scene The scene the eyes position is used from
  9416. */
  9417. static BindEyePosition(effect: Effect, scene: Scene): void;
  9418. /**
  9419. * Helps preparing the defines values about the UVs in used in the effect.
  9420. * UVs are shared as much as we can accross channels in the shaders.
  9421. * @param texture The texture we are preparing the UVs for
  9422. * @param defines The defines to update
  9423. * @param key The channel key "diffuse", "specular"... used in the shader
  9424. */
  9425. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9426. /**
  9427. * Binds a texture matrix value to its corrsponding uniform
  9428. * @param texture The texture to bind the matrix for
  9429. * @param uniformBuffer The uniform buffer receivin the data
  9430. * @param key The channel key "diffuse", "specular"... used in the shader
  9431. */
  9432. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9433. /**
  9434. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9435. * @param mesh defines the current mesh
  9436. * @param scene defines the current scene
  9437. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9438. * @param pointsCloud defines if point cloud rendering has to be turned on
  9439. * @param fogEnabled defines if fog has to be turned on
  9440. * @param alphaTest defines if alpha testing has to be turned on
  9441. * @param defines defines the current list of defines
  9442. */
  9443. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9444. /**
  9445. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9446. * @param scene defines the current scene
  9447. * @param engine defines the current engine
  9448. * @param defines specifies the list of active defines
  9449. * @param useInstances defines if instances have to be turned on
  9450. * @param useClipPlane defines if clip plane have to be turned on
  9451. */
  9452. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9453. /**
  9454. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9455. * @param mesh The mesh containing the geometry data we will draw
  9456. * @param defines The defines to update
  9457. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9458. * @param useBones Precise whether bones should be used or not (override mesh info)
  9459. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9460. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9461. * @returns false if defines are considered not dirty and have not been checked
  9462. */
  9463. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9464. /**
  9465. * Prepares the defines related to multiview
  9466. * @param scene The scene we are intending to draw
  9467. * @param defines The defines to update
  9468. */
  9469. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9470. /**
  9471. * Prepares the defines related to the light information passed in parameter
  9472. * @param scene The scene we are intending to draw
  9473. * @param mesh The mesh the effect is compiling for
  9474. * @param defines The defines to update
  9475. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9476. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9477. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9478. * @returns true if normals will be required for the rest of the effect
  9479. */
  9480. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9481. /**
  9482. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9483. * that won t be acctive due to defines being turned off.
  9484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9485. * @param samplersList The samplers list
  9486. * @param defines The defines helping in the list generation
  9487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9488. */
  9489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9490. /**
  9491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9492. * @param defines The defines to update while falling back
  9493. * @param fallbacks The authorized effect fallbacks
  9494. * @param maxSimultaneousLights The maximum number of lights allowed
  9495. * @param rank the current rank of the Effect
  9496. * @returns The newly affected rank
  9497. */
  9498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9499. /**
  9500. * Prepares the list of attributes required for morph targets according to the effect defines.
  9501. * @param attribs The current list of supported attribs
  9502. * @param mesh The mesh to prepare the morph targets attributes for
  9503. * @param defines The current Defines of the effect
  9504. */
  9505. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9506. /**
  9507. * Prepares the list of attributes required for bones according to the effect defines.
  9508. * @param attribs The current list of supported attribs
  9509. * @param mesh The mesh to prepare the bones attributes for
  9510. * @param defines The current Defines of the effect
  9511. * @param fallbacks The current efffect fallback strategy
  9512. */
  9513. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9514. /**
  9515. * Prepares the list of attributes required for instances according to the effect defines.
  9516. * @param attribs The current list of supported attribs
  9517. * @param defines The current Defines of the effect
  9518. */
  9519. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9520. /**
  9521. * Binds the light shadow information to the effect for the given mesh.
  9522. * @param light The light containing the generator
  9523. * @param scene The scene the lights belongs to
  9524. * @param mesh The mesh we are binding the information to render
  9525. * @param lightIndex The light index in the effect used to render the mesh
  9526. * @param effect The effect we are binding the data to
  9527. */
  9528. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9529. /**
  9530. * Binds the light information to the effect.
  9531. * @param light The light containing the generator
  9532. * @param effect The effect we are binding the data to
  9533. * @param lightIndex The light index in the effect used to render
  9534. */
  9535. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9536. /**
  9537. * Binds the lights information from the scene to the effect for the given mesh.
  9538. * @param scene The scene the lights belongs to
  9539. * @param mesh The mesh we are binding the information to render
  9540. * @param effect The effect we are binding the data to
  9541. * @param defines The generated defines for the effect
  9542. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9543. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9544. */
  9545. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9546. private static _tempFogColor;
  9547. /**
  9548. * Binds the fog information from the scene to the effect for the given mesh.
  9549. * @param scene The scene the lights belongs to
  9550. * @param mesh The mesh we are binding the information to render
  9551. * @param effect The effect we are binding the data to
  9552. * @param linearSpace Defines if the fog effect is applied in linear space
  9553. */
  9554. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9555. /**
  9556. * Binds the bones information from the mesh to the effect.
  9557. * @param mesh The mesh we are binding the information to render
  9558. * @param effect The effect we are binding the data to
  9559. */
  9560. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9561. /**
  9562. * Binds the morph targets information from the mesh to the effect.
  9563. * @param abstractMesh The mesh we are binding the information to render
  9564. * @param effect The effect we are binding the data to
  9565. */
  9566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9567. /**
  9568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9569. * @param defines The generated defines used in the effect
  9570. * @param effect The effect we are binding the data to
  9571. * @param scene The scene we are willing to render with logarithmic scale for
  9572. */
  9573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9574. /**
  9575. * Binds the clip plane information from the scene to the effect.
  9576. * @param scene The scene the clip plane information are extracted from
  9577. * @param effect The effect we are binding the data to
  9578. */
  9579. static BindClipPlane(effect: Effect, scene: Scene): void;
  9580. }
  9581. }
  9582. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9583. /** @hidden */
  9584. export var kernelBlurVaryingDeclaration: {
  9585. name: string;
  9586. shader: string;
  9587. };
  9588. }
  9589. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9590. /** @hidden */
  9591. export var kernelBlurFragment: {
  9592. name: string;
  9593. shader: string;
  9594. };
  9595. }
  9596. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9597. /** @hidden */
  9598. export var kernelBlurFragment2: {
  9599. name: string;
  9600. shader: string;
  9601. };
  9602. }
  9603. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9604. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9605. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9606. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9607. /** @hidden */
  9608. export var kernelBlurPixelShader: {
  9609. name: string;
  9610. shader: string;
  9611. };
  9612. }
  9613. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9614. /** @hidden */
  9615. export var kernelBlurVertex: {
  9616. name: string;
  9617. shader: string;
  9618. };
  9619. }
  9620. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9621. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9622. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9623. /** @hidden */
  9624. export var kernelBlurVertexShader: {
  9625. name: string;
  9626. shader: string;
  9627. };
  9628. }
  9629. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9630. import { Vector2 } from "babylonjs/Maths/math";
  9631. import { Nullable } from "babylonjs/types";
  9632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9633. import { Camera } from "babylonjs/Cameras/camera";
  9634. import { Effect } from "babylonjs/Materials/effect";
  9635. import { Engine } from "babylonjs/Engines/engine";
  9636. import "babylonjs/Shaders/kernelBlur.fragment";
  9637. import "babylonjs/Shaders/kernelBlur.vertex";
  9638. /**
  9639. * The Blur Post Process which blurs an image based on a kernel and direction.
  9640. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9641. */
  9642. export class BlurPostProcess extends PostProcess {
  9643. /** The direction in which to blur the image. */
  9644. direction: Vector2;
  9645. private blockCompilation;
  9646. protected _kernel: number;
  9647. protected _idealKernel: number;
  9648. protected _packedFloat: boolean;
  9649. private _staticDefines;
  9650. /**
  9651. * Sets the length in pixels of the blur sample region
  9652. */
  9653. /**
  9654. * Gets the length in pixels of the blur sample region
  9655. */
  9656. kernel: number;
  9657. /**
  9658. * Sets wether or not the blur needs to unpack/repack floats
  9659. */
  9660. /**
  9661. * Gets wether or not the blur is unpacking/repacking floats
  9662. */
  9663. packedFloat: boolean;
  9664. /**
  9665. * Creates a new instance BlurPostProcess
  9666. * @param name The name of the effect.
  9667. * @param direction The direction in which to blur the image.
  9668. * @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.
  9669. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9670. * @param camera The camera to apply the render pass to.
  9671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9672. * @param engine The engine which the post process will be applied. (default: current engine)
  9673. * @param reusable If the post process can be reused on the same frame. (default: false)
  9674. * @param textureType Type of textures used when performing the post process. (default: 0)
  9675. * @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)
  9676. */
  9677. constructor(name: string,
  9678. /** The direction in which to blur the image. */
  9679. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9680. /**
  9681. * Updates the effect with the current post process compile time values and recompiles the shader.
  9682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9685. * @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
  9686. * @param onCompiled Called when the shader has been compiled.
  9687. * @param onError Called if there is an error when compiling a shader.
  9688. */
  9689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9690. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9691. /**
  9692. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9693. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9694. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9695. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9696. * The gaps between physical kernels are compensated for in the weighting of the samples
  9697. * @param idealKernel Ideal blur kernel.
  9698. * @return Nearest best kernel.
  9699. */
  9700. protected _nearestBestKernel(idealKernel: number): number;
  9701. /**
  9702. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9703. * @param x The point on the Gaussian distribution to sample.
  9704. * @return the value of the Gaussian function at x.
  9705. */
  9706. protected _gaussianWeight(x: number): number;
  9707. /**
  9708. * Generates a string that can be used as a floating point number in GLSL.
  9709. * @param x Value to print.
  9710. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9711. * @return GLSL float string.
  9712. */
  9713. protected _glslFloat(x: number, decimalFigures?: number): string;
  9714. }
  9715. }
  9716. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9717. /** @hidden */
  9718. export var shadowMapPixelShader: {
  9719. name: string;
  9720. shader: string;
  9721. };
  9722. }
  9723. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9724. /** @hidden */
  9725. export var bonesDeclaration: {
  9726. name: string;
  9727. shader: string;
  9728. };
  9729. }
  9730. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9731. /** @hidden */
  9732. export var morphTargetsVertexGlobalDeclaration: {
  9733. name: string;
  9734. shader: string;
  9735. };
  9736. }
  9737. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9738. /** @hidden */
  9739. export var morphTargetsVertexDeclaration: {
  9740. name: string;
  9741. shader: string;
  9742. };
  9743. }
  9744. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9745. /** @hidden */
  9746. export var instancesDeclaration: {
  9747. name: string;
  9748. shader: string;
  9749. };
  9750. }
  9751. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9752. /** @hidden */
  9753. export var helperFunctions: {
  9754. name: string;
  9755. shader: string;
  9756. };
  9757. }
  9758. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9759. /** @hidden */
  9760. export var morphTargetsVertex: {
  9761. name: string;
  9762. shader: string;
  9763. };
  9764. }
  9765. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9766. /** @hidden */
  9767. export var instancesVertex: {
  9768. name: string;
  9769. shader: string;
  9770. };
  9771. }
  9772. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9773. /** @hidden */
  9774. export var bonesVertex: {
  9775. name: string;
  9776. shader: string;
  9777. };
  9778. }
  9779. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9780. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9786. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9787. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9788. /** @hidden */
  9789. export var shadowMapVertexShader: {
  9790. name: string;
  9791. shader: string;
  9792. };
  9793. }
  9794. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9795. /** @hidden */
  9796. export var depthBoxBlurPixelShader: {
  9797. name: string;
  9798. shader: string;
  9799. };
  9800. }
  9801. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9802. import { Nullable } from "babylonjs/types";
  9803. import { Scene } from "babylonjs/scene";
  9804. import { Matrix } from "babylonjs/Maths/math";
  9805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Mesh } from "babylonjs/Meshes/mesh";
  9808. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9809. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9810. import { Effect } from "babylonjs/Materials/effect";
  9811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9812. import "babylonjs/Shaders/shadowMap.fragment";
  9813. import "babylonjs/Shaders/shadowMap.vertex";
  9814. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9815. import { Observable } from "babylonjs/Misc/observable";
  9816. /**
  9817. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9818. */
  9819. export interface ICustomShaderOptions {
  9820. /**
  9821. * Gets or sets the custom shader name to use
  9822. */
  9823. shaderName: string;
  9824. /**
  9825. * The list of attribute names used in the shader
  9826. */
  9827. attributes?: string[];
  9828. /**
  9829. * The list of unifrom names used in the shader
  9830. */
  9831. uniforms?: string[];
  9832. /**
  9833. * The list of sampler names used in the shader
  9834. */
  9835. samplers?: string[];
  9836. /**
  9837. * The list of defines used in the shader
  9838. */
  9839. defines?: string[];
  9840. }
  9841. /**
  9842. * Interface to implement to create a shadow generator compatible with BJS.
  9843. */
  9844. export interface IShadowGenerator {
  9845. /**
  9846. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9847. * @returns The render target texture if present otherwise, null
  9848. */
  9849. getShadowMap(): Nullable<RenderTargetTexture>;
  9850. /**
  9851. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9852. * @returns The render target texture if the shadow map is present otherwise, null
  9853. */
  9854. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9855. /**
  9856. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9857. * @param subMesh The submesh we want to render in the shadow map
  9858. * @param useInstances Defines wether will draw in the map using instances
  9859. * @returns true if ready otherwise, false
  9860. */
  9861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9862. /**
  9863. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9864. * @param defines Defines of the material we want to update
  9865. * @param lightIndex Index of the light in the enabled light list of the material
  9866. */
  9867. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9868. /**
  9869. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9870. * defined in the generator but impacting the effect).
  9871. * It implies the unifroms available on the materials are the standard BJS ones.
  9872. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9873. * @param effect The effect we are binfing the information for
  9874. */
  9875. bindShadowLight(lightIndex: string, effect: Effect): void;
  9876. /**
  9877. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9878. * (eq to shadow prjection matrix * light transform matrix)
  9879. * @returns The transform matrix used to create the shadow map
  9880. */
  9881. getTransformMatrix(): Matrix;
  9882. /**
  9883. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9884. * Cube and 2D textures for instance.
  9885. */
  9886. recreateShadowMap(): void;
  9887. /**
  9888. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9889. * @param onCompiled Callback triggered at the and of the effects compilation
  9890. * @param options Sets of optional options forcing the compilation with different modes
  9891. */
  9892. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9893. useInstances: boolean;
  9894. }>): void;
  9895. /**
  9896. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9897. * @param options Sets of optional options forcing the compilation with different modes
  9898. * @returns A promise that resolves when the compilation completes
  9899. */
  9900. forceCompilationAsync(options?: Partial<{
  9901. useInstances: boolean;
  9902. }>): Promise<void>;
  9903. /**
  9904. * Serializes the shadow generator setup to a json object.
  9905. * @returns The serialized JSON object
  9906. */
  9907. serialize(): any;
  9908. /**
  9909. * Disposes the Shadow map and related Textures and effects.
  9910. */
  9911. dispose(): void;
  9912. }
  9913. /**
  9914. * Default implementation IShadowGenerator.
  9915. * This is the main object responsible of generating shadows in the framework.
  9916. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9917. */
  9918. export class ShadowGenerator implements IShadowGenerator {
  9919. /**
  9920. * Shadow generator mode None: no filtering applied.
  9921. */
  9922. static readonly FILTER_NONE: number;
  9923. /**
  9924. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9926. */
  9927. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9928. /**
  9929. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9930. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9931. */
  9932. static readonly FILTER_POISSONSAMPLING: number;
  9933. /**
  9934. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9935. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9936. */
  9937. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9938. /**
  9939. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9940. * edge artifacts on steep falloff.
  9941. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9942. */
  9943. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9944. /**
  9945. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9946. * edge artifacts on steep falloff.
  9947. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9948. */
  9949. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9950. /**
  9951. * Shadow generator mode PCF: Percentage Closer Filtering
  9952. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9953. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9954. */
  9955. static readonly FILTER_PCF: number;
  9956. /**
  9957. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9958. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9959. * Contact Hardening
  9960. */
  9961. static readonly FILTER_PCSS: number;
  9962. /**
  9963. * Reserved for PCF and PCSS
  9964. * Highest Quality.
  9965. *
  9966. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9967. *
  9968. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9969. */
  9970. static readonly QUALITY_HIGH: number;
  9971. /**
  9972. * Reserved for PCF and PCSS
  9973. * Good tradeoff for quality/perf cross devices
  9974. *
  9975. * Execute PCF on a 3*3 kernel.
  9976. *
  9977. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9978. */
  9979. static readonly QUALITY_MEDIUM: number;
  9980. /**
  9981. * Reserved for PCF and PCSS
  9982. * The lowest quality but the fastest.
  9983. *
  9984. * Execute PCF on a 1*1 kernel.
  9985. *
  9986. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9987. */
  9988. static readonly QUALITY_LOW: number;
  9989. /** Gets or sets the custom shader name to use */
  9990. customShaderOptions: ICustomShaderOptions;
  9991. /**
  9992. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9993. */
  9994. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9995. /**
  9996. * Observable triggered before a mesh is rendered in the shadow map.
  9997. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9998. */
  9999. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10000. private _bias;
  10001. /**
  10002. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10003. */
  10004. /**
  10005. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10006. */
  10007. bias: number;
  10008. private _normalBias;
  10009. /**
  10010. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10011. */
  10012. /**
  10013. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10014. */
  10015. normalBias: number;
  10016. private _blurBoxOffset;
  10017. /**
  10018. * Gets the blur box offset: offset applied during the blur pass.
  10019. * Only useful if useKernelBlur = false
  10020. */
  10021. /**
  10022. * Sets the blur box offset: offset applied during the blur pass.
  10023. * Only useful if useKernelBlur = false
  10024. */
  10025. blurBoxOffset: number;
  10026. private _blurScale;
  10027. /**
  10028. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10029. * 2 means half of the size.
  10030. */
  10031. /**
  10032. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10033. * 2 means half of the size.
  10034. */
  10035. blurScale: number;
  10036. private _blurKernel;
  10037. /**
  10038. * Gets the blur kernel: kernel size of the blur pass.
  10039. * Only useful if useKernelBlur = true
  10040. */
  10041. /**
  10042. * Sets the blur kernel: kernel size of the blur pass.
  10043. * Only useful if useKernelBlur = true
  10044. */
  10045. blurKernel: number;
  10046. private _useKernelBlur;
  10047. /**
  10048. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10049. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10050. */
  10051. /**
  10052. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10053. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10054. */
  10055. useKernelBlur: boolean;
  10056. private _depthScale;
  10057. /**
  10058. * Gets the depth scale used in ESM mode.
  10059. */
  10060. /**
  10061. * Sets the depth scale used in ESM mode.
  10062. * This can override the scale stored on the light.
  10063. */
  10064. depthScale: number;
  10065. private _filter;
  10066. /**
  10067. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10069. */
  10070. /**
  10071. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10072. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10073. */
  10074. filter: number;
  10075. /**
  10076. * Gets if the current filter is set to Poisson Sampling.
  10077. */
  10078. /**
  10079. * Sets the current filter to Poisson Sampling.
  10080. */
  10081. usePoissonSampling: boolean;
  10082. /**
  10083. * Gets if the current filter is set to ESM.
  10084. */
  10085. /**
  10086. * Sets the current filter is to ESM.
  10087. */
  10088. useExponentialShadowMap: boolean;
  10089. /**
  10090. * Gets if the current filter is set to filtered ESM.
  10091. */
  10092. /**
  10093. * Gets if the current filter is set to filtered ESM.
  10094. */
  10095. useBlurExponentialShadowMap: boolean;
  10096. /**
  10097. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10098. * exponential to prevent steep falloff artifacts).
  10099. */
  10100. /**
  10101. * Sets the current filter to "close ESM" (using the inverse of the
  10102. * exponential to prevent steep falloff artifacts).
  10103. */
  10104. useCloseExponentialShadowMap: boolean;
  10105. /**
  10106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10107. * exponential to prevent steep falloff artifacts).
  10108. */
  10109. /**
  10110. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10111. * exponential to prevent steep falloff artifacts).
  10112. */
  10113. useBlurCloseExponentialShadowMap: boolean;
  10114. /**
  10115. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10116. */
  10117. /**
  10118. * Sets the current filter to "PCF" (percentage closer filtering).
  10119. */
  10120. usePercentageCloserFiltering: boolean;
  10121. private _filteringQuality;
  10122. /**
  10123. * Gets the PCF or PCSS Quality.
  10124. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10125. */
  10126. /**
  10127. * Sets the PCF or PCSS Quality.
  10128. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10129. */
  10130. filteringQuality: number;
  10131. /**
  10132. * Gets if the current filter is set to "PCSS" (contact hardening).
  10133. */
  10134. /**
  10135. * Sets the current filter to "PCSS" (contact hardening).
  10136. */
  10137. useContactHardeningShadow: boolean;
  10138. private _contactHardeningLightSizeUVRatio;
  10139. /**
  10140. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10141. * Using a ratio helps keeping shape stability independently of the map size.
  10142. *
  10143. * It does not account for the light projection as it was having too much
  10144. * instability during the light setup or during light position changes.
  10145. *
  10146. * Only valid if useContactHardeningShadow is true.
  10147. */
  10148. /**
  10149. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10150. * Using a ratio helps keeping shape stability independently of the map size.
  10151. *
  10152. * It does not account for the light projection as it was having too much
  10153. * instability during the light setup or during light position changes.
  10154. *
  10155. * Only valid if useContactHardeningShadow is true.
  10156. */
  10157. contactHardeningLightSizeUVRatio: number;
  10158. private _darkness;
  10159. /**
  10160. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10161. * 0 means strongest and 1 would means no shadow.
  10162. * @returns the darkness.
  10163. */
  10164. getDarkness(): number;
  10165. /**
  10166. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10167. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10168. * @returns the shadow generator allowing fluent coding.
  10169. */
  10170. setDarkness(darkness: number): ShadowGenerator;
  10171. private _transparencyShadow;
  10172. /**
  10173. * Sets the ability to have transparent shadow (boolean).
  10174. * @param transparent True if transparent else False
  10175. * @returns the shadow generator allowing fluent coding
  10176. */
  10177. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10178. private _shadowMap;
  10179. private _shadowMap2;
  10180. /**
  10181. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10182. * @returns The render target texture if present otherwise, null
  10183. */
  10184. getShadowMap(): Nullable<RenderTargetTexture>;
  10185. /**
  10186. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10187. * @returns The render target texture if the shadow map is present otherwise, null
  10188. */
  10189. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10190. /**
  10191. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10192. * @param mesh Mesh to add
  10193. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10194. * @returns the Shadow Generator itself
  10195. */
  10196. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10197. /**
  10198. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10199. * @param mesh Mesh to remove
  10200. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10201. * @returns the Shadow Generator itself
  10202. */
  10203. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10204. /**
  10205. * Controls the extent to which the shadows fade out at the edge of the frustum
  10206. * Used only by directionals and spots
  10207. */
  10208. frustumEdgeFalloff: number;
  10209. private _light;
  10210. /**
  10211. * Returns the associated light object.
  10212. * @returns the light generating the shadow
  10213. */
  10214. getLight(): IShadowLight;
  10215. /**
  10216. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10217. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10218. * It might on the other hand introduce peter panning.
  10219. */
  10220. forceBackFacesOnly: boolean;
  10221. private _scene;
  10222. private _lightDirection;
  10223. private _effect;
  10224. private _viewMatrix;
  10225. private _projectionMatrix;
  10226. private _transformMatrix;
  10227. private _cachedPosition;
  10228. private _cachedDirection;
  10229. private _cachedDefines;
  10230. private _currentRenderID;
  10231. private _boxBlurPostprocess;
  10232. private _kernelBlurXPostprocess;
  10233. private _kernelBlurYPostprocess;
  10234. private _blurPostProcesses;
  10235. private _mapSize;
  10236. private _currentFaceIndex;
  10237. private _currentFaceIndexCache;
  10238. private _textureType;
  10239. private _defaultTextureMatrix;
  10240. /** @hidden */
  10241. static _SceneComponentInitialization: (scene: Scene) => void;
  10242. /**
  10243. * Creates a ShadowGenerator object.
  10244. * A ShadowGenerator is the required tool to use the shadows.
  10245. * Each light casting shadows needs to use its own ShadowGenerator.
  10246. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10247. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10248. * @param light The light object generating the shadows.
  10249. * @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.
  10250. */
  10251. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10252. private _initializeGenerator;
  10253. private _initializeShadowMap;
  10254. private _initializeBlurRTTAndPostProcesses;
  10255. private _renderForShadowMap;
  10256. private _renderSubMeshForShadowMap;
  10257. private _applyFilterValues;
  10258. /**
  10259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10260. * @param onCompiled Callback triggered at the and of the effects compilation
  10261. * @param options Sets of optional options forcing the compilation with different modes
  10262. */
  10263. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10264. useInstances: boolean;
  10265. }>): void;
  10266. /**
  10267. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10268. * @param options Sets of optional options forcing the compilation with different modes
  10269. * @returns A promise that resolves when the compilation completes
  10270. */
  10271. forceCompilationAsync(options?: Partial<{
  10272. useInstances: boolean;
  10273. }>): Promise<void>;
  10274. /**
  10275. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10276. * @param subMesh The submesh we want to render in the shadow map
  10277. * @param useInstances Defines wether will draw in the map using instances
  10278. * @returns true if ready otherwise, false
  10279. */
  10280. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10281. /**
  10282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10283. * @param defines Defines of the material we want to update
  10284. * @param lightIndex Index of the light in the enabled light list of the material
  10285. */
  10286. prepareDefines(defines: any, lightIndex: number): void;
  10287. /**
  10288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10289. * defined in the generator but impacting the effect).
  10290. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10291. * @param effect The effect we are binfing the information for
  10292. */
  10293. bindShadowLight(lightIndex: string, effect: Effect): void;
  10294. /**
  10295. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10296. * (eq to shadow prjection matrix * light transform matrix)
  10297. * @returns The transform matrix used to create the shadow map
  10298. */
  10299. getTransformMatrix(): Matrix;
  10300. /**
  10301. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10302. * Cube and 2D textures for instance.
  10303. */
  10304. recreateShadowMap(): void;
  10305. private _disposeBlurPostProcesses;
  10306. private _disposeRTTandPostProcesses;
  10307. /**
  10308. * Disposes the ShadowGenerator.
  10309. * Returns nothing.
  10310. */
  10311. dispose(): void;
  10312. /**
  10313. * Serializes the shadow generator setup to a json object.
  10314. * @returns The serialized JSON object
  10315. */
  10316. serialize(): any;
  10317. /**
  10318. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10319. * @param parsedShadowGenerator The JSON object to parse
  10320. * @param scene The scene to create the shadow map for
  10321. * @returns The parsed shadow generator
  10322. */
  10323. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10324. }
  10325. }
  10326. declare module "babylonjs/Lights/light" {
  10327. import { Nullable } from "babylonjs/types";
  10328. import { Scene } from "babylonjs/scene";
  10329. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10330. import { Node } from "babylonjs/node";
  10331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10332. import { Effect } from "babylonjs/Materials/effect";
  10333. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10334. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10335. /**
  10336. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10337. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10338. * 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.
  10339. */
  10340. export abstract class Light extends Node {
  10341. /**
  10342. * Falloff Default: light is falling off following the material specification:
  10343. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10344. */
  10345. static readonly FALLOFF_DEFAULT: number;
  10346. /**
  10347. * Falloff Physical: light is falling off following the inverse squared distance law.
  10348. */
  10349. static readonly FALLOFF_PHYSICAL: number;
  10350. /**
  10351. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10352. * to enhance interoperability with other engines.
  10353. */
  10354. static readonly FALLOFF_GLTF: number;
  10355. /**
  10356. * Falloff Standard: light is falling off like in the standard material
  10357. * to enhance interoperability with other materials.
  10358. */
  10359. static readonly FALLOFF_STANDARD: number;
  10360. /**
  10361. * If every light affecting the material is in this lightmapMode,
  10362. * material.lightmapTexture adds or multiplies
  10363. * (depends on material.useLightmapAsShadowmap)
  10364. * after every other light calculations.
  10365. */
  10366. static readonly LIGHTMAP_DEFAULT: number;
  10367. /**
  10368. * material.lightmapTexture as only diffuse lighting from this light
  10369. * adds only specular lighting from this light
  10370. * adds dynamic shadows
  10371. */
  10372. static readonly LIGHTMAP_SPECULAR: number;
  10373. /**
  10374. * material.lightmapTexture as only lighting
  10375. * no light calculation from this light
  10376. * only adds dynamic shadows from this light
  10377. */
  10378. static readonly LIGHTMAP_SHADOWSONLY: number;
  10379. /**
  10380. * Each light type uses the default quantity according to its type:
  10381. * point/spot lights use luminous intensity
  10382. * directional lights use illuminance
  10383. */
  10384. static readonly INTENSITYMODE_AUTOMATIC: number;
  10385. /**
  10386. * lumen (lm)
  10387. */
  10388. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10389. /**
  10390. * candela (lm/sr)
  10391. */
  10392. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10393. /**
  10394. * lux (lm/m^2)
  10395. */
  10396. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10397. /**
  10398. * nit (cd/m^2)
  10399. */
  10400. static readonly INTENSITYMODE_LUMINANCE: number;
  10401. /**
  10402. * Light type const id of the point light.
  10403. */
  10404. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10405. /**
  10406. * Light type const id of the directional light.
  10407. */
  10408. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10409. /**
  10410. * Light type const id of the spot light.
  10411. */
  10412. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10413. /**
  10414. * Light type const id of the hemispheric light.
  10415. */
  10416. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10417. /**
  10418. * Diffuse gives the basic color to an object.
  10419. */
  10420. diffuse: Color3;
  10421. /**
  10422. * Specular produces a highlight color on an object.
  10423. * Note: This is note affecting PBR materials.
  10424. */
  10425. specular: Color3;
  10426. /**
  10427. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10428. * falling off base on range or angle.
  10429. * This can be set to any values in Light.FALLOFF_x.
  10430. *
  10431. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10432. * other types of materials.
  10433. */
  10434. falloffType: number;
  10435. /**
  10436. * Strength of the light.
  10437. * Note: By default it is define in the framework own unit.
  10438. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10439. */
  10440. intensity: number;
  10441. private _range;
  10442. protected _inverseSquaredRange: number;
  10443. /**
  10444. * Defines how far from the source the light is impacting in scene units.
  10445. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10446. */
  10447. /**
  10448. * Defines how far from the source the light is impacting in scene units.
  10449. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10450. */
  10451. range: number;
  10452. /**
  10453. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10454. * of light.
  10455. */
  10456. private _photometricScale;
  10457. private _intensityMode;
  10458. /**
  10459. * Gets the photometric scale used to interpret the intensity.
  10460. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10461. */
  10462. /**
  10463. * Sets the photometric scale used to interpret the intensity.
  10464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10465. */
  10466. intensityMode: number;
  10467. private _radius;
  10468. /**
  10469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10470. */
  10471. /**
  10472. * sets the light radius used by PBR Materials to simulate soft area lights.
  10473. */
  10474. radius: number;
  10475. private _renderPriority;
  10476. /**
  10477. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10478. * exceeding the number allowed of the materials.
  10479. */
  10480. renderPriority: number;
  10481. private _shadowEnabled;
  10482. /**
  10483. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10484. * the current shadow generator.
  10485. */
  10486. /**
  10487. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10488. * the current shadow generator.
  10489. */
  10490. shadowEnabled: boolean;
  10491. private _includedOnlyMeshes;
  10492. /**
  10493. * Gets the only meshes impacted by this light.
  10494. */
  10495. /**
  10496. * Sets the only meshes impacted by this light.
  10497. */
  10498. includedOnlyMeshes: AbstractMesh[];
  10499. private _excludedMeshes;
  10500. /**
  10501. * Gets the meshes not impacted by this light.
  10502. */
  10503. /**
  10504. * Sets the meshes not impacted by this light.
  10505. */
  10506. excludedMeshes: AbstractMesh[];
  10507. private _excludeWithLayerMask;
  10508. /**
  10509. * Gets the layer id use to find what meshes are not impacted by the light.
  10510. * Inactive if 0
  10511. */
  10512. /**
  10513. * Sets the layer id use to find what meshes are not impacted by the light.
  10514. * Inactive if 0
  10515. */
  10516. excludeWithLayerMask: number;
  10517. private _includeOnlyWithLayerMask;
  10518. /**
  10519. * Gets the layer id use to find what meshes are impacted by the light.
  10520. * Inactive if 0
  10521. */
  10522. /**
  10523. * Sets the layer id use to find what meshes are impacted by the light.
  10524. * Inactive if 0
  10525. */
  10526. includeOnlyWithLayerMask: number;
  10527. private _lightmapMode;
  10528. /**
  10529. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10530. */
  10531. /**
  10532. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10533. */
  10534. lightmapMode: number;
  10535. /**
  10536. * Shadow generator associted to the light.
  10537. * @hidden Internal use only.
  10538. */
  10539. _shadowGenerator: Nullable<IShadowGenerator>;
  10540. /**
  10541. * @hidden Internal use only.
  10542. */
  10543. _excludedMeshesIds: string[];
  10544. /**
  10545. * @hidden Internal use only.
  10546. */
  10547. _includedOnlyMeshesIds: string[];
  10548. /**
  10549. * The current light unifom buffer.
  10550. * @hidden Internal use only.
  10551. */
  10552. _uniformBuffer: UniformBuffer;
  10553. /**
  10554. * Creates a Light object in the scene.
  10555. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10556. * @param name The firendly name of the light
  10557. * @param scene The scene the light belongs too
  10558. */
  10559. constructor(name: string, scene: Scene);
  10560. protected abstract _buildUniformLayout(): void;
  10561. /**
  10562. * Sets the passed Effect "effect" with the Light information.
  10563. * @param effect The effect to update
  10564. * @param lightIndex The index of the light in the effect to update
  10565. * @returns The light
  10566. */
  10567. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10568. /**
  10569. * Returns the string "Light".
  10570. * @returns the class name
  10571. */
  10572. getClassName(): string;
  10573. /** @hidden */
  10574. readonly _isLight: boolean;
  10575. /**
  10576. * Converts the light information to a readable string for debug purpose.
  10577. * @param fullDetails Supports for multiple levels of logging within scene loading
  10578. * @returns the human readable light info
  10579. */
  10580. toString(fullDetails?: boolean): string;
  10581. /** @hidden */
  10582. protected _syncParentEnabledState(): void;
  10583. /**
  10584. * Set the enabled state of this node.
  10585. * @param value - the new enabled state
  10586. */
  10587. setEnabled(value: boolean): void;
  10588. /**
  10589. * Returns the Light associated shadow generator if any.
  10590. * @return the associated shadow generator.
  10591. */
  10592. getShadowGenerator(): Nullable<IShadowGenerator>;
  10593. /**
  10594. * Returns a Vector3, the absolute light position in the World.
  10595. * @returns the world space position of the light
  10596. */
  10597. getAbsolutePosition(): Vector3;
  10598. /**
  10599. * Specifies if the light will affect the passed mesh.
  10600. * @param mesh The mesh to test against the light
  10601. * @return true the mesh is affected otherwise, false.
  10602. */
  10603. canAffectMesh(mesh: AbstractMesh): boolean;
  10604. /**
  10605. * Sort function to order lights for rendering.
  10606. * @param a First Light object to compare to second.
  10607. * @param b Second Light object to compare first.
  10608. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10609. */
  10610. static CompareLightsPriority(a: Light, b: Light): number;
  10611. /**
  10612. * Releases resources associated with this node.
  10613. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10614. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10615. */
  10616. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10617. /**
  10618. * Returns the light type ID (integer).
  10619. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10620. */
  10621. getTypeID(): number;
  10622. /**
  10623. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10624. * @returns the scaled intensity in intensity mode unit
  10625. */
  10626. getScaledIntensity(): number;
  10627. /**
  10628. * Returns a new Light object, named "name", from the current one.
  10629. * @param name The name of the cloned light
  10630. * @returns the new created light
  10631. */
  10632. clone(name: string): Nullable<Light>;
  10633. /**
  10634. * Serializes the current light into a Serialization object.
  10635. * @returns the serialized object.
  10636. */
  10637. serialize(): any;
  10638. /**
  10639. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10640. * This new light is named "name" and added to the passed scene.
  10641. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10642. * @param name The friendly name of the light
  10643. * @param scene The scene the new light will belong to
  10644. * @returns the constructor function
  10645. */
  10646. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10647. /**
  10648. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10649. * @param parsedLight The JSON representation of the light
  10650. * @param scene The scene to create the parsed light in
  10651. * @returns the created light after parsing
  10652. */
  10653. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10654. private _hookArrayForExcluded;
  10655. private _hookArrayForIncludedOnly;
  10656. private _resyncMeshes;
  10657. /**
  10658. * Forces the meshes to update their light related information in their rendering used effects
  10659. * @hidden Internal Use Only
  10660. */
  10661. _markMeshesAsLightDirty(): void;
  10662. /**
  10663. * Recomputes the cached photometric scale if needed.
  10664. */
  10665. private _computePhotometricScale;
  10666. /**
  10667. * Returns the Photometric Scale according to the light type and intensity mode.
  10668. */
  10669. private _getPhotometricScale;
  10670. /**
  10671. * Reorder the light in the scene according to their defined priority.
  10672. * @hidden Internal Use Only
  10673. */
  10674. _reorderLightsInScene(): void;
  10675. /**
  10676. * Prepares the list of defines specific to the light type.
  10677. * @param defines the list of defines
  10678. * @param lightIndex defines the index of the light for the effect
  10679. */
  10680. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10681. }
  10682. }
  10683. declare module "babylonjs/Actions/action" {
  10684. import { Observable } from "babylonjs/Misc/observable";
  10685. import { Condition } from "babylonjs/Actions/condition";
  10686. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10687. import { ActionManager } from "babylonjs/Actions/actionManager";
  10688. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10689. /**
  10690. * Interface used to define Action
  10691. */
  10692. export interface IAction {
  10693. /**
  10694. * Trigger for the action
  10695. */
  10696. trigger: number;
  10697. /** Options of the trigger */
  10698. triggerOptions: any;
  10699. /**
  10700. * Gets the trigger parameters
  10701. * @returns the trigger parameters
  10702. */
  10703. getTriggerParameter(): any;
  10704. /**
  10705. * Internal only - executes current action event
  10706. * @hidden
  10707. */
  10708. _executeCurrent(evt?: ActionEvent): void;
  10709. /**
  10710. * Serialize placeholder for child classes
  10711. * @param parent of child
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. /**
  10716. * Internal only
  10717. * @hidden
  10718. */
  10719. _prepare(): void;
  10720. /**
  10721. * Internal only - manager for action
  10722. * @hidden
  10723. */
  10724. _actionManager: AbstractActionManager;
  10725. }
  10726. /**
  10727. * The action to be carried out following a trigger
  10728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10729. */
  10730. export class Action implements IAction {
  10731. /** the trigger, with or without parameters, for the action */
  10732. triggerOptions: any;
  10733. /**
  10734. * Trigger for the action
  10735. */
  10736. trigger: number;
  10737. /**
  10738. * Internal only - manager for action
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. private _nextActiveAction;
  10743. private _child;
  10744. private _condition?;
  10745. private _triggerParameter;
  10746. /**
  10747. * An event triggered prior to action being executed.
  10748. */
  10749. onBeforeExecuteObservable: Observable<Action>;
  10750. /**
  10751. * Creates a new Action
  10752. * @param triggerOptions the trigger, with or without parameters, for the action
  10753. * @param condition an optional determinant of action
  10754. */
  10755. constructor(
  10756. /** the trigger, with or without parameters, for the action */
  10757. triggerOptions: any, condition?: Condition);
  10758. /**
  10759. * Internal only
  10760. * @hidden
  10761. */
  10762. _prepare(): void;
  10763. /**
  10764. * Gets the trigger parameters
  10765. * @returns the trigger parameters
  10766. */
  10767. getTriggerParameter(): any;
  10768. /**
  10769. * Internal only - executes current action event
  10770. * @hidden
  10771. */
  10772. _executeCurrent(evt?: ActionEvent): void;
  10773. /**
  10774. * Execute placeholder for child classes
  10775. * @param evt optional action event
  10776. */
  10777. execute(evt?: ActionEvent): void;
  10778. /**
  10779. * Skips to next active action
  10780. */
  10781. skipToNextActiveAction(): void;
  10782. /**
  10783. * Adds action to chain of actions, may be a DoNothingAction
  10784. * @param action defines the next action to execute
  10785. * @returns The action passed in
  10786. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10787. */
  10788. then(action: Action): Action;
  10789. /**
  10790. * Internal only
  10791. * @hidden
  10792. */
  10793. _getProperty(propertyPath: string): string;
  10794. /**
  10795. * Internal only
  10796. * @hidden
  10797. */
  10798. _getEffectiveTarget(target: any, propertyPath: string): any;
  10799. /**
  10800. * Serialize placeholder for child classes
  10801. * @param parent of child
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. /**
  10806. * Internal only called by serialize
  10807. * @hidden
  10808. */
  10809. protected _serialize(serializedAction: any, parent?: any): any;
  10810. /**
  10811. * Internal only
  10812. * @hidden
  10813. */
  10814. static _SerializeValueAsString: (value: any) => string;
  10815. /**
  10816. * Internal only
  10817. * @hidden
  10818. */
  10819. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10820. name: string;
  10821. targetType: string;
  10822. value: string;
  10823. };
  10824. }
  10825. }
  10826. declare module "babylonjs/Actions/condition" {
  10827. import { ActionManager } from "babylonjs/Actions/actionManager";
  10828. /**
  10829. * A Condition applied to an Action
  10830. */
  10831. export class Condition {
  10832. /**
  10833. * Internal only - manager for action
  10834. * @hidden
  10835. */
  10836. _actionManager: ActionManager;
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _evaluationId: number;
  10842. /**
  10843. * Internal only
  10844. * @hidden
  10845. */
  10846. _currentResult: boolean;
  10847. /**
  10848. * Creates a new Condition
  10849. * @param actionManager the manager of the action the condition is applied to
  10850. */
  10851. constructor(actionManager: ActionManager);
  10852. /**
  10853. * Check if the current condition is valid
  10854. * @returns a boolean
  10855. */
  10856. isValid(): boolean;
  10857. /**
  10858. * Internal only
  10859. * @hidden
  10860. */
  10861. _getProperty(propertyPath: string): string;
  10862. /**
  10863. * Internal only
  10864. * @hidden
  10865. */
  10866. _getEffectiveTarget(target: any, propertyPath: string): any;
  10867. /**
  10868. * Serialize placeholder for child classes
  10869. * @returns the serialized object
  10870. */
  10871. serialize(): any;
  10872. /**
  10873. * Internal only
  10874. * @hidden
  10875. */
  10876. protected _serialize(serializedCondition: any): any;
  10877. }
  10878. /**
  10879. * Defines specific conditional operators as extensions of Condition
  10880. */
  10881. export class ValueCondition extends Condition {
  10882. /** path to specify the property of the target the conditional operator uses */
  10883. propertyPath: string;
  10884. /** the value compared by the conditional operator against the current value of the property */
  10885. value: any;
  10886. /** the conditional operator, default ValueCondition.IsEqual */
  10887. operator: number;
  10888. /**
  10889. * Internal only
  10890. * @hidden
  10891. */
  10892. private static _IsEqual;
  10893. /**
  10894. * Internal only
  10895. * @hidden
  10896. */
  10897. private static _IsDifferent;
  10898. /**
  10899. * Internal only
  10900. * @hidden
  10901. */
  10902. private static _IsGreater;
  10903. /**
  10904. * Internal only
  10905. * @hidden
  10906. */
  10907. private static _IsLesser;
  10908. /**
  10909. * returns the number for IsEqual
  10910. */
  10911. static readonly IsEqual: number;
  10912. /**
  10913. * Returns the number for IsDifferent
  10914. */
  10915. static readonly IsDifferent: number;
  10916. /**
  10917. * Returns the number for IsGreater
  10918. */
  10919. static readonly IsGreater: number;
  10920. /**
  10921. * Returns the number for IsLesser
  10922. */
  10923. static readonly IsLesser: number;
  10924. /**
  10925. * Internal only The action manager for the condition
  10926. * @hidden
  10927. */
  10928. _actionManager: ActionManager;
  10929. /**
  10930. * Internal only
  10931. * @hidden
  10932. */
  10933. private _target;
  10934. /**
  10935. * Internal only
  10936. * @hidden
  10937. */
  10938. private _effectiveTarget;
  10939. /**
  10940. * Internal only
  10941. * @hidden
  10942. */
  10943. private _property;
  10944. /**
  10945. * Creates a new ValueCondition
  10946. * @param actionManager manager for the action the condition applies to
  10947. * @param target for the action
  10948. * @param propertyPath path to specify the property of the target the conditional operator uses
  10949. * @param value the value compared by the conditional operator against the current value of the property
  10950. * @param operator the conditional operator, default ValueCondition.IsEqual
  10951. */
  10952. constructor(actionManager: ActionManager, target: any,
  10953. /** path to specify the property of the target the conditional operator uses */
  10954. propertyPath: string,
  10955. /** the value compared by the conditional operator against the current value of the property */
  10956. value: any,
  10957. /** the conditional operator, default ValueCondition.IsEqual */
  10958. operator?: number);
  10959. /**
  10960. * Compares the given value with the property value for the specified conditional operator
  10961. * @returns the result of the comparison
  10962. */
  10963. isValid(): boolean;
  10964. /**
  10965. * Serialize the ValueCondition into a JSON compatible object
  10966. * @returns serialization object
  10967. */
  10968. serialize(): any;
  10969. /**
  10970. * Gets the name of the conditional operator for the ValueCondition
  10971. * @param operator the conditional operator
  10972. * @returns the name
  10973. */
  10974. static GetOperatorName(operator: number): string;
  10975. }
  10976. /**
  10977. * Defines a predicate condition as an extension of Condition
  10978. */
  10979. export class PredicateCondition extends Condition {
  10980. /** defines the predicate function used to validate the condition */
  10981. predicate: () => boolean;
  10982. /**
  10983. * Internal only - manager for action
  10984. * @hidden
  10985. */
  10986. _actionManager: ActionManager;
  10987. /**
  10988. * Creates a new PredicateCondition
  10989. * @param actionManager manager for the action the condition applies to
  10990. * @param predicate defines the predicate function used to validate the condition
  10991. */
  10992. constructor(actionManager: ActionManager,
  10993. /** defines the predicate function used to validate the condition */
  10994. predicate: () => boolean);
  10995. /**
  10996. * @returns the validity of the predicate condition
  10997. */
  10998. isValid(): boolean;
  10999. }
  11000. /**
  11001. * Defines a state condition as an extension of Condition
  11002. */
  11003. export class StateCondition extends Condition {
  11004. /** Value to compare with target state */
  11005. value: string;
  11006. /**
  11007. * Internal only - manager for action
  11008. * @hidden
  11009. */
  11010. _actionManager: ActionManager;
  11011. /**
  11012. * Internal only
  11013. * @hidden
  11014. */
  11015. private _target;
  11016. /**
  11017. * Creates a new StateCondition
  11018. * @param actionManager manager for the action the condition applies to
  11019. * @param target of the condition
  11020. * @param value to compare with target state
  11021. */
  11022. constructor(actionManager: ActionManager, target: any,
  11023. /** Value to compare with target state */
  11024. value: string);
  11025. /**
  11026. * Gets a boolean indicating if the current condition is met
  11027. * @returns the validity of the state
  11028. */
  11029. isValid(): boolean;
  11030. /**
  11031. * Serialize the StateCondition into a JSON compatible object
  11032. * @returns serialization object
  11033. */
  11034. serialize(): any;
  11035. }
  11036. }
  11037. declare module "babylonjs/Actions/directActions" {
  11038. import { Action } from "babylonjs/Actions/action";
  11039. import { Condition } from "babylonjs/Actions/condition";
  11040. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11041. /**
  11042. * This defines an action responsible to toggle a boolean once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class SwitchBooleanAction extends Action {
  11046. /**
  11047. * The path to the boolean property in the target object
  11048. */
  11049. propertyPath: string;
  11050. private _target;
  11051. private _effectiveTarget;
  11052. private _property;
  11053. /**
  11054. * Instantiate the action
  11055. * @param triggerOptions defines the trigger options
  11056. * @param target defines the object containing the boolean
  11057. * @param propertyPath defines the path to the boolean property in the target object
  11058. * @param condition defines the trigger related conditions
  11059. */
  11060. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11061. /** @hidden */
  11062. _prepare(): void;
  11063. /**
  11064. * Execute the action toggle the boolean value.
  11065. */
  11066. execute(): void;
  11067. /**
  11068. * Serializes the actions and its related information.
  11069. * @param parent defines the object to serialize in
  11070. * @returns the serialized object
  11071. */
  11072. serialize(parent: any): any;
  11073. }
  11074. /**
  11075. * This defines an action responsible to set a the state field of the target
  11076. * to a desired value once triggered.
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11078. */
  11079. export class SetStateAction extends Action {
  11080. /**
  11081. * The value to store in the state field.
  11082. */
  11083. value: string;
  11084. private _target;
  11085. /**
  11086. * Instantiate the action
  11087. * @param triggerOptions defines the trigger options
  11088. * @param target defines the object containing the state property
  11089. * @param value defines the value to store in the state field
  11090. * @param condition defines the trigger related conditions
  11091. */
  11092. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11093. /**
  11094. * Execute the action and store the value on the target state property.
  11095. */
  11096. execute(): void;
  11097. /**
  11098. * Serializes the actions and its related information.
  11099. * @param parent defines the object to serialize in
  11100. * @returns the serialized object
  11101. */
  11102. serialize(parent: any): any;
  11103. }
  11104. /**
  11105. * This defines an action responsible to set a property of the target
  11106. * to a desired value once triggered.
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11108. */
  11109. export class SetValueAction extends Action {
  11110. /**
  11111. * The path of the property to set in the target.
  11112. */
  11113. propertyPath: string;
  11114. /**
  11115. * The value to set in the property
  11116. */
  11117. value: any;
  11118. private _target;
  11119. private _effectiveTarget;
  11120. private _property;
  11121. /**
  11122. * Instantiate the action
  11123. * @param triggerOptions defines the trigger options
  11124. * @param target defines the object containing the property
  11125. * @param propertyPath defines the path of the property to set in the target
  11126. * @param value defines the value to set in the property
  11127. * @param condition defines the trigger related conditions
  11128. */
  11129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11130. /** @hidden */
  11131. _prepare(): void;
  11132. /**
  11133. * Execute the action and set the targetted property to the desired value.
  11134. */
  11135. execute(): void;
  11136. /**
  11137. * Serializes the actions and its related information.
  11138. * @param parent defines the object to serialize in
  11139. * @returns the serialized object
  11140. */
  11141. serialize(parent: any): any;
  11142. }
  11143. /**
  11144. * This defines an action responsible to increment the target value
  11145. * to a desired value once triggered.
  11146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11147. */
  11148. export class IncrementValueAction extends Action {
  11149. /**
  11150. * The path of the property to increment in the target.
  11151. */
  11152. propertyPath: string;
  11153. /**
  11154. * The value we should increment the property by.
  11155. */
  11156. value: any;
  11157. private _target;
  11158. private _effectiveTarget;
  11159. private _property;
  11160. /**
  11161. * Instantiate the action
  11162. * @param triggerOptions defines the trigger options
  11163. * @param target defines the object containing the property
  11164. * @param propertyPath defines the path of the property to increment in the target
  11165. * @param value defines the value value we should increment the property by
  11166. * @param condition defines the trigger related conditions
  11167. */
  11168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11169. /** @hidden */
  11170. _prepare(): void;
  11171. /**
  11172. * Execute the action and increment the target of the value amount.
  11173. */
  11174. execute(): void;
  11175. /**
  11176. * Serializes the actions and its related information.
  11177. * @param parent defines the object to serialize in
  11178. * @returns the serialized object
  11179. */
  11180. serialize(parent: any): any;
  11181. }
  11182. /**
  11183. * This defines an action responsible to start an animation once triggered.
  11184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11185. */
  11186. export class PlayAnimationAction extends Action {
  11187. /**
  11188. * Where the animation should start (animation frame)
  11189. */
  11190. from: number;
  11191. /**
  11192. * Where the animation should stop (animation frame)
  11193. */
  11194. to: number;
  11195. /**
  11196. * Define if the animation should loop or stop after the first play.
  11197. */
  11198. loop?: boolean;
  11199. private _target;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the target animation or animation name
  11204. * @param from defines from where the animation should start (animation frame)
  11205. * @param end defines where the animation should stop (animation frame)
  11206. * @param loop defines if the animation should loop or stop after the first play
  11207. * @param condition defines the trigger related conditions
  11208. */
  11209. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11210. /** @hidden */
  11211. _prepare(): void;
  11212. /**
  11213. * Execute the action and play the animation.
  11214. */
  11215. execute(): void;
  11216. /**
  11217. * Serializes the actions and its related information.
  11218. * @param parent defines the object to serialize in
  11219. * @returns the serialized object
  11220. */
  11221. serialize(parent: any): any;
  11222. }
  11223. /**
  11224. * This defines an action responsible to stop an animation once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class StopAnimationAction extends Action {
  11228. private _target;
  11229. /**
  11230. * Instantiate the action
  11231. * @param triggerOptions defines the trigger options
  11232. * @param target defines the target animation or animation name
  11233. * @param condition defines the trigger related conditions
  11234. */
  11235. constructor(triggerOptions: any, target: any, condition?: Condition);
  11236. /** @hidden */
  11237. _prepare(): void;
  11238. /**
  11239. * Execute the action and stop the animation.
  11240. */
  11241. execute(): void;
  11242. /**
  11243. * Serializes the actions and its related information.
  11244. * @param parent defines the object to serialize in
  11245. * @returns the serialized object
  11246. */
  11247. serialize(parent: any): any;
  11248. }
  11249. /**
  11250. * This defines an action responsible that does nothing once triggered.
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11252. */
  11253. export class DoNothingAction extends Action {
  11254. /**
  11255. * Instantiate the action
  11256. * @param triggerOptions defines the trigger options
  11257. * @param condition defines the trigger related conditions
  11258. */
  11259. constructor(triggerOptions?: any, condition?: Condition);
  11260. /**
  11261. * Execute the action and do nothing.
  11262. */
  11263. execute(): void;
  11264. /**
  11265. * Serializes the actions and its related information.
  11266. * @param parent defines the object to serialize in
  11267. * @returns the serialized object
  11268. */
  11269. serialize(parent: any): any;
  11270. }
  11271. /**
  11272. * This defines an action responsible to trigger several actions once triggered.
  11273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11274. */
  11275. export class CombineAction extends Action {
  11276. /**
  11277. * The list of aggregated animations to run.
  11278. */
  11279. children: Action[];
  11280. /**
  11281. * Instantiate the action
  11282. * @param triggerOptions defines the trigger options
  11283. * @param children defines the list of aggregated animations to run
  11284. * @param condition defines the trigger related conditions
  11285. */
  11286. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11287. /** @hidden */
  11288. _prepare(): void;
  11289. /**
  11290. * Execute the action and executes all the aggregated actions.
  11291. */
  11292. execute(evt: ActionEvent): void;
  11293. /**
  11294. * Serializes the actions and its related information.
  11295. * @param parent defines the object to serialize in
  11296. * @returns the serialized object
  11297. */
  11298. serialize(parent: any): any;
  11299. }
  11300. /**
  11301. * This defines an action responsible to run code (external event) once triggered.
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11303. */
  11304. export class ExecuteCodeAction extends Action {
  11305. /**
  11306. * The callback function to run.
  11307. */
  11308. func: (evt: ActionEvent) => void;
  11309. /**
  11310. * Instantiate the action
  11311. * @param triggerOptions defines the trigger options
  11312. * @param func defines the callback function to run
  11313. * @param condition defines the trigger related conditions
  11314. */
  11315. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11316. /**
  11317. * Execute the action and run the attached code.
  11318. */
  11319. execute(evt: ActionEvent): void;
  11320. }
  11321. /**
  11322. * This defines an action responsible to set the parent property of the target once triggered.
  11323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11324. */
  11325. export class SetParentAction extends Action {
  11326. private _parent;
  11327. private _target;
  11328. /**
  11329. * Instantiate the action
  11330. * @param triggerOptions defines the trigger options
  11331. * @param target defines the target containing the parent property
  11332. * @param parent defines from where the animation should start (animation frame)
  11333. * @param condition defines the trigger related conditions
  11334. */
  11335. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11336. /** @hidden */
  11337. _prepare(): void;
  11338. /**
  11339. * Execute the action and set the parent property.
  11340. */
  11341. execute(): void;
  11342. /**
  11343. * Serializes the actions and its related information.
  11344. * @param parent defines the object to serialize in
  11345. * @returns the serialized object
  11346. */
  11347. serialize(parent: any): any;
  11348. }
  11349. }
  11350. declare module "babylonjs/Actions/actionManager" {
  11351. import { Nullable } from "babylonjs/types";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { Scene } from "babylonjs/scene";
  11354. import { IAction } from "babylonjs/Actions/action";
  11355. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11356. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11357. /**
  11358. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11359. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11361. */
  11362. export class ActionManager extends AbstractActionManager {
  11363. /**
  11364. * Nothing
  11365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11366. */
  11367. static readonly NothingTrigger: number;
  11368. /**
  11369. * On pick
  11370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11371. */
  11372. static readonly OnPickTrigger: number;
  11373. /**
  11374. * On left pick
  11375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11376. */
  11377. static readonly OnLeftPickTrigger: number;
  11378. /**
  11379. * On right pick
  11380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11381. */
  11382. static readonly OnRightPickTrigger: number;
  11383. /**
  11384. * On center pick
  11385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11386. */
  11387. static readonly OnCenterPickTrigger: number;
  11388. /**
  11389. * On pick down
  11390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11391. */
  11392. static readonly OnPickDownTrigger: number;
  11393. /**
  11394. * On double pick
  11395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11396. */
  11397. static readonly OnDoublePickTrigger: number;
  11398. /**
  11399. * On pick up
  11400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11401. */
  11402. static readonly OnPickUpTrigger: number;
  11403. /**
  11404. * On pick out.
  11405. * This trigger will only be raised if you also declared a OnPickDown
  11406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11407. */
  11408. static readonly OnPickOutTrigger: number;
  11409. /**
  11410. * On long press
  11411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11412. */
  11413. static readonly OnLongPressTrigger: number;
  11414. /**
  11415. * On pointer over
  11416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11417. */
  11418. static readonly OnPointerOverTrigger: number;
  11419. /**
  11420. * On pointer out
  11421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11422. */
  11423. static readonly OnPointerOutTrigger: number;
  11424. /**
  11425. * On every frame
  11426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11427. */
  11428. static readonly OnEveryFrameTrigger: number;
  11429. /**
  11430. * On intersection enter
  11431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11432. */
  11433. static readonly OnIntersectionEnterTrigger: number;
  11434. /**
  11435. * On intersection exit
  11436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11437. */
  11438. static readonly OnIntersectionExitTrigger: number;
  11439. /**
  11440. * On key down
  11441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11442. */
  11443. static readonly OnKeyDownTrigger: number;
  11444. /**
  11445. * On key up
  11446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11447. */
  11448. static readonly OnKeyUpTrigger: number;
  11449. private _scene;
  11450. /**
  11451. * Creates a new action manager
  11452. * @param scene defines the hosting scene
  11453. */
  11454. constructor(scene: Scene);
  11455. /**
  11456. * Releases all associated resources
  11457. */
  11458. dispose(): void;
  11459. /**
  11460. * Gets hosting scene
  11461. * @returns the hosting scene
  11462. */
  11463. getScene(): Scene;
  11464. /**
  11465. * Does this action manager handles actions of any of the given triggers
  11466. * @param triggers defines the triggers to be tested
  11467. * @return a boolean indicating whether one (or more) of the triggers is handled
  11468. */
  11469. hasSpecificTriggers(triggers: number[]): boolean;
  11470. /**
  11471. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11472. * speed.
  11473. * @param triggerA defines the trigger to be tested
  11474. * @param triggerB defines the trigger to be tested
  11475. * @return a boolean indicating whether one (or more) of the triggers is handled
  11476. */
  11477. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11478. /**
  11479. * Does this action manager handles actions of a given trigger
  11480. * @param trigger defines the trigger to be tested
  11481. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11482. * @return whether the trigger is handled
  11483. */
  11484. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11485. /**
  11486. * Does this action manager has pointer triggers
  11487. */
  11488. readonly hasPointerTriggers: boolean;
  11489. /**
  11490. * Does this action manager has pick triggers
  11491. */
  11492. readonly hasPickTriggers: boolean;
  11493. /**
  11494. * Registers an action to this action manager
  11495. * @param action defines the action to be registered
  11496. * @return the action amended (prepared) after registration
  11497. */
  11498. registerAction(action: IAction): Nullable<IAction>;
  11499. /**
  11500. * Unregisters an action to this action manager
  11501. * @param action defines the action to be unregistered
  11502. * @return a boolean indicating whether the action has been unregistered
  11503. */
  11504. unregisterAction(action: IAction): Boolean;
  11505. /**
  11506. * Process a specific trigger
  11507. * @param trigger defines the trigger to process
  11508. * @param evt defines the event details to be processed
  11509. */
  11510. processTrigger(trigger: number, evt?: IActionEvent): void;
  11511. /** @hidden */
  11512. _getEffectiveTarget(target: any, propertyPath: string): any;
  11513. /** @hidden */
  11514. _getProperty(propertyPath: string): string;
  11515. /**
  11516. * Serialize this manager to a JSON object
  11517. * @param name defines the property name to store this manager
  11518. * @returns a JSON representation of this manager
  11519. */
  11520. serialize(name: string): any;
  11521. /**
  11522. * Creates a new ActionManager from a JSON data
  11523. * @param parsedActions defines the JSON data to read from
  11524. * @param object defines the hosting mesh
  11525. * @param scene defines the hosting scene
  11526. */
  11527. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11528. /**
  11529. * Get a trigger name by index
  11530. * @param trigger defines the trigger index
  11531. * @returns a trigger name
  11532. */
  11533. static GetTriggerName(trigger: number): string;
  11534. }
  11535. }
  11536. declare module "babylonjs/Culling/ray" {
  11537. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11538. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11541. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11542. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11543. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11544. /**
  11545. * Class representing a ray with position and direction
  11546. */
  11547. export class Ray {
  11548. /** origin point */
  11549. origin: Vector3;
  11550. /** direction */
  11551. direction: Vector3;
  11552. /** length of the ray */
  11553. length: number;
  11554. private static readonly TmpVector3;
  11555. private _tmpRay;
  11556. /**
  11557. * Creates a new ray
  11558. * @param origin origin point
  11559. * @param direction direction
  11560. * @param length length of the ray
  11561. */
  11562. constructor(
  11563. /** origin point */
  11564. origin: Vector3,
  11565. /** direction */
  11566. direction: Vector3,
  11567. /** length of the ray */
  11568. length?: number);
  11569. /**
  11570. * Checks if the ray intersects a box
  11571. * @param minimum bound of the box
  11572. * @param maximum bound of the box
  11573. * @param intersectionTreshold extra extend to be added to the box in all direction
  11574. * @returns if the box was hit
  11575. */
  11576. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11577. /**
  11578. * Checks if the ray intersects a box
  11579. * @param box the bounding box to check
  11580. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11581. * @returns if the box was hit
  11582. */
  11583. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11584. /**
  11585. * If the ray hits a sphere
  11586. * @param sphere the bounding sphere to check
  11587. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11588. * @returns true if it hits the sphere
  11589. */
  11590. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11591. /**
  11592. * If the ray hits a triange
  11593. * @param vertex0 triangle vertex
  11594. * @param vertex1 triangle vertex
  11595. * @param vertex2 triangle vertex
  11596. * @returns intersection information if hit
  11597. */
  11598. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11599. /**
  11600. * Checks if ray intersects a plane
  11601. * @param plane the plane to check
  11602. * @returns the distance away it was hit
  11603. */
  11604. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11605. /**
  11606. * Checks if ray intersects a mesh
  11607. * @param mesh the mesh to check
  11608. * @param fastCheck if only the bounding box should checked
  11609. * @returns picking info of the intersecton
  11610. */
  11611. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11612. /**
  11613. * Checks if ray intersects a mesh
  11614. * @param meshes the meshes to check
  11615. * @param fastCheck if only the bounding box should checked
  11616. * @param results array to store result in
  11617. * @returns Array of picking infos
  11618. */
  11619. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11620. private _comparePickingInfo;
  11621. private static smallnum;
  11622. private static rayl;
  11623. /**
  11624. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11625. * @param sega the first point of the segment to test the intersection against
  11626. * @param segb the second point of the segment to test the intersection against
  11627. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11628. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11629. */
  11630. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11631. /**
  11632. * Update the ray from viewport position
  11633. * @param x position
  11634. * @param y y position
  11635. * @param viewportWidth viewport width
  11636. * @param viewportHeight viewport height
  11637. * @param world world matrix
  11638. * @param view view matrix
  11639. * @param projection projection matrix
  11640. * @returns this ray updated
  11641. */
  11642. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11643. /**
  11644. * Creates a ray with origin and direction of 0,0,0
  11645. * @returns the new ray
  11646. */
  11647. static Zero(): Ray;
  11648. /**
  11649. * Creates a new ray from screen space and viewport
  11650. * @param x position
  11651. * @param y y position
  11652. * @param viewportWidth viewport width
  11653. * @param viewportHeight viewport height
  11654. * @param world world matrix
  11655. * @param view view matrix
  11656. * @param projection projection matrix
  11657. * @returns new ray
  11658. */
  11659. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11660. /**
  11661. * 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
  11662. * transformed to the given world matrix.
  11663. * @param origin The origin point
  11664. * @param end The end point
  11665. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11666. * @returns the new ray
  11667. */
  11668. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11669. /**
  11670. * Transforms a ray by a matrix
  11671. * @param ray ray to transform
  11672. * @param matrix matrix to apply
  11673. * @returns the resulting new ray
  11674. */
  11675. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11676. /**
  11677. * Transforms a ray by a matrix
  11678. * @param ray ray to transform
  11679. * @param matrix matrix to apply
  11680. * @param result ray to store result in
  11681. */
  11682. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11683. /**
  11684. * Unproject a ray from screen space to object space
  11685. * @param sourceX defines the screen space x coordinate to use
  11686. * @param sourceY defines the screen space y coordinate to use
  11687. * @param viewportWidth defines the current width of the viewport
  11688. * @param viewportHeight defines the current height of the viewport
  11689. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11690. * @param view defines the view matrix to use
  11691. * @param projection defines the projection matrix to use
  11692. */
  11693. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11694. }
  11695. /**
  11696. * Type used to define predicate used to select faces when a mesh intersection is detected
  11697. */
  11698. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11699. module "babylonjs/scene" {
  11700. interface Scene {
  11701. /** @hidden */
  11702. _tempPickingRay: Nullable<Ray>;
  11703. /** @hidden */
  11704. _cachedRayForTransform: Ray;
  11705. /** @hidden */
  11706. _pickWithRayInverseMatrix: Matrix;
  11707. /** @hidden */
  11708. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11709. /** @hidden */
  11710. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11711. }
  11712. }
  11713. }
  11714. declare module "babylonjs/sceneComponent" {
  11715. import { Scene } from "babylonjs/scene";
  11716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11718. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11719. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11720. import { Nullable } from "babylonjs/types";
  11721. import { Camera } from "babylonjs/Cameras/camera";
  11722. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11723. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11724. import { AbstractScene } from "babylonjs/abstractScene";
  11725. /**
  11726. * Groups all the scene component constants in one place to ease maintenance.
  11727. * @hidden
  11728. */
  11729. export class SceneComponentConstants {
  11730. static readonly NAME_EFFECTLAYER: string;
  11731. static readonly NAME_LAYER: string;
  11732. static readonly NAME_LENSFLARESYSTEM: string;
  11733. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11734. static readonly NAME_PARTICLESYSTEM: string;
  11735. static readonly NAME_GAMEPAD: string;
  11736. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11737. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11738. static readonly NAME_DEPTHRENDERER: string;
  11739. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11740. static readonly NAME_SPRITE: string;
  11741. static readonly NAME_OUTLINERENDERER: string;
  11742. static readonly NAME_PROCEDURALTEXTURE: string;
  11743. static readonly NAME_SHADOWGENERATOR: string;
  11744. static readonly NAME_OCTREE: string;
  11745. static readonly NAME_PHYSICSENGINE: string;
  11746. static readonly NAME_AUDIO: string;
  11747. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11748. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11749. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11750. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11751. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11752. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11753. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11754. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11755. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11756. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11757. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11758. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11759. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11760. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11761. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11762. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11764. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11765. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11766. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11767. static readonly STEP_AFTERRENDER_AUDIO: number;
  11768. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11769. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11770. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11771. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11772. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11773. static readonly STEP_POINTERMOVE_SPRITE: number;
  11774. static readonly STEP_POINTERDOWN_SPRITE: number;
  11775. static readonly STEP_POINTERUP_SPRITE: number;
  11776. }
  11777. /**
  11778. * This represents a scene component.
  11779. *
  11780. * This is used to decouple the dependency the scene is having on the different workloads like
  11781. * layers, post processes...
  11782. */
  11783. export interface ISceneComponent {
  11784. /**
  11785. * The name of the component. Each component must have a unique name.
  11786. */
  11787. name: string;
  11788. /**
  11789. * The scene the component belongs to.
  11790. */
  11791. scene: Scene;
  11792. /**
  11793. * Register the component to one instance of a scene.
  11794. */
  11795. register(): void;
  11796. /**
  11797. * Rebuilds the elements related to this component in case of
  11798. * context lost for instance.
  11799. */
  11800. rebuild(): void;
  11801. /**
  11802. * Disposes the component and the associated ressources.
  11803. */
  11804. dispose(): void;
  11805. }
  11806. /**
  11807. * This represents a SERIALIZABLE scene component.
  11808. *
  11809. * This extends Scene Component to add Serialization methods on top.
  11810. */
  11811. export interface ISceneSerializableComponent extends ISceneComponent {
  11812. /**
  11813. * Adds all the element from the container to the scene
  11814. * @param container the container holding the elements
  11815. */
  11816. addFromContainer(container: AbstractScene): void;
  11817. /**
  11818. * Removes all the elements in the container from the scene
  11819. * @param container contains the elements to remove
  11820. * @param dispose if the removed element should be disposed (default: false)
  11821. */
  11822. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11823. /**
  11824. * Serializes the component data to the specified json object
  11825. * @param serializationObject The object to serialize to
  11826. */
  11827. serialize(serializationObject: any): void;
  11828. }
  11829. /**
  11830. * Strong typing of a Mesh related stage step action
  11831. */
  11832. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11833. /**
  11834. * Strong typing of a Evaluate Sub Mesh related stage step action
  11835. */
  11836. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11837. /**
  11838. * Strong typing of a Active Mesh related stage step action
  11839. */
  11840. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11841. /**
  11842. * Strong typing of a Camera related stage step action
  11843. */
  11844. export type CameraStageAction = (camera: Camera) => void;
  11845. /**
  11846. * Strong typing of a Camera Frame buffer related stage step action
  11847. */
  11848. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11849. /**
  11850. * Strong typing of a Render Target related stage step action
  11851. */
  11852. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11853. /**
  11854. * Strong typing of a RenderingGroup related stage step action
  11855. */
  11856. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11857. /**
  11858. * Strong typing of a Mesh Render related stage step action
  11859. */
  11860. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11861. /**
  11862. * Strong typing of a simple stage step action
  11863. */
  11864. export type SimpleStageAction = () => void;
  11865. /**
  11866. * Strong typing of a render target action.
  11867. */
  11868. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11869. /**
  11870. * Strong typing of a pointer move action.
  11871. */
  11872. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11873. /**
  11874. * Strong typing of a pointer up/down action.
  11875. */
  11876. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11877. /**
  11878. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11879. * @hidden
  11880. */
  11881. export class Stage<T extends Function> extends Array<{
  11882. index: number;
  11883. component: ISceneComponent;
  11884. action: T;
  11885. }> {
  11886. /**
  11887. * Hide ctor from the rest of the world.
  11888. * @param items The items to add.
  11889. */
  11890. private constructor();
  11891. /**
  11892. * Creates a new Stage.
  11893. * @returns A new instance of a Stage
  11894. */
  11895. static Create<T extends Function>(): Stage<T>;
  11896. /**
  11897. * Registers a step in an ordered way in the targeted stage.
  11898. * @param index Defines the position to register the step in
  11899. * @param component Defines the component attached to the step
  11900. * @param action Defines the action to launch during the step
  11901. */
  11902. registerStep(index: number, component: ISceneComponent, action: T): void;
  11903. /**
  11904. * Clears all the steps from the stage.
  11905. */
  11906. clear(): void;
  11907. }
  11908. }
  11909. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11910. import { Nullable } from "babylonjs/types";
  11911. import { Observable } from "babylonjs/Misc/observable";
  11912. import { Scene } from "babylonjs/scene";
  11913. import { Sprite } from "babylonjs/Sprites/sprite";
  11914. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11915. import { Ray } from "babylonjs/Culling/ray";
  11916. import { Camera } from "babylonjs/Cameras/camera";
  11917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11918. import { ISceneComponent } from "babylonjs/sceneComponent";
  11919. module "babylonjs/scene" {
  11920. interface Scene {
  11921. /** @hidden */
  11922. _pointerOverSprite: Nullable<Sprite>;
  11923. /** @hidden */
  11924. _pickedDownSprite: Nullable<Sprite>;
  11925. /** @hidden */
  11926. _tempSpritePickingRay: Nullable<Ray>;
  11927. /**
  11928. * All of the sprite managers added to this scene
  11929. * @see http://doc.babylonjs.com/babylon101/sprites
  11930. */
  11931. spriteManagers: Array<ISpriteManager>;
  11932. /**
  11933. * An event triggered when sprites rendering is about to start
  11934. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11935. */
  11936. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11937. /**
  11938. * An event triggered when sprites rendering is done
  11939. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11940. */
  11941. onAfterSpritesRenderingObservable: Observable<Scene>;
  11942. /** @hidden */
  11943. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11944. /** Launch a ray to try to pick a sprite in the scene
  11945. * @param x position on screen
  11946. * @param y position on screen
  11947. * @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
  11948. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11949. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11950. * @returns a PickingInfo
  11951. */
  11952. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11953. /** Use the given ray to pick a sprite in the scene
  11954. * @param ray The ray (in world space) to use to pick meshes
  11955. * @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
  11956. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11957. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11958. * @returns a PickingInfo
  11959. */
  11960. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11961. /**
  11962. * Force the sprite under the pointer
  11963. * @param sprite defines the sprite to use
  11964. */
  11965. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11966. /**
  11967. * Gets the sprite under the pointer
  11968. * @returns a Sprite or null if no sprite is under the pointer
  11969. */
  11970. getPointerOverSprite(): Nullable<Sprite>;
  11971. }
  11972. }
  11973. /**
  11974. * Defines the sprite scene component responsible to manage sprites
  11975. * in a given scene.
  11976. */
  11977. export class SpriteSceneComponent implements ISceneComponent {
  11978. /**
  11979. * The component name helpfull to identify the component in the list of scene components.
  11980. */
  11981. readonly name: string;
  11982. /**
  11983. * The scene the component belongs to.
  11984. */
  11985. scene: Scene;
  11986. /** @hidden */
  11987. private _spritePredicate;
  11988. /**
  11989. * Creates a new instance of the component for the given scene
  11990. * @param scene Defines the scene to register the component in
  11991. */
  11992. constructor(scene: Scene);
  11993. /**
  11994. * Registers the component in a given scene
  11995. */
  11996. register(): void;
  11997. /**
  11998. * Rebuilds the elements related to this component in case of
  11999. * context lost for instance.
  12000. */
  12001. rebuild(): void;
  12002. /**
  12003. * Disposes the component and the associated ressources.
  12004. */
  12005. dispose(): void;
  12006. private _pickSpriteButKeepRay;
  12007. private _pointerMove;
  12008. private _pointerDown;
  12009. private _pointerUp;
  12010. }
  12011. }
  12012. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12013. /** @hidden */
  12014. export var fogFragmentDeclaration: {
  12015. name: string;
  12016. shader: string;
  12017. };
  12018. }
  12019. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12020. /** @hidden */
  12021. export var fogFragment: {
  12022. name: string;
  12023. shader: string;
  12024. };
  12025. }
  12026. declare module "babylonjs/Shaders/sprites.fragment" {
  12027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12028. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12029. /** @hidden */
  12030. export var spritesPixelShader: {
  12031. name: string;
  12032. shader: string;
  12033. };
  12034. }
  12035. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12036. /** @hidden */
  12037. export var fogVertexDeclaration: {
  12038. name: string;
  12039. shader: string;
  12040. };
  12041. }
  12042. declare module "babylonjs/Shaders/sprites.vertex" {
  12043. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12044. /** @hidden */
  12045. export var spritesVertexShader: {
  12046. name: string;
  12047. shader: string;
  12048. };
  12049. }
  12050. declare module "babylonjs/Sprites/spriteManager" {
  12051. import { IDisposable, Scene } from "babylonjs/scene";
  12052. import { Nullable } from "babylonjs/types";
  12053. import { Observable } from "babylonjs/Misc/observable";
  12054. import { Sprite } from "babylonjs/Sprites/sprite";
  12055. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12056. import { Camera } from "babylonjs/Cameras/camera";
  12057. import { Texture } from "babylonjs/Materials/Textures/texture";
  12058. import "babylonjs/Shaders/sprites.fragment";
  12059. import "babylonjs/Shaders/sprites.vertex";
  12060. import { Ray } from "babylonjs/Culling/ray";
  12061. /**
  12062. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12063. */
  12064. export interface ISpriteManager extends IDisposable {
  12065. /**
  12066. * Restricts the camera to viewing objects with the same layerMask.
  12067. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12068. */
  12069. layerMask: number;
  12070. /**
  12071. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12072. */
  12073. isPickable: boolean;
  12074. /**
  12075. * Specifies the rendering group id for this mesh (0 by default)
  12076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12077. */
  12078. renderingGroupId: number;
  12079. /**
  12080. * Defines the list of sprites managed by the manager.
  12081. */
  12082. sprites: Array<Sprite>;
  12083. /**
  12084. * Tests the intersection of a sprite with a specific ray.
  12085. * @param ray The ray we are sending to test the collision
  12086. * @param camera The camera space we are sending rays in
  12087. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12088. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12089. * @returns picking info or null.
  12090. */
  12091. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12092. /**
  12093. * Renders the list of sprites on screen.
  12094. */
  12095. render(): void;
  12096. }
  12097. /**
  12098. * Class used to manage multiple sprites on the same spritesheet
  12099. * @see http://doc.babylonjs.com/babylon101/sprites
  12100. */
  12101. export class SpriteManager implements ISpriteManager {
  12102. /** defines the manager's name */
  12103. name: string;
  12104. /** Gets the list of sprites */
  12105. sprites: Sprite[];
  12106. /** Gets or sets the rendering group id (0 by default) */
  12107. renderingGroupId: number;
  12108. /** Gets or sets camera layer mask */
  12109. layerMask: number;
  12110. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12111. fogEnabled: boolean;
  12112. /** Gets or sets a boolean indicating if the sprites are pickable */
  12113. isPickable: boolean;
  12114. /** Defines the default width of a cell in the spritesheet */
  12115. cellWidth: number;
  12116. /** Defines the default height of a cell in the spritesheet */
  12117. cellHeight: number;
  12118. /**
  12119. * An event triggered when the manager is disposed.
  12120. */
  12121. onDisposeObservable: Observable<SpriteManager>;
  12122. private _onDisposeObserver;
  12123. /**
  12124. * Callback called when the manager is disposed
  12125. */
  12126. onDispose: () => void;
  12127. private _capacity;
  12128. private _spriteTexture;
  12129. private _epsilon;
  12130. private _scene;
  12131. private _vertexData;
  12132. private _buffer;
  12133. private _vertexBuffers;
  12134. private _indexBuffer;
  12135. private _effectBase;
  12136. private _effectFog;
  12137. /**
  12138. * Gets or sets the spritesheet texture
  12139. */
  12140. texture: Texture;
  12141. /**
  12142. * Creates a new sprite manager
  12143. * @param name defines the manager's name
  12144. * @param imgUrl defines the sprite sheet url
  12145. * @param capacity defines the maximum allowed number of sprites
  12146. * @param cellSize defines the size of a sprite cell
  12147. * @param scene defines the hosting scene
  12148. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12149. * @param samplingMode defines the smapling mode to use with spritesheet
  12150. */
  12151. constructor(
  12152. /** defines the manager's name */
  12153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12154. private _appendSpriteVertex;
  12155. /**
  12156. * Intersects the sprites with a ray
  12157. * @param ray defines the ray to intersect with
  12158. * @param camera defines the current active camera
  12159. * @param predicate defines a predicate used to select candidate sprites
  12160. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12161. * @returns null if no hit or a PickingInfo
  12162. */
  12163. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12164. /**
  12165. * Render all child sprites
  12166. */
  12167. render(): void;
  12168. /**
  12169. * Release associated resources
  12170. */
  12171. dispose(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Sprites/sprite" {
  12175. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12176. import { Nullable } from "babylonjs/types";
  12177. import { ActionManager } from "babylonjs/Actions/actionManager";
  12178. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12179. /**
  12180. * Class used to represent a sprite
  12181. * @see http://doc.babylonjs.com/babylon101/sprites
  12182. */
  12183. export class Sprite {
  12184. /** defines the name */
  12185. name: string;
  12186. /** Gets or sets the current world position */
  12187. position: Vector3;
  12188. /** Gets or sets the main color */
  12189. color: Color4;
  12190. /** Gets or sets the width */
  12191. width: number;
  12192. /** Gets or sets the height */
  12193. height: number;
  12194. /** Gets or sets rotation angle */
  12195. angle: number;
  12196. /** Gets or sets the cell index in the sprite sheet */
  12197. cellIndex: number;
  12198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12199. invertU: number;
  12200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12201. invertV: number;
  12202. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12203. disposeWhenFinishedAnimating: boolean;
  12204. /** Gets the list of attached animations */
  12205. animations: Animation[];
  12206. /** Gets or sets a boolean indicating if the sprite can be picked */
  12207. isPickable: boolean;
  12208. /**
  12209. * Gets or sets the associated action manager
  12210. */
  12211. actionManager: Nullable<ActionManager>;
  12212. private _animationStarted;
  12213. private _loopAnimation;
  12214. private _fromIndex;
  12215. private _toIndex;
  12216. private _delay;
  12217. private _direction;
  12218. private _manager;
  12219. private _time;
  12220. private _onAnimationEnd;
  12221. /**
  12222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12223. */
  12224. isVisible: boolean;
  12225. /**
  12226. * Gets or sets the sprite size
  12227. */
  12228. size: number;
  12229. /**
  12230. * Creates a new Sprite
  12231. * @param name defines the name
  12232. * @param manager defines the manager
  12233. */
  12234. constructor(
  12235. /** defines the name */
  12236. name: string, manager: ISpriteManager);
  12237. /**
  12238. * Starts an animation
  12239. * @param from defines the initial key
  12240. * @param to defines the end key
  12241. * @param loop defines if the animation must loop
  12242. * @param delay defines the start delay (in ms)
  12243. * @param onAnimationEnd defines a callback to call when animation ends
  12244. */
  12245. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12246. /** Stops current animation (if any) */
  12247. stopAnimation(): void;
  12248. /** @hidden */
  12249. _animate(deltaTime: number): void;
  12250. /** Release associated resources */
  12251. dispose(): void;
  12252. }
  12253. }
  12254. declare module "babylonjs/Collisions/pickingInfo" {
  12255. import { Nullable } from "babylonjs/types";
  12256. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12258. import { Sprite } from "babylonjs/Sprites/sprite";
  12259. import { Ray } from "babylonjs/Culling/ray";
  12260. /**
  12261. * Information about the result of picking within a scene
  12262. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12263. */
  12264. export class PickingInfo {
  12265. /** @hidden */
  12266. _pickingUnavailable: boolean;
  12267. /**
  12268. * If the pick collided with an object
  12269. */
  12270. hit: boolean;
  12271. /**
  12272. * Distance away where the pick collided
  12273. */
  12274. distance: number;
  12275. /**
  12276. * The location of pick collision
  12277. */
  12278. pickedPoint: Nullable<Vector3>;
  12279. /**
  12280. * The mesh corresponding the the pick collision
  12281. */
  12282. pickedMesh: Nullable<AbstractMesh>;
  12283. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12284. bu: number;
  12285. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12286. bv: number;
  12287. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12288. faceId: number;
  12289. /** Id of the the submesh that was picked */
  12290. subMeshId: number;
  12291. /** If a sprite was picked, this will be the sprite the pick collided with */
  12292. pickedSprite: Nullable<Sprite>;
  12293. /**
  12294. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12295. */
  12296. originMesh: Nullable<AbstractMesh>;
  12297. /**
  12298. * The ray that was used to perform the picking.
  12299. */
  12300. ray: Nullable<Ray>;
  12301. /**
  12302. * Gets the normal correspodning to the face the pick collided with
  12303. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12304. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12305. * @returns The normal correspodning to the face the pick collided with
  12306. */
  12307. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12308. /**
  12309. * Gets the texture coordinates of where the pick occured
  12310. * @returns the vector containing the coordnates of the texture
  12311. */
  12312. getTextureCoordinates(): Nullable<Vector2>;
  12313. }
  12314. }
  12315. declare module "babylonjs/Events/pointerEvents" {
  12316. import { Nullable } from "babylonjs/types";
  12317. import { Vector2 } from "babylonjs/Maths/math";
  12318. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12319. import { Ray } from "babylonjs/Culling/ray";
  12320. /**
  12321. * Gather the list of pointer event types as constants.
  12322. */
  12323. export class PointerEventTypes {
  12324. /**
  12325. * 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.
  12326. */
  12327. static readonly POINTERDOWN: number;
  12328. /**
  12329. * The pointerup event is fired when a pointer is no longer active.
  12330. */
  12331. static readonly POINTERUP: number;
  12332. /**
  12333. * The pointermove event is fired when a pointer changes coordinates.
  12334. */
  12335. static readonly POINTERMOVE: number;
  12336. /**
  12337. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12338. */
  12339. static readonly POINTERWHEEL: number;
  12340. /**
  12341. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12342. */
  12343. static readonly POINTERPICK: number;
  12344. /**
  12345. * The pointertap event is fired when a the object has been touched and released without drag.
  12346. */
  12347. static readonly POINTERTAP: number;
  12348. /**
  12349. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12350. */
  12351. static readonly POINTERDOUBLETAP: number;
  12352. }
  12353. /**
  12354. * Base class of pointer info types.
  12355. */
  12356. export class PointerInfoBase {
  12357. /**
  12358. * Defines the type of event (PointerEventTypes)
  12359. */
  12360. type: number;
  12361. /**
  12362. * Defines the related dom event
  12363. */
  12364. event: PointerEvent | MouseWheelEvent;
  12365. /**
  12366. * Instantiates the base class of pointers info.
  12367. * @param type Defines the type of event (PointerEventTypes)
  12368. * @param event Defines the related dom event
  12369. */
  12370. constructor(
  12371. /**
  12372. * Defines the type of event (PointerEventTypes)
  12373. */
  12374. type: number,
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: PointerEvent | MouseWheelEvent);
  12379. }
  12380. /**
  12381. * This class is used to store pointer related info for the onPrePointerObservable event.
  12382. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12383. */
  12384. export class PointerInfoPre extends PointerInfoBase {
  12385. /**
  12386. * Ray from a pointer if availible (eg. 6dof controller)
  12387. */
  12388. ray: Nullable<Ray>;
  12389. /**
  12390. * Defines the local position of the pointer on the canvas.
  12391. */
  12392. localPosition: Vector2;
  12393. /**
  12394. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12395. */
  12396. skipOnPointerObservable: boolean;
  12397. /**
  12398. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12399. * @param type Defines the type of event (PointerEventTypes)
  12400. * @param event Defines the related dom event
  12401. * @param localX Defines the local x coordinates of the pointer when the event occured
  12402. * @param localY Defines the local y coordinates of the pointer when the event occured
  12403. */
  12404. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12405. }
  12406. /**
  12407. * This type contains all the data related to a pointer event in Babylon.js.
  12408. * 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.
  12409. */
  12410. export class PointerInfo extends PointerInfoBase {
  12411. /**
  12412. * Defines the picking info associated to the info (if any)\
  12413. */
  12414. pickInfo: Nullable<PickingInfo>;
  12415. /**
  12416. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12417. * @param type Defines the type of event (PointerEventTypes)
  12418. * @param event Defines the related dom event
  12419. * @param pickInfo Defines the picking info associated to the info (if any)\
  12420. */
  12421. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12422. /**
  12423. * Defines the picking info associated to the info (if any)\
  12424. */
  12425. pickInfo: Nullable<PickingInfo>);
  12426. }
  12427. /**
  12428. * Data relating to a touch event on the screen.
  12429. */
  12430. export interface PointerTouch {
  12431. /**
  12432. * X coordinate of touch.
  12433. */
  12434. x: number;
  12435. /**
  12436. * Y coordinate of touch.
  12437. */
  12438. y: number;
  12439. /**
  12440. * Id of touch. Unique for each finger.
  12441. */
  12442. pointerId: number;
  12443. /**
  12444. * Event type passed from DOM.
  12445. */
  12446. type: any;
  12447. }
  12448. }
  12449. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12450. import { Observable } from "babylonjs/Misc/observable";
  12451. import { Nullable } from "babylonjs/types";
  12452. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12453. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12454. /**
  12455. * Manage the mouse inputs to control the movement of a free camera.
  12456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12457. */
  12458. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12459. /**
  12460. * Define if touch is enabled in the mouse input
  12461. */
  12462. touchEnabled: boolean;
  12463. /**
  12464. * Defines the camera the input is attached to.
  12465. */
  12466. camera: FreeCamera;
  12467. /**
  12468. * Defines the buttons associated with the input to handle camera move.
  12469. */
  12470. buttons: number[];
  12471. /**
  12472. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12473. */
  12474. angularSensibility: number;
  12475. private _pointerInput;
  12476. private _onMouseMove;
  12477. private _observer;
  12478. private previousPosition;
  12479. /**
  12480. * Observable for when a pointer move event occurs containing the move offset
  12481. */
  12482. onPointerMovedObservable: Observable<{
  12483. offsetX: number;
  12484. offsetY: number;
  12485. }>;
  12486. /**
  12487. * @hidden
  12488. * If the camera should be rotated automatically based on pointer movement
  12489. */
  12490. _allowCameraRotation: boolean;
  12491. /**
  12492. * Manage the mouse inputs to control the movement of a free camera.
  12493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12494. * @param touchEnabled Defines if touch is enabled or not
  12495. */
  12496. constructor(
  12497. /**
  12498. * Define if touch is enabled in the mouse input
  12499. */
  12500. touchEnabled?: boolean);
  12501. /**
  12502. * Attach the input controls to a specific dom element to get the input from.
  12503. * @param element Defines the element the controls should be listened from
  12504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12505. */
  12506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12507. /**
  12508. * Called on JS contextmenu event.
  12509. * Override this method to provide functionality.
  12510. */
  12511. protected onContextMenu(evt: PointerEvent): void;
  12512. /**
  12513. * Detach the current controls from the specified dom element.
  12514. * @param element Defines the element to stop listening the inputs from
  12515. */
  12516. detachControl(element: Nullable<HTMLElement>): void;
  12517. /**
  12518. * Gets the class name of the current intput.
  12519. * @returns the class name
  12520. */
  12521. getClassName(): string;
  12522. /**
  12523. * Get the friendly name associated with the input class.
  12524. * @returns the input friendly name
  12525. */
  12526. getSimpleName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the touch inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Defines the camera the input is attached to.
  12540. */
  12541. camera: FreeCamera;
  12542. /**
  12543. * Defines the touch sensibility for rotation.
  12544. * The higher the faster.
  12545. */
  12546. touchAngularSensibility: number;
  12547. /**
  12548. * Defines the touch sensibility for move.
  12549. * The higher the faster.
  12550. */
  12551. touchMoveSensibility: number;
  12552. private _offsetX;
  12553. private _offsetY;
  12554. private _pointerPressed;
  12555. private _pointerInput;
  12556. private _observer;
  12557. private _onLostFocus;
  12558. /**
  12559. * Attach the input controls to a specific dom element to get the input from.
  12560. * @param element Defines the element the controls should be listened from
  12561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12562. */
  12563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12564. /**
  12565. * Detach the current controls from the specified dom element.
  12566. * @param element Defines the element to stop listening the inputs from
  12567. */
  12568. detachControl(element: Nullable<HTMLElement>): void;
  12569. /**
  12570. * Update the current camera state depending on the inputs that have been used this frame.
  12571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12572. */
  12573. checkInputs(): void;
  12574. /**
  12575. * Gets the class name of the current intput.
  12576. * @returns the class name
  12577. */
  12578. getClassName(): string;
  12579. /**
  12580. * Get the friendly name associated with the input class.
  12581. * @returns the input friendly name
  12582. */
  12583. getSimpleName(): string;
  12584. }
  12585. }
  12586. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12588. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12589. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12590. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12591. import { Nullable } from "babylonjs/types";
  12592. /**
  12593. * Default Inputs manager for the FreeCamera.
  12594. * It groups all the default supported inputs for ease of use.
  12595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12596. */
  12597. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12598. /**
  12599. * @hidden
  12600. */
  12601. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12602. /**
  12603. * @hidden
  12604. */
  12605. _mouseInput: Nullable<FreeCameraMouseInput>;
  12606. /**
  12607. * Instantiates a new FreeCameraInputsManager.
  12608. * @param camera Defines the camera the inputs belong to
  12609. */
  12610. constructor(camera: FreeCamera);
  12611. /**
  12612. * Add keyboard input support to the input manager.
  12613. * @returns the current input manager
  12614. */
  12615. addKeyboard(): FreeCameraInputsManager;
  12616. /**
  12617. * Add mouse input support to the input manager.
  12618. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12619. * @returns the current input manager
  12620. */
  12621. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12622. /**
  12623. * Removes the mouse input support from the manager
  12624. * @returns the current input manager
  12625. */
  12626. removeMouse(): FreeCameraInputsManager;
  12627. /**
  12628. * Add touch input support to the input manager.
  12629. * @returns the current input manager
  12630. */
  12631. addTouch(): FreeCameraInputsManager;
  12632. }
  12633. }
  12634. declare module "babylonjs/Cameras/freeCamera" {
  12635. import { Vector3 } from "babylonjs/Maths/math";
  12636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12637. import { Scene } from "babylonjs/scene";
  12638. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12639. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12640. /**
  12641. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12642. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12643. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12644. */
  12645. export class FreeCamera extends TargetCamera {
  12646. /**
  12647. * Define the collision ellipsoid of the camera.
  12648. * This is helpful to simulate a camera body like the player body around the camera
  12649. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12650. */
  12651. ellipsoid: Vector3;
  12652. /**
  12653. * Define an offset for the position of the ellipsoid around the camera.
  12654. * This can be helpful to determine the center of the body near the gravity center of the body
  12655. * instead of its head.
  12656. */
  12657. ellipsoidOffset: Vector3;
  12658. /**
  12659. * Enable or disable collisions of the camera with the rest of the scene objects.
  12660. */
  12661. checkCollisions: boolean;
  12662. /**
  12663. * Enable or disable gravity on the camera.
  12664. */
  12665. applyGravity: boolean;
  12666. /**
  12667. * Define the input manager associated to the camera.
  12668. */
  12669. inputs: FreeCameraInputsManager;
  12670. /**
  12671. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12672. * Higher values reduce sensitivity.
  12673. */
  12674. /**
  12675. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12676. * Higher values reduce sensitivity.
  12677. */
  12678. angularSensibility: number;
  12679. /**
  12680. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12681. */
  12682. keysUp: number[];
  12683. /**
  12684. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12685. */
  12686. keysDown: number[];
  12687. /**
  12688. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12689. */
  12690. keysLeft: number[];
  12691. /**
  12692. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12693. */
  12694. keysRight: number[];
  12695. /**
  12696. * Event raised when the camera collide with a mesh in the scene.
  12697. */
  12698. onCollide: (collidedMesh: AbstractMesh) => void;
  12699. private _collider;
  12700. private _needMoveForGravity;
  12701. private _oldPosition;
  12702. private _diffPosition;
  12703. private _newPosition;
  12704. /** @hidden */
  12705. _localDirection: Vector3;
  12706. /** @hidden */
  12707. _transformedDirection: Vector3;
  12708. /**
  12709. * Instantiates a Free Camera.
  12710. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12711. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12713. * @param name Define the name of the camera in the scene
  12714. * @param position Define the start position of the camera in the scene
  12715. * @param scene Define the scene the camera belongs to
  12716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12717. */
  12718. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12719. /**
  12720. * Attached controls to the current camera.
  12721. * @param element Defines the element the controls should be listened from
  12722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12723. */
  12724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12725. /**
  12726. * Detach the current controls from the camera.
  12727. * The camera will stop reacting to inputs.
  12728. * @param element Defines the element to stop listening the inputs from
  12729. */
  12730. detachControl(element: HTMLElement): void;
  12731. private _collisionMask;
  12732. /**
  12733. * Define a collision mask to limit the list of object the camera can collide with
  12734. */
  12735. collisionMask: number;
  12736. /** @hidden */
  12737. _collideWithWorld(displacement: Vector3): void;
  12738. private _onCollisionPositionChange;
  12739. /** @hidden */
  12740. _checkInputs(): void;
  12741. /** @hidden */
  12742. _decideIfNeedsToMove(): boolean;
  12743. /** @hidden */
  12744. _updatePosition(): void;
  12745. /**
  12746. * Destroy the camera and release the current resources hold by it.
  12747. */
  12748. dispose(): void;
  12749. /**
  12750. * Gets the current object class name.
  12751. * @return the class name
  12752. */
  12753. getClassName(): string;
  12754. }
  12755. }
  12756. declare module "babylonjs/Gamepads/gamepad" {
  12757. import { Observable } from "babylonjs/Misc/observable";
  12758. /**
  12759. * Represents a gamepad control stick position
  12760. */
  12761. export class StickValues {
  12762. /**
  12763. * The x component of the control stick
  12764. */
  12765. x: number;
  12766. /**
  12767. * The y component of the control stick
  12768. */
  12769. y: number;
  12770. /**
  12771. * Initializes the gamepad x and y control stick values
  12772. * @param x The x component of the gamepad control stick value
  12773. * @param y The y component of the gamepad control stick value
  12774. */
  12775. constructor(
  12776. /**
  12777. * The x component of the control stick
  12778. */
  12779. x: number,
  12780. /**
  12781. * The y component of the control stick
  12782. */
  12783. y: number);
  12784. }
  12785. /**
  12786. * An interface which manages callbacks for gamepad button changes
  12787. */
  12788. export interface GamepadButtonChanges {
  12789. /**
  12790. * Called when a gamepad has been changed
  12791. */
  12792. changed: boolean;
  12793. /**
  12794. * Called when a gamepad press event has been triggered
  12795. */
  12796. pressChanged: boolean;
  12797. /**
  12798. * Called when a touch event has been triggered
  12799. */
  12800. touchChanged: boolean;
  12801. /**
  12802. * Called when a value has changed
  12803. */
  12804. valueChanged: boolean;
  12805. }
  12806. /**
  12807. * Represents a gamepad
  12808. */
  12809. export class Gamepad {
  12810. /**
  12811. * The id of the gamepad
  12812. */
  12813. id: string;
  12814. /**
  12815. * The index of the gamepad
  12816. */
  12817. index: number;
  12818. /**
  12819. * The browser gamepad
  12820. */
  12821. browserGamepad: any;
  12822. /**
  12823. * Specifies what type of gamepad this represents
  12824. */
  12825. type: number;
  12826. private _leftStick;
  12827. private _rightStick;
  12828. /** @hidden */
  12829. _isConnected: boolean;
  12830. private _leftStickAxisX;
  12831. private _leftStickAxisY;
  12832. private _rightStickAxisX;
  12833. private _rightStickAxisY;
  12834. /**
  12835. * Triggered when the left control stick has been changed
  12836. */
  12837. private _onleftstickchanged;
  12838. /**
  12839. * Triggered when the right control stick has been changed
  12840. */
  12841. private _onrightstickchanged;
  12842. /**
  12843. * Represents a gamepad controller
  12844. */
  12845. static GAMEPAD: number;
  12846. /**
  12847. * Represents a generic controller
  12848. */
  12849. static GENERIC: number;
  12850. /**
  12851. * Represents an XBox controller
  12852. */
  12853. static XBOX: number;
  12854. /**
  12855. * Represents a pose-enabled controller
  12856. */
  12857. static POSE_ENABLED: number;
  12858. /**
  12859. * Specifies whether the left control stick should be Y-inverted
  12860. */
  12861. protected _invertLeftStickY: boolean;
  12862. /**
  12863. * Specifies if the gamepad has been connected
  12864. */
  12865. readonly isConnected: boolean;
  12866. /**
  12867. * Initializes the gamepad
  12868. * @param id The id of the gamepad
  12869. * @param index The index of the gamepad
  12870. * @param browserGamepad The browser gamepad
  12871. * @param leftStickX The x component of the left joystick
  12872. * @param leftStickY The y component of the left joystick
  12873. * @param rightStickX The x component of the right joystick
  12874. * @param rightStickY The y component of the right joystick
  12875. */
  12876. constructor(
  12877. /**
  12878. * The id of the gamepad
  12879. */
  12880. id: string,
  12881. /**
  12882. * The index of the gamepad
  12883. */
  12884. index: number,
  12885. /**
  12886. * The browser gamepad
  12887. */
  12888. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12889. /**
  12890. * Callback triggered when the left joystick has changed
  12891. * @param callback
  12892. */
  12893. onleftstickchanged(callback: (values: StickValues) => void): void;
  12894. /**
  12895. * Callback triggered when the right joystick has changed
  12896. * @param callback
  12897. */
  12898. onrightstickchanged(callback: (values: StickValues) => void): void;
  12899. /**
  12900. * Gets the left joystick
  12901. */
  12902. /**
  12903. * Sets the left joystick values
  12904. */
  12905. leftStick: StickValues;
  12906. /**
  12907. * Gets the right joystick
  12908. */
  12909. /**
  12910. * Sets the right joystick value
  12911. */
  12912. rightStick: StickValues;
  12913. /**
  12914. * Updates the gamepad joystick positions
  12915. */
  12916. update(): void;
  12917. /**
  12918. * Disposes the gamepad
  12919. */
  12920. dispose(): void;
  12921. }
  12922. /**
  12923. * Represents a generic gamepad
  12924. */
  12925. export class GenericPad extends Gamepad {
  12926. private _buttons;
  12927. private _onbuttondown;
  12928. private _onbuttonup;
  12929. /**
  12930. * Observable triggered when a button has been pressed
  12931. */
  12932. onButtonDownObservable: Observable<number>;
  12933. /**
  12934. * Observable triggered when a button has been released
  12935. */
  12936. onButtonUpObservable: Observable<number>;
  12937. /**
  12938. * Callback triggered when a button has been pressed
  12939. * @param callback Called when a button has been pressed
  12940. */
  12941. onbuttondown(callback: (buttonPressed: number) => void): void;
  12942. /**
  12943. * Callback triggered when a button has been released
  12944. * @param callback Called when a button has been released
  12945. */
  12946. onbuttonup(callback: (buttonReleased: number) => void): void;
  12947. /**
  12948. * Initializes the generic gamepad
  12949. * @param id The id of the generic gamepad
  12950. * @param index The index of the generic gamepad
  12951. * @param browserGamepad The browser gamepad
  12952. */
  12953. constructor(id: string, index: number, browserGamepad: any);
  12954. private _setButtonValue;
  12955. /**
  12956. * Updates the generic gamepad
  12957. */
  12958. update(): void;
  12959. /**
  12960. * Disposes the generic gamepad
  12961. */
  12962. dispose(): void;
  12963. }
  12964. }
  12965. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12966. import { Observable } from "babylonjs/Misc/observable";
  12967. import { Nullable } from "babylonjs/types";
  12968. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12971. import { Ray } from "babylonjs/Culling/ray";
  12972. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12973. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12974. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12975. /**
  12976. * Defines the types of pose enabled controllers that are supported
  12977. */
  12978. export enum PoseEnabledControllerType {
  12979. /**
  12980. * HTC Vive
  12981. */
  12982. VIVE = 0,
  12983. /**
  12984. * Oculus Rift
  12985. */
  12986. OCULUS = 1,
  12987. /**
  12988. * Windows mixed reality
  12989. */
  12990. WINDOWS = 2,
  12991. /**
  12992. * Samsung gear VR
  12993. */
  12994. GEAR_VR = 3,
  12995. /**
  12996. * Google Daydream
  12997. */
  12998. DAYDREAM = 4,
  12999. /**
  13000. * Generic
  13001. */
  13002. GENERIC = 5
  13003. }
  13004. /**
  13005. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13006. */
  13007. export interface MutableGamepadButton {
  13008. /**
  13009. * Value of the button/trigger
  13010. */
  13011. value: number;
  13012. /**
  13013. * If the button/trigger is currently touched
  13014. */
  13015. touched: boolean;
  13016. /**
  13017. * If the button/trigger is currently pressed
  13018. */
  13019. pressed: boolean;
  13020. }
  13021. /**
  13022. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13023. * @hidden
  13024. */
  13025. export interface ExtendedGamepadButton extends GamepadButton {
  13026. /**
  13027. * If the button/trigger is currently pressed
  13028. */
  13029. readonly pressed: boolean;
  13030. /**
  13031. * If the button/trigger is currently touched
  13032. */
  13033. readonly touched: boolean;
  13034. /**
  13035. * Value of the button/trigger
  13036. */
  13037. readonly value: number;
  13038. }
  13039. /** @hidden */
  13040. export interface _GamePadFactory {
  13041. /**
  13042. * Returns wether or not the current gamepad can be created for this type of controller.
  13043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13044. * @returns true if it can be created, otherwise false
  13045. */
  13046. canCreate(gamepadInfo: any): boolean;
  13047. /**
  13048. * Creates a new instance of the Gamepad.
  13049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13050. * @returns the new gamepad instance
  13051. */
  13052. create(gamepadInfo: any): Gamepad;
  13053. }
  13054. /**
  13055. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13056. */
  13057. export class PoseEnabledControllerHelper {
  13058. /** @hidden */
  13059. static _ControllerFactories: _GamePadFactory[];
  13060. /** @hidden */
  13061. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13062. /**
  13063. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13064. * @param vrGamepad the gamepad to initialized
  13065. * @returns a vr controller of the type the gamepad identified as
  13066. */
  13067. static InitiateController(vrGamepad: any): Gamepad;
  13068. }
  13069. /**
  13070. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13071. */
  13072. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13073. private _deviceRoomPosition;
  13074. private _deviceRoomRotationQuaternion;
  13075. /**
  13076. * The device position in babylon space
  13077. */
  13078. devicePosition: Vector3;
  13079. /**
  13080. * The device rotation in babylon space
  13081. */
  13082. deviceRotationQuaternion: Quaternion;
  13083. /**
  13084. * The scale factor of the device in babylon space
  13085. */
  13086. deviceScaleFactor: number;
  13087. /**
  13088. * (Likely devicePosition should be used instead) The device position in its room space
  13089. */
  13090. position: Vector3;
  13091. /**
  13092. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13093. */
  13094. rotationQuaternion: Quaternion;
  13095. /**
  13096. * The type of controller (Eg. Windows mixed reality)
  13097. */
  13098. controllerType: PoseEnabledControllerType;
  13099. protected _calculatedPosition: Vector3;
  13100. private _calculatedRotation;
  13101. /**
  13102. * The raw pose from the device
  13103. */
  13104. rawPose: DevicePose;
  13105. private _trackPosition;
  13106. private _maxRotationDistFromHeadset;
  13107. private _draggedRoomRotation;
  13108. /**
  13109. * @hidden
  13110. */
  13111. _disableTrackPosition(fixedPosition: Vector3): void;
  13112. /**
  13113. * Internal, the mesh attached to the controller
  13114. * @hidden
  13115. */
  13116. _mesh: Nullable<AbstractMesh>;
  13117. private _poseControlledCamera;
  13118. private _leftHandSystemQuaternion;
  13119. /**
  13120. * Internal, matrix used to convert room space to babylon space
  13121. * @hidden
  13122. */
  13123. _deviceToWorld: Matrix;
  13124. /**
  13125. * Node to be used when casting a ray from the controller
  13126. * @hidden
  13127. */
  13128. _pointingPoseNode: Nullable<TransformNode>;
  13129. /**
  13130. * Name of the child mesh that can be used to cast a ray from the controller
  13131. */
  13132. static readonly POINTING_POSE: string;
  13133. /**
  13134. * Creates a new PoseEnabledController from a gamepad
  13135. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13136. */
  13137. constructor(browserGamepad: any);
  13138. private _workingMatrix;
  13139. /**
  13140. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13141. */
  13142. update(): void;
  13143. /**
  13144. * Updates only the pose device and mesh without doing any button event checking
  13145. */
  13146. protected _updatePoseAndMesh(): void;
  13147. /**
  13148. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13149. * @param poseData raw pose fromthe device
  13150. */
  13151. updateFromDevice(poseData: DevicePose): void;
  13152. /**
  13153. * @hidden
  13154. */
  13155. _meshAttachedObservable: Observable<AbstractMesh>;
  13156. /**
  13157. * Attaches a mesh to the controller
  13158. * @param mesh the mesh to be attached
  13159. */
  13160. attachToMesh(mesh: AbstractMesh): void;
  13161. /**
  13162. * Attaches the controllers mesh to a camera
  13163. * @param camera the camera the mesh should be attached to
  13164. */
  13165. attachToPoseControlledCamera(camera: TargetCamera): void;
  13166. /**
  13167. * Disposes of the controller
  13168. */
  13169. dispose(): void;
  13170. /**
  13171. * The mesh that is attached to the controller
  13172. */
  13173. readonly mesh: Nullable<AbstractMesh>;
  13174. /**
  13175. * Gets the ray of the controller in the direction the controller is pointing
  13176. * @param length the length the resulting ray should be
  13177. * @returns a ray in the direction the controller is pointing
  13178. */
  13179. getForwardRay(length?: number): Ray;
  13180. }
  13181. }
  13182. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13183. import { Observable } from "babylonjs/Misc/observable";
  13184. import { Scene } from "babylonjs/scene";
  13185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13186. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13187. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13188. /**
  13189. * Defines the WebVRController object that represents controllers tracked in 3D space
  13190. */
  13191. export abstract class WebVRController extends PoseEnabledController {
  13192. /**
  13193. * Internal, the default controller model for the controller
  13194. */
  13195. protected _defaultModel: AbstractMesh;
  13196. /**
  13197. * Fired when the trigger state has changed
  13198. */
  13199. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13200. /**
  13201. * Fired when the main button state has changed
  13202. */
  13203. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13204. /**
  13205. * Fired when the secondary button state has changed
  13206. */
  13207. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13208. /**
  13209. * Fired when the pad state has changed
  13210. */
  13211. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13212. /**
  13213. * Fired when controllers stick values have changed
  13214. */
  13215. onPadValuesChangedObservable: Observable<StickValues>;
  13216. /**
  13217. * Array of button availible on the controller
  13218. */
  13219. protected _buttons: Array<MutableGamepadButton>;
  13220. private _onButtonStateChange;
  13221. /**
  13222. * Fired when a controller button's state has changed
  13223. * @param callback the callback containing the button that was modified
  13224. */
  13225. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13226. /**
  13227. * X and Y axis corrisponding to the controllers joystick
  13228. */
  13229. pad: StickValues;
  13230. /**
  13231. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13232. */
  13233. hand: string;
  13234. /**
  13235. * The default controller model for the controller
  13236. */
  13237. readonly defaultModel: AbstractMesh;
  13238. /**
  13239. * Creates a new WebVRController from a gamepad
  13240. * @param vrGamepad the gamepad that the WebVRController should be created from
  13241. */
  13242. constructor(vrGamepad: any);
  13243. /**
  13244. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13245. */
  13246. update(): void;
  13247. /**
  13248. * Function to be called when a button is modified
  13249. */
  13250. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13251. /**
  13252. * Loads a mesh and attaches it to the controller
  13253. * @param scene the scene the mesh should be added to
  13254. * @param meshLoaded callback for when the mesh has been loaded
  13255. */
  13256. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13257. private _setButtonValue;
  13258. private _changes;
  13259. private _checkChanges;
  13260. /**
  13261. * Disposes of th webVRCOntroller
  13262. */
  13263. dispose(): void;
  13264. }
  13265. }
  13266. declare module "babylonjs/Lights/hemisphericLight" {
  13267. import { Nullable } from "babylonjs/types";
  13268. import { Scene } from "babylonjs/scene";
  13269. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13270. import { Effect } from "babylonjs/Materials/effect";
  13271. import { Light } from "babylonjs/Lights/light";
  13272. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13273. /**
  13274. * The HemisphericLight simulates the ambient environment light,
  13275. * so the passed direction is the light reflection direction, not the incoming direction.
  13276. */
  13277. export class HemisphericLight extends Light {
  13278. /**
  13279. * The groundColor is the light in the opposite direction to the one specified during creation.
  13280. * 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.
  13281. */
  13282. groundColor: Color3;
  13283. /**
  13284. * The light reflection direction, not the incoming direction.
  13285. */
  13286. direction: Vector3;
  13287. /**
  13288. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13289. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13290. * The HemisphericLight can't cast shadows.
  13291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13292. * @param name The friendly name of the light
  13293. * @param direction The direction of the light reflection
  13294. * @param scene The scene the light belongs to
  13295. */
  13296. constructor(name: string, direction: Vector3, scene: Scene);
  13297. protected _buildUniformLayout(): void;
  13298. /**
  13299. * Returns the string "HemisphericLight".
  13300. * @return The class name
  13301. */
  13302. getClassName(): string;
  13303. /**
  13304. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13305. * Returns the updated direction.
  13306. * @param target The target the direction should point to
  13307. * @return The computed direction
  13308. */
  13309. setDirectionToTarget(target: Vector3): Vector3;
  13310. /**
  13311. * Returns the shadow generator associated to the light.
  13312. * @returns Always null for hemispheric lights because it does not support shadows.
  13313. */
  13314. getShadowGenerator(): Nullable<IShadowGenerator>;
  13315. /**
  13316. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13317. * @param effect The effect to update
  13318. * @param lightIndex The index of the light in the effect to update
  13319. * @returns The hemispheric light
  13320. */
  13321. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13322. /**
  13323. * Computes the world matrix of the node
  13324. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13325. * @param useWasUpdatedFlag defines a reserved property
  13326. * @returns the world matrix
  13327. */
  13328. computeWorldMatrix(): Matrix;
  13329. /**
  13330. * Returns the integer 3.
  13331. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13332. */
  13333. getTypeID(): number;
  13334. /**
  13335. * Prepares the list of defines specific to the light type.
  13336. * @param defines the list of defines
  13337. * @param lightIndex defines the index of the light for the effect
  13338. */
  13339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13340. }
  13341. }
  13342. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13343. /** @hidden */
  13344. export var vrMultiviewToSingleviewPixelShader: {
  13345. name: string;
  13346. shader: string;
  13347. };
  13348. }
  13349. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13351. import { Scene } from "babylonjs/scene";
  13352. /**
  13353. * Renders to multiple views with a single draw call
  13354. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13355. */
  13356. export class MultiviewRenderTarget extends RenderTargetTexture {
  13357. /**
  13358. * Creates a multiview render target
  13359. * @param scene scene used with the render target
  13360. * @param size the size of the render target (used for each view)
  13361. */
  13362. constructor(scene: Scene, size?: number | {
  13363. width: number;
  13364. height: number;
  13365. } | {
  13366. ratio: number;
  13367. });
  13368. /**
  13369. * @hidden
  13370. * @param faceIndex the face index, if its a cube texture
  13371. */
  13372. _bindFrameBuffer(faceIndex?: number): void;
  13373. /**
  13374. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13375. * @returns the view count
  13376. */
  13377. getViewCount(): number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13381. import { Camera } from "babylonjs/Cameras/camera";
  13382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13385. import { Matrix } from "babylonjs/Maths/math";
  13386. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13387. module "babylonjs/Engines/engine" {
  13388. interface Engine {
  13389. /**
  13390. * Creates a new multiview render target
  13391. * @param width defines the width of the texture
  13392. * @param height defines the height of the texture
  13393. * @returns the created multiview texture
  13394. */
  13395. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13396. /**
  13397. * Binds a multiview framebuffer to be drawn to
  13398. * @param multiviewTexture texture to bind
  13399. */
  13400. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13401. }
  13402. }
  13403. module "babylonjs/Cameras/camera" {
  13404. interface Camera {
  13405. /**
  13406. * @hidden
  13407. * 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)
  13408. */
  13409. _useMultiviewToSingleView: boolean;
  13410. /**
  13411. * @hidden
  13412. * 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)
  13413. */
  13414. _multiviewTexture: Nullable<RenderTargetTexture>;
  13415. /**
  13416. * @hidden
  13417. * ensures the multiview texture of the camera exists and has the specified width/height
  13418. * @param width height to set on the multiview texture
  13419. * @param height width to set on the multiview texture
  13420. */
  13421. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13422. }
  13423. }
  13424. module "babylonjs/scene" {
  13425. interface Scene {
  13426. /** @hidden */
  13427. _transformMatrixR: Matrix;
  13428. /** @hidden */
  13429. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13430. /** @hidden */
  13431. _createMultiviewUbo(): void;
  13432. /** @hidden */
  13433. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13434. /** @hidden */
  13435. _renderMultiviewToSingleView(camera: Camera): void;
  13436. }
  13437. }
  13438. }
  13439. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13440. import { Camera } from "babylonjs/Cameras/camera";
  13441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13442. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13443. import "babylonjs/Engines/Extensions/engine.multiview";
  13444. /**
  13445. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13446. * This will not be used for webXR as it supports displaying texture arrays directly
  13447. */
  13448. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13449. /**
  13450. * Initializes a VRMultiviewToSingleview
  13451. * @param name name of the post process
  13452. * @param camera camera to be applied to
  13453. * @param scaleFactor scaling factor to the size of the output texture
  13454. */
  13455. constructor(name: string, camera: Camera, scaleFactor: number);
  13456. }
  13457. }
  13458. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13459. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Size } from "babylonjs/Maths/math";
  13462. import { Observable } from "babylonjs/Misc/observable";
  13463. module "babylonjs/Engines/engine" {
  13464. /**
  13465. * Defines the interface used by display changed events
  13466. */
  13467. interface IDisplayChangedEventArgs {
  13468. /** Gets the vrDisplay object (if any) */
  13469. vrDisplay: Nullable<any>;
  13470. /** Gets a boolean indicating if webVR is supported */
  13471. vrSupported: boolean;
  13472. }
  13473. interface Engine {
  13474. /** @hidden */
  13475. _vrDisplay: any;
  13476. /** @hidden */
  13477. _vrSupported: boolean;
  13478. /** @hidden */
  13479. _oldSize: Size;
  13480. /** @hidden */
  13481. _oldHardwareScaleFactor: number;
  13482. /** @hidden */
  13483. _vrExclusivePointerMode: boolean;
  13484. /** @hidden */
  13485. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13486. /** @hidden */
  13487. _onVRDisplayPointerRestricted: () => void;
  13488. /** @hidden */
  13489. _onVRDisplayPointerUnrestricted: () => void;
  13490. /** @hidden */
  13491. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13492. /** @hidden */
  13493. _onVrDisplayDisconnect: Nullable<() => void>;
  13494. /** @hidden */
  13495. _onVrDisplayPresentChange: Nullable<() => void>;
  13496. /**
  13497. * Observable signaled when VR display mode changes
  13498. */
  13499. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13500. /**
  13501. * Observable signaled when VR request present is complete
  13502. */
  13503. onVRRequestPresentComplete: Observable<boolean>;
  13504. /**
  13505. * Observable signaled when VR request present starts
  13506. */
  13507. onVRRequestPresentStart: Observable<Engine>;
  13508. /**
  13509. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13510. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13511. */
  13512. isInVRExclusivePointerMode: boolean;
  13513. /**
  13514. * Gets a boolean indicating if a webVR device was detected
  13515. * @returns true if a webVR device was detected
  13516. */
  13517. isVRDevicePresent(): boolean;
  13518. /**
  13519. * Gets the current webVR device
  13520. * @returns the current webVR device (or null)
  13521. */
  13522. getVRDevice(): any;
  13523. /**
  13524. * Initializes a webVR display and starts listening to display change events
  13525. * The onVRDisplayChangedObservable will be notified upon these changes
  13526. * @returns A promise containing a VRDisplay and if vr is supported
  13527. */
  13528. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13529. /** @hidden */
  13530. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13531. /**
  13532. * Call this function to switch to webVR mode
  13533. * Will do nothing if webVR is not supported or if there is no webVR device
  13534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13535. */
  13536. enableVR(): void;
  13537. /** @hidden */
  13538. _onVRFullScreenTriggered(): void;
  13539. }
  13540. }
  13541. }
  13542. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13543. import { Nullable } from "babylonjs/types";
  13544. import { Observable } from "babylonjs/Misc/observable";
  13545. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13546. import { Scene } from "babylonjs/scene";
  13547. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13549. import { Node } from "babylonjs/node";
  13550. import { Ray } from "babylonjs/Culling/ray";
  13551. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13552. import "babylonjs/Engines/Extensions/engine.webVR";
  13553. /**
  13554. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13555. * IMPORTANT!! The data is right-hand data.
  13556. * @export
  13557. * @interface DevicePose
  13558. */
  13559. export interface DevicePose {
  13560. /**
  13561. * The position of the device, values in array are [x,y,z].
  13562. */
  13563. readonly position: Nullable<Float32Array>;
  13564. /**
  13565. * The linearVelocity of the device, values in array are [x,y,z].
  13566. */
  13567. readonly linearVelocity: Nullable<Float32Array>;
  13568. /**
  13569. * The linearAcceleration of the device, values in array are [x,y,z].
  13570. */
  13571. readonly linearAcceleration: Nullable<Float32Array>;
  13572. /**
  13573. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13574. */
  13575. readonly orientation: Nullable<Float32Array>;
  13576. /**
  13577. * The angularVelocity of the device, values in array are [x,y,z].
  13578. */
  13579. readonly angularVelocity: Nullable<Float32Array>;
  13580. /**
  13581. * The angularAcceleration of the device, values in array are [x,y,z].
  13582. */
  13583. readonly angularAcceleration: Nullable<Float32Array>;
  13584. }
  13585. /**
  13586. * Interface representing a pose controlled object in Babylon.
  13587. * A pose controlled object has both regular pose values as well as pose values
  13588. * from an external device such as a VR head mounted display
  13589. */
  13590. export interface PoseControlled {
  13591. /**
  13592. * The position of the object in babylon space.
  13593. */
  13594. position: Vector3;
  13595. /**
  13596. * The rotation quaternion of the object in babylon space.
  13597. */
  13598. rotationQuaternion: Quaternion;
  13599. /**
  13600. * The position of the device in babylon space.
  13601. */
  13602. devicePosition?: Vector3;
  13603. /**
  13604. * The rotation quaternion of the device in babylon space.
  13605. */
  13606. deviceRotationQuaternion: Quaternion;
  13607. /**
  13608. * The raw pose coming from the device.
  13609. */
  13610. rawPose: Nullable<DevicePose>;
  13611. /**
  13612. * The scale of the device to be used when translating from device space to babylon space.
  13613. */
  13614. deviceScaleFactor: number;
  13615. /**
  13616. * Updates the poseControlled values based on the input device pose.
  13617. * @param poseData the pose data to update the object with
  13618. */
  13619. updateFromDevice(poseData: DevicePose): void;
  13620. }
  13621. /**
  13622. * Set of options to customize the webVRCamera
  13623. */
  13624. export interface WebVROptions {
  13625. /**
  13626. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13627. */
  13628. trackPosition?: boolean;
  13629. /**
  13630. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13631. */
  13632. positionScale?: number;
  13633. /**
  13634. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13635. */
  13636. displayName?: string;
  13637. /**
  13638. * Should the native controller meshes be initialized. (default: true)
  13639. */
  13640. controllerMeshes?: boolean;
  13641. /**
  13642. * Creating a default HemiLight only on controllers. (default: true)
  13643. */
  13644. defaultLightingOnControllers?: boolean;
  13645. /**
  13646. * If you don't want to use the default VR button of the helper. (default: false)
  13647. */
  13648. useCustomVRButton?: boolean;
  13649. /**
  13650. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13651. */
  13652. customVRButton?: HTMLButtonElement;
  13653. /**
  13654. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13655. */
  13656. rayLength?: number;
  13657. /**
  13658. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13659. */
  13660. defaultHeight?: number;
  13661. /**
  13662. * If multiview should be used if availible (default: false)
  13663. */
  13664. useMultiview?: boolean;
  13665. }
  13666. /**
  13667. * This represents a WebVR camera.
  13668. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13669. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13670. */
  13671. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13672. private webVROptions;
  13673. /**
  13674. * @hidden
  13675. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13676. */
  13677. _vrDevice: any;
  13678. /**
  13679. * The rawPose of the vrDevice.
  13680. */
  13681. rawPose: Nullable<DevicePose>;
  13682. private _onVREnabled;
  13683. private _specsVersion;
  13684. private _attached;
  13685. private _frameData;
  13686. protected _descendants: Array<Node>;
  13687. private _deviceRoomPosition;
  13688. /** @hidden */
  13689. _deviceRoomRotationQuaternion: Quaternion;
  13690. private _standingMatrix;
  13691. /**
  13692. * Represents device position in babylon space.
  13693. */
  13694. devicePosition: Vector3;
  13695. /**
  13696. * Represents device rotation in babylon space.
  13697. */
  13698. deviceRotationQuaternion: Quaternion;
  13699. /**
  13700. * The scale of the device to be used when translating from device space to babylon space.
  13701. */
  13702. deviceScaleFactor: number;
  13703. private _deviceToWorld;
  13704. private _worldToDevice;
  13705. /**
  13706. * References to the webVR controllers for the vrDevice.
  13707. */
  13708. controllers: Array<WebVRController>;
  13709. /**
  13710. * Emits an event when a controller is attached.
  13711. */
  13712. onControllersAttachedObservable: Observable<WebVRController[]>;
  13713. /**
  13714. * Emits an event when a controller's mesh has been loaded;
  13715. */
  13716. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13717. /**
  13718. * Emits an event when the HMD's pose has been updated.
  13719. */
  13720. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13721. private _poseSet;
  13722. /**
  13723. * If the rig cameras be used as parent instead of this camera.
  13724. */
  13725. rigParenting: boolean;
  13726. private _lightOnControllers;
  13727. private _defaultHeight?;
  13728. /**
  13729. * Instantiates a WebVRFreeCamera.
  13730. * @param name The name of the WebVRFreeCamera
  13731. * @param position The starting anchor position for the camera
  13732. * @param scene The scene the camera belongs to
  13733. * @param webVROptions a set of customizable options for the webVRCamera
  13734. */
  13735. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13736. /**
  13737. * Gets the device distance from the ground in meters.
  13738. * @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.
  13739. */
  13740. deviceDistanceToRoomGround(): number;
  13741. /**
  13742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13743. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13744. */
  13745. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13746. /**
  13747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13748. * @returns A promise with a boolean set to if the standing matrix is supported.
  13749. */
  13750. useStandingMatrixAsync(): Promise<boolean>;
  13751. /**
  13752. * Disposes the camera
  13753. */
  13754. dispose(): void;
  13755. /**
  13756. * Gets a vrController by name.
  13757. * @param name The name of the controller to retreive
  13758. * @returns the controller matching the name specified or null if not found
  13759. */
  13760. getControllerByName(name: string): Nullable<WebVRController>;
  13761. private _leftController;
  13762. /**
  13763. * The controller corrisponding to the users left hand.
  13764. */
  13765. readonly leftController: Nullable<WebVRController>;
  13766. private _rightController;
  13767. /**
  13768. * The controller corrisponding to the users right hand.
  13769. */
  13770. readonly rightController: Nullable<WebVRController>;
  13771. /**
  13772. * Casts a ray forward from the vrCamera's gaze.
  13773. * @param length Length of the ray (default: 100)
  13774. * @returns the ray corrisponding to the gaze
  13775. */
  13776. getForwardRay(length?: number): Ray;
  13777. /**
  13778. * @hidden
  13779. * Updates the camera based on device's frame data
  13780. */
  13781. _checkInputs(): void;
  13782. /**
  13783. * Updates the poseControlled values based on the input device pose.
  13784. * @param poseData Pose coming from the device
  13785. */
  13786. updateFromDevice(poseData: DevicePose): void;
  13787. private _htmlElementAttached;
  13788. private _detachIfAttached;
  13789. /**
  13790. * WebVR's attach control will start broadcasting frames to the device.
  13791. * Note that in certain browsers (chrome for example) this function must be called
  13792. * within a user-interaction callback. Example:
  13793. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13794. *
  13795. * @param element html element to attach the vrDevice to
  13796. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13797. */
  13798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13799. /**
  13800. * Detaches the camera from the html element and disables VR
  13801. *
  13802. * @param element html element to detach from
  13803. */
  13804. detachControl(element: HTMLElement): void;
  13805. /**
  13806. * @returns the name of this class
  13807. */
  13808. getClassName(): string;
  13809. /**
  13810. * Calls resetPose on the vrDisplay
  13811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13812. */
  13813. resetToCurrentRotation(): void;
  13814. /**
  13815. * @hidden
  13816. * Updates the rig cameras (left and right eye)
  13817. */
  13818. _updateRigCameras(): void;
  13819. private _workingVector;
  13820. private _oneVector;
  13821. private _workingMatrix;
  13822. private updateCacheCalled;
  13823. private _correctPositionIfNotTrackPosition;
  13824. /**
  13825. * @hidden
  13826. * Updates the cached values of the camera
  13827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13828. */
  13829. _updateCache(ignoreParentClass?: boolean): void;
  13830. /**
  13831. * @hidden
  13832. * Get current device position in babylon world
  13833. */
  13834. _computeDevicePosition(): void;
  13835. /**
  13836. * Updates the current device position and rotation in the babylon world
  13837. */
  13838. update(): void;
  13839. /**
  13840. * @hidden
  13841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13842. * @returns an identity matrix
  13843. */
  13844. _getViewMatrix(): Matrix;
  13845. private _tmpMatrix;
  13846. /**
  13847. * This function is called by the two RIG cameras.
  13848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13849. * @hidden
  13850. */
  13851. _getWebVRViewMatrix(): Matrix;
  13852. /** @hidden */
  13853. _getWebVRProjectionMatrix(): Matrix;
  13854. private _onGamepadConnectedObserver;
  13855. private _onGamepadDisconnectedObserver;
  13856. private _updateCacheWhenTrackingDisabledObserver;
  13857. /**
  13858. * Initializes the controllers and their meshes
  13859. */
  13860. initControllers(): void;
  13861. }
  13862. }
  13863. declare module "babylonjs/PostProcesses/postProcess" {
  13864. import { Nullable } from "babylonjs/types";
  13865. import { SmartArray } from "babylonjs/Misc/smartArray";
  13866. import { Observable } from "babylonjs/Misc/observable";
  13867. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13868. import { Camera } from "babylonjs/Cameras/camera";
  13869. import { Effect } from "babylonjs/Materials/effect";
  13870. import "babylonjs/Shaders/postprocess.vertex";
  13871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13872. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13873. import { Engine } from "babylonjs/Engines/engine";
  13874. /**
  13875. * Size options for a post process
  13876. */
  13877. export type PostProcessOptions = {
  13878. width: number;
  13879. height: number;
  13880. };
  13881. /**
  13882. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13883. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13884. */
  13885. export class PostProcess {
  13886. /** Name of the PostProcess. */
  13887. name: string;
  13888. /**
  13889. * Gets or sets the unique id of the post process
  13890. */
  13891. uniqueId: number;
  13892. /**
  13893. * Width of the texture to apply the post process on
  13894. */
  13895. width: number;
  13896. /**
  13897. * Height of the texture to apply the post process on
  13898. */
  13899. height: number;
  13900. /**
  13901. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13902. * @hidden
  13903. */
  13904. _outputTexture: Nullable<InternalTexture>;
  13905. /**
  13906. * Sampling mode used by the shader
  13907. * See https://doc.babylonjs.com/classes/3.1/texture
  13908. */
  13909. renderTargetSamplingMode: number;
  13910. /**
  13911. * Clear color to use when screen clearing
  13912. */
  13913. clearColor: Color4;
  13914. /**
  13915. * If the buffer needs to be cleared before applying the post process. (default: true)
  13916. * Should be set to false if shader will overwrite all previous pixels.
  13917. */
  13918. autoClear: boolean;
  13919. /**
  13920. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13921. */
  13922. alphaMode: number;
  13923. /**
  13924. * Sets the setAlphaBlendConstants of the babylon engine
  13925. */
  13926. alphaConstants: Color4;
  13927. /**
  13928. * Animations to be used for the post processing
  13929. */
  13930. animations: import("babylonjs/Animations/animation").Animation[];
  13931. /**
  13932. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13933. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13934. */
  13935. enablePixelPerfectMode: boolean;
  13936. /**
  13937. * Force the postprocess to be applied without taking in account viewport
  13938. */
  13939. forceFullscreenViewport: boolean;
  13940. /**
  13941. * List of inspectable custom properties (used by the Inspector)
  13942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13943. */
  13944. inspectableCustomProperties: IInspectable[];
  13945. /**
  13946. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13947. *
  13948. * | Value | Type | Description |
  13949. * | ----- | ----------------------------------- | ----------- |
  13950. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13951. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13952. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13953. *
  13954. */
  13955. scaleMode: number;
  13956. /**
  13957. * Force textures to be a power of two (default: false)
  13958. */
  13959. alwaysForcePOT: boolean;
  13960. private _samples;
  13961. /**
  13962. * Number of sample textures (default: 1)
  13963. */
  13964. samples: number;
  13965. /**
  13966. * Modify the scale of the post process to be the same as the viewport (default: false)
  13967. */
  13968. adaptScaleToCurrentViewport: boolean;
  13969. private _camera;
  13970. private _scene;
  13971. private _engine;
  13972. private _options;
  13973. private _reusable;
  13974. private _textureType;
  13975. /**
  13976. * Smart array of input and output textures for the post process.
  13977. * @hidden
  13978. */
  13979. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13980. /**
  13981. * The index in _textures that corresponds to the output texture.
  13982. * @hidden
  13983. */
  13984. _currentRenderTextureInd: number;
  13985. private _effect;
  13986. private _samplers;
  13987. private _fragmentUrl;
  13988. private _vertexUrl;
  13989. private _parameters;
  13990. private _scaleRatio;
  13991. protected _indexParameters: any;
  13992. private _shareOutputWithPostProcess;
  13993. private _texelSize;
  13994. private _forcedOutputTexture;
  13995. /**
  13996. * Returns the fragment url or shader name used in the post process.
  13997. * @returns the fragment url or name in the shader store.
  13998. */
  13999. getEffectName(): string;
  14000. /**
  14001. * An event triggered when the postprocess is activated.
  14002. */
  14003. onActivateObservable: Observable<Camera>;
  14004. private _onActivateObserver;
  14005. /**
  14006. * A function that is added to the onActivateObservable
  14007. */
  14008. onActivate: Nullable<(camera: Camera) => void>;
  14009. /**
  14010. * An event triggered when the postprocess changes its size.
  14011. */
  14012. onSizeChangedObservable: Observable<PostProcess>;
  14013. private _onSizeChangedObserver;
  14014. /**
  14015. * A function that is added to the onSizeChangedObservable
  14016. */
  14017. onSizeChanged: (postProcess: PostProcess) => void;
  14018. /**
  14019. * An event triggered when the postprocess applies its effect.
  14020. */
  14021. onApplyObservable: Observable<Effect>;
  14022. private _onApplyObserver;
  14023. /**
  14024. * A function that is added to the onApplyObservable
  14025. */
  14026. onApply: (effect: Effect) => void;
  14027. /**
  14028. * An event triggered before rendering the postprocess
  14029. */
  14030. onBeforeRenderObservable: Observable<Effect>;
  14031. private _onBeforeRenderObserver;
  14032. /**
  14033. * A function that is added to the onBeforeRenderObservable
  14034. */
  14035. onBeforeRender: (effect: Effect) => void;
  14036. /**
  14037. * An event triggered after rendering the postprocess
  14038. */
  14039. onAfterRenderObservable: Observable<Effect>;
  14040. private _onAfterRenderObserver;
  14041. /**
  14042. * A function that is added to the onAfterRenderObservable
  14043. */
  14044. onAfterRender: (efect: Effect) => void;
  14045. /**
  14046. * 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
  14047. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14048. */
  14049. inputTexture: InternalTexture;
  14050. /**
  14051. * Gets the camera which post process is applied to.
  14052. * @returns The camera the post process is applied to.
  14053. */
  14054. getCamera(): Camera;
  14055. /**
  14056. * Gets the texel size of the postprocess.
  14057. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14058. */
  14059. readonly texelSize: Vector2;
  14060. /**
  14061. * Creates a new instance PostProcess
  14062. * @param name The name of the PostProcess.
  14063. * @param fragmentUrl The url of the fragment shader to be used.
  14064. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14065. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14067. * @param camera The camera to apply the render pass to.
  14068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14069. * @param engine The engine which the post process will be applied. (default: current engine)
  14070. * @param reusable If the post process can be reused on the same frame. (default: false)
  14071. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14072. * @param textureType Type of textures used when performing the post process. (default: 0)
  14073. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14074. * @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
  14075. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14076. */
  14077. constructor(
  14078. /** Name of the PostProcess. */
  14079. 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);
  14080. /**
  14081. * Gets a string idenfifying the name of the class
  14082. * @returns "PostProcess" string
  14083. */
  14084. getClassName(): string;
  14085. /**
  14086. * Gets the engine which this post process belongs to.
  14087. * @returns The engine the post process was enabled with.
  14088. */
  14089. getEngine(): Engine;
  14090. /**
  14091. * The effect that is created when initializing the post process.
  14092. * @returns The created effect corrisponding the the postprocess.
  14093. */
  14094. getEffect(): Effect;
  14095. /**
  14096. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14097. * @param postProcess The post process to share the output with.
  14098. * @returns This post process.
  14099. */
  14100. shareOutputWith(postProcess: PostProcess): PostProcess;
  14101. /**
  14102. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14103. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14104. */
  14105. useOwnOutput(): void;
  14106. /**
  14107. * Updates the effect with the current post process compile time values and recompiles the shader.
  14108. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14109. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14110. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14111. * @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
  14112. * @param onCompiled Called when the shader has been compiled.
  14113. * @param onError Called if there is an error when compiling a shader.
  14114. */
  14115. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14116. /**
  14117. * The post process is reusable if it can be used multiple times within one frame.
  14118. * @returns If the post process is reusable
  14119. */
  14120. isReusable(): boolean;
  14121. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14122. markTextureDirty(): void;
  14123. /**
  14124. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14125. * 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.
  14126. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14127. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14128. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14129. * @returns The target texture that was bound to be written to.
  14130. */
  14131. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14132. /**
  14133. * If the post process is supported.
  14134. */
  14135. readonly isSupported: boolean;
  14136. /**
  14137. * The aspect ratio of the output texture.
  14138. */
  14139. readonly aspectRatio: number;
  14140. /**
  14141. * Get a value indicating if the post-process is ready to be used
  14142. * @returns true if the post-process is ready (shader is compiled)
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14147. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14148. */
  14149. apply(): Nullable<Effect>;
  14150. private _disposeTextures;
  14151. /**
  14152. * Disposes the post process.
  14153. * @param camera The camera to dispose the post process on.
  14154. */
  14155. dispose(camera?: Camera): void;
  14156. }
  14157. }
  14158. declare module "babylonjs/PostProcesses/postProcessManager" {
  14159. import { Nullable } from "babylonjs/types";
  14160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14162. import { Scene } from "babylonjs/scene";
  14163. /**
  14164. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14165. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14166. */
  14167. export class PostProcessManager {
  14168. private _scene;
  14169. private _indexBuffer;
  14170. private _vertexBuffers;
  14171. /**
  14172. * Creates a new instance PostProcess
  14173. * @param scene The scene that the post process is associated with.
  14174. */
  14175. constructor(scene: Scene);
  14176. private _prepareBuffers;
  14177. private _buildIndexBuffer;
  14178. /**
  14179. * Rebuilds the vertex buffers of the manager.
  14180. * @hidden
  14181. */
  14182. _rebuild(): void;
  14183. /**
  14184. * Prepares a frame to be run through a post process.
  14185. * @param sourceTexture The input texture to the post procesess. (default: null)
  14186. * @param postProcesses An array of post processes to be run. (default: null)
  14187. * @returns True if the post processes were able to be run.
  14188. * @hidden
  14189. */
  14190. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14191. /**
  14192. * Manually render a set of post processes to a texture.
  14193. * @param postProcesses An array of post processes to be run.
  14194. * @param targetTexture The target texture to render to.
  14195. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14196. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14197. * @param lodLevel defines which lod of the texture to render to
  14198. */
  14199. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14200. /**
  14201. * Finalize the result of the output of the postprocesses.
  14202. * @param doNotPresent If true the result will not be displayed to the screen.
  14203. * @param targetTexture The target texture to render to.
  14204. * @param faceIndex The index of the face to bind the target texture to.
  14205. * @param postProcesses The array of post processes to render.
  14206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14207. * @hidden
  14208. */
  14209. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14210. /**
  14211. * Disposes of the post process manager.
  14212. */
  14213. dispose(): void;
  14214. }
  14215. }
  14216. declare module "babylonjs/Layers/layerSceneComponent" {
  14217. import { Scene } from "babylonjs/scene";
  14218. import { ISceneComponent } from "babylonjs/sceneComponent";
  14219. import { Layer } from "babylonjs/Layers/layer";
  14220. module "babylonjs/abstractScene" {
  14221. interface AbstractScene {
  14222. /**
  14223. * The list of layers (background and foreground) of the scene
  14224. */
  14225. layers: Array<Layer>;
  14226. }
  14227. }
  14228. /**
  14229. * Defines the layer scene component responsible to manage any layers
  14230. * in a given scene.
  14231. */
  14232. export class LayerSceneComponent implements ISceneComponent {
  14233. /**
  14234. * The component name helpfull to identify the component in the list of scene components.
  14235. */
  14236. readonly name: string;
  14237. /**
  14238. * The scene the component belongs to.
  14239. */
  14240. scene: Scene;
  14241. private _engine;
  14242. /**
  14243. * Creates a new instance of the component for the given scene
  14244. * @param scene Defines the scene to register the component in
  14245. */
  14246. constructor(scene: Scene);
  14247. /**
  14248. * Registers the component in a given scene
  14249. */
  14250. register(): void;
  14251. /**
  14252. * Rebuilds the elements related to this component in case of
  14253. * context lost for instance.
  14254. */
  14255. rebuild(): void;
  14256. /**
  14257. * Disposes the component and the associated ressources.
  14258. */
  14259. dispose(): void;
  14260. private _draw;
  14261. private _drawCameraPredicate;
  14262. private _drawCameraBackground;
  14263. private _drawCameraForeground;
  14264. private _drawRenderTargetPredicate;
  14265. private _drawRenderTargetBackground;
  14266. private _drawRenderTargetForeground;
  14267. }
  14268. }
  14269. declare module "babylonjs/Shaders/layer.fragment" {
  14270. /** @hidden */
  14271. export var layerPixelShader: {
  14272. name: string;
  14273. shader: string;
  14274. };
  14275. }
  14276. declare module "babylonjs/Shaders/layer.vertex" {
  14277. /** @hidden */
  14278. export var layerVertexShader: {
  14279. name: string;
  14280. shader: string;
  14281. };
  14282. }
  14283. declare module "babylonjs/Layers/layer" {
  14284. import { Observable } from "babylonjs/Misc/observable";
  14285. import { Nullable } from "babylonjs/types";
  14286. import { Scene } from "babylonjs/scene";
  14287. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14288. import { Texture } from "babylonjs/Materials/Textures/texture";
  14289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14290. import "babylonjs/Shaders/layer.fragment";
  14291. import "babylonjs/Shaders/layer.vertex";
  14292. /**
  14293. * This represents a full screen 2d layer.
  14294. * This can be useful to display a picture in the background of your scene for instance.
  14295. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14296. */
  14297. export class Layer {
  14298. /**
  14299. * Define the name of the layer.
  14300. */
  14301. name: string;
  14302. /**
  14303. * Define the texture the layer should display.
  14304. */
  14305. texture: Nullable<Texture>;
  14306. /**
  14307. * Is the layer in background or foreground.
  14308. */
  14309. isBackground: boolean;
  14310. /**
  14311. * Define the color of the layer (instead of texture).
  14312. */
  14313. color: Color4;
  14314. /**
  14315. * Define the scale of the layer in order to zoom in out of the texture.
  14316. */
  14317. scale: Vector2;
  14318. /**
  14319. * Define an offset for the layer in order to shift the texture.
  14320. */
  14321. offset: Vector2;
  14322. /**
  14323. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14324. */
  14325. alphaBlendingMode: number;
  14326. /**
  14327. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14328. * Alpha test will not mix with the background color in case of transparency.
  14329. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14330. */
  14331. alphaTest: boolean;
  14332. /**
  14333. * Define a mask to restrict the layer to only some of the scene cameras.
  14334. */
  14335. layerMask: number;
  14336. /**
  14337. * Define the list of render target the layer is visible into.
  14338. */
  14339. renderTargetTextures: RenderTargetTexture[];
  14340. /**
  14341. * Define if the layer is only used in renderTarget or if it also
  14342. * renders in the main frame buffer of the canvas.
  14343. */
  14344. renderOnlyInRenderTargetTextures: boolean;
  14345. private _scene;
  14346. private _vertexBuffers;
  14347. private _indexBuffer;
  14348. private _effect;
  14349. private _alphaTestEffect;
  14350. /**
  14351. * An event triggered when the layer is disposed.
  14352. */
  14353. onDisposeObservable: Observable<Layer>;
  14354. private _onDisposeObserver;
  14355. /**
  14356. * Back compatibility with callback before the onDisposeObservable existed.
  14357. * The set callback will be triggered when the layer has been disposed.
  14358. */
  14359. onDispose: () => void;
  14360. /**
  14361. * An event triggered before rendering the scene
  14362. */
  14363. onBeforeRenderObservable: Observable<Layer>;
  14364. private _onBeforeRenderObserver;
  14365. /**
  14366. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14367. * The set callback will be triggered just before rendering the layer.
  14368. */
  14369. onBeforeRender: () => void;
  14370. /**
  14371. * An event triggered after rendering the scene
  14372. */
  14373. onAfterRenderObservable: Observable<Layer>;
  14374. private _onAfterRenderObserver;
  14375. /**
  14376. * Back compatibility with callback before the onAfterRenderObservable existed.
  14377. * The set callback will be triggered just after rendering the layer.
  14378. */
  14379. onAfterRender: () => void;
  14380. /**
  14381. * Instantiates a new layer.
  14382. * This represents a full screen 2d layer.
  14383. * This can be useful to display a picture in the background of your scene for instance.
  14384. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14385. * @param name Define the name of the layer in the scene
  14386. * @param imgUrl Define the url of the texture to display in the layer
  14387. * @param scene Define the scene the layer belongs to
  14388. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14389. * @param color Defines a color for the layer
  14390. */
  14391. constructor(
  14392. /**
  14393. * Define the name of the layer.
  14394. */
  14395. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14396. private _createIndexBuffer;
  14397. /** @hidden */
  14398. _rebuild(): void;
  14399. /**
  14400. * Renders the layer in the scene.
  14401. */
  14402. render(): void;
  14403. /**
  14404. * Disposes and releases the associated ressources.
  14405. */
  14406. dispose(): void;
  14407. }
  14408. }
  14409. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14410. import { Scene } from "babylonjs/scene";
  14411. import { ISceneComponent } from "babylonjs/sceneComponent";
  14412. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14413. module "babylonjs/abstractScene" {
  14414. interface AbstractScene {
  14415. /**
  14416. * The list of procedural textures added to the scene
  14417. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14418. */
  14419. proceduralTextures: Array<ProceduralTexture>;
  14420. }
  14421. }
  14422. /**
  14423. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14424. * in a given scene.
  14425. */
  14426. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14427. /**
  14428. * The component name helpfull to identify the component in the list of scene components.
  14429. */
  14430. readonly name: string;
  14431. /**
  14432. * The scene the component belongs to.
  14433. */
  14434. scene: Scene;
  14435. /**
  14436. * Creates a new instance of the component for the given scene
  14437. * @param scene Defines the scene to register the component in
  14438. */
  14439. constructor(scene: Scene);
  14440. /**
  14441. * Registers the component in a given scene
  14442. */
  14443. register(): void;
  14444. /**
  14445. * Rebuilds the elements related to this component in case of
  14446. * context lost for instance.
  14447. */
  14448. rebuild(): void;
  14449. /**
  14450. * Disposes the component and the associated ressources.
  14451. */
  14452. dispose(): void;
  14453. private _beforeClear;
  14454. }
  14455. }
  14456. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14458. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14459. module "babylonjs/Engines/engine" {
  14460. interface Engine {
  14461. /**
  14462. * Creates a new render target cube texture
  14463. * @param size defines the size of the texture
  14464. * @param options defines the options used to create the texture
  14465. * @returns a new render target cube texture stored in an InternalTexture
  14466. */
  14467. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14468. }
  14469. }
  14470. }
  14471. declare module "babylonjs/Shaders/procedural.vertex" {
  14472. /** @hidden */
  14473. export var proceduralVertexShader: {
  14474. name: string;
  14475. shader: string;
  14476. };
  14477. }
  14478. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14479. import { Observable } from "babylonjs/Misc/observable";
  14480. import { Nullable } from "babylonjs/types";
  14481. import { Scene } from "babylonjs/scene";
  14482. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14483. import { Effect } from "babylonjs/Materials/effect";
  14484. import { Texture } from "babylonjs/Materials/Textures/texture";
  14485. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14486. import "babylonjs/Shaders/procedural.vertex";
  14487. /**
  14488. * 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.
  14489. * This is the base class of any Procedural texture and contains most of the shareable code.
  14490. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14491. */
  14492. export class ProceduralTexture extends Texture {
  14493. isCube: boolean;
  14494. /**
  14495. * Define if the texture is enabled or not (disabled texture will not render)
  14496. */
  14497. isEnabled: boolean;
  14498. /**
  14499. * Define if the texture must be cleared before rendering (default is true)
  14500. */
  14501. autoClear: boolean;
  14502. /**
  14503. * Callback called when the texture is generated
  14504. */
  14505. onGenerated: () => void;
  14506. /**
  14507. * Event raised when the texture is generated
  14508. */
  14509. onGeneratedObservable: Observable<ProceduralTexture>;
  14510. /** @hidden */
  14511. _generateMipMaps: boolean;
  14512. /** @hidden **/
  14513. _effect: Effect;
  14514. /** @hidden */
  14515. _textures: {
  14516. [key: string]: Texture;
  14517. };
  14518. private _size;
  14519. private _currentRefreshId;
  14520. private _refreshRate;
  14521. private _vertexBuffers;
  14522. private _indexBuffer;
  14523. private _uniforms;
  14524. private _samplers;
  14525. private _fragment;
  14526. private _floats;
  14527. private _ints;
  14528. private _floatsArrays;
  14529. private _colors3;
  14530. private _colors4;
  14531. private _vectors2;
  14532. private _vectors3;
  14533. private _matrices;
  14534. private _fallbackTexture;
  14535. private _fallbackTextureUsed;
  14536. private _engine;
  14537. private _cachedDefines;
  14538. private _contentUpdateId;
  14539. private _contentData;
  14540. /**
  14541. * Instantiates a new procedural texture.
  14542. * 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.
  14543. * This is the base class of any Procedural texture and contains most of the shareable code.
  14544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14545. * @param name Define the name of the texture
  14546. * @param size Define the size of the texture to create
  14547. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14548. * @param scene Define the scene the texture belongs to
  14549. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14550. * @param generateMipMaps Define if the texture should creates mip maps or not
  14551. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14552. */
  14553. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14554. /**
  14555. * The effect that is created when initializing the post process.
  14556. * @returns The created effect corrisponding the the postprocess.
  14557. */
  14558. getEffect(): Effect;
  14559. /**
  14560. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14561. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14562. */
  14563. getContent(): Nullable<ArrayBufferView>;
  14564. private _createIndexBuffer;
  14565. /** @hidden */
  14566. _rebuild(): void;
  14567. /**
  14568. * Resets the texture in order to recreate its associated resources.
  14569. * This can be called in case of context loss
  14570. */
  14571. reset(): void;
  14572. protected _getDefines(): string;
  14573. /**
  14574. * Is the texture ready to be used ? (rendered at least once)
  14575. * @returns true if ready, otherwise, false.
  14576. */
  14577. isReady(): boolean;
  14578. /**
  14579. * Resets the refresh counter of the texture and start bak from scratch.
  14580. * Could be useful to regenerate the texture if it is setup to render only once.
  14581. */
  14582. resetRefreshCounter(): void;
  14583. /**
  14584. * Set the fragment shader to use in order to render the texture.
  14585. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14586. */
  14587. setFragment(fragment: any): void;
  14588. /**
  14589. * Define the refresh rate of the texture or the rendering frequency.
  14590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14591. */
  14592. refreshRate: number;
  14593. /** @hidden */
  14594. _shouldRender(): boolean;
  14595. /**
  14596. * Get the size the texture is rendering at.
  14597. * @returns the size (texture is always squared)
  14598. */
  14599. getRenderSize(): number;
  14600. /**
  14601. * Resize the texture to new value.
  14602. * @param size Define the new size the texture should have
  14603. * @param generateMipMaps Define whether the new texture should create mip maps
  14604. */
  14605. resize(size: number, generateMipMaps: boolean): void;
  14606. private _checkUniform;
  14607. /**
  14608. * Set a texture in the shader program used to render.
  14609. * @param name Define the name of the uniform samplers as defined in the shader
  14610. * @param texture Define the texture to bind to this sampler
  14611. * @return the texture itself allowing "fluent" like uniform updates
  14612. */
  14613. setTexture(name: string, texture: Texture): ProceduralTexture;
  14614. /**
  14615. * Set a float in the shader.
  14616. * @param name Define the name of the uniform as defined in the shader
  14617. * @param value Define the value to give to the uniform
  14618. * @return the texture itself allowing "fluent" like uniform updates
  14619. */
  14620. setFloat(name: string, value: number): ProceduralTexture;
  14621. /**
  14622. * Set a int in the shader.
  14623. * @param name Define the name of the uniform as defined in the shader
  14624. * @param value Define the value to give to the uniform
  14625. * @return the texture itself allowing "fluent" like uniform updates
  14626. */
  14627. setInt(name: string, value: number): ProceduralTexture;
  14628. /**
  14629. * Set an array of floats in the shader.
  14630. * @param name Define the name of the uniform as defined in the shader
  14631. * @param value Define the value to give to the uniform
  14632. * @return the texture itself allowing "fluent" like uniform updates
  14633. */
  14634. setFloats(name: string, value: number[]): ProceduralTexture;
  14635. /**
  14636. * Set a vec3 in the shader from a Color3.
  14637. * @param name Define the name of the uniform as defined in the shader
  14638. * @param value Define the value to give to the uniform
  14639. * @return the texture itself allowing "fluent" like uniform updates
  14640. */
  14641. setColor3(name: string, value: Color3): ProceduralTexture;
  14642. /**
  14643. * Set a vec4 in the shader from a Color4.
  14644. * @param name Define the name of the uniform as defined in the shader
  14645. * @param value Define the value to give to the uniform
  14646. * @return the texture itself allowing "fluent" like uniform updates
  14647. */
  14648. setColor4(name: string, value: Color4): ProceduralTexture;
  14649. /**
  14650. * Set a vec2 in the shader from a Vector2.
  14651. * @param name Define the name of the uniform as defined in the shader
  14652. * @param value Define the value to give to the uniform
  14653. * @return the texture itself allowing "fluent" like uniform updates
  14654. */
  14655. setVector2(name: string, value: Vector2): ProceduralTexture;
  14656. /**
  14657. * Set a vec3 in the shader from a Vector3.
  14658. * @param name Define the name of the uniform as defined in the shader
  14659. * @param value Define the value to give to the uniform
  14660. * @return the texture itself allowing "fluent" like uniform updates
  14661. */
  14662. setVector3(name: string, value: Vector3): ProceduralTexture;
  14663. /**
  14664. * Set a mat4 in the shader from a MAtrix.
  14665. * @param name Define the name of the uniform as defined in the shader
  14666. * @param value Define the value to give to the uniform
  14667. * @return the texture itself allowing "fluent" like uniform updates
  14668. */
  14669. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14670. /**
  14671. * Render the texture to its associated render target.
  14672. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14673. */
  14674. render(useCameraPostProcess?: boolean): void;
  14675. /**
  14676. * Clone the texture.
  14677. * @returns the cloned texture
  14678. */
  14679. clone(): ProceduralTexture;
  14680. /**
  14681. * Dispose the texture and release its asoociated resources.
  14682. */
  14683. dispose(): void;
  14684. }
  14685. }
  14686. declare module "babylonjs/Particles/baseParticleSystem" {
  14687. import { Nullable } from "babylonjs/types";
  14688. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14690. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. import { Scene } from "babylonjs/scene";
  14694. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14695. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14696. import { Texture } from "babylonjs/Materials/Textures/texture";
  14697. import { Animation } from "babylonjs/Animations/animation";
  14698. /**
  14699. * This represents the base class for particle system in Babylon.
  14700. * 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.
  14701. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14702. * @example https://doc.babylonjs.com/babylon101/particles
  14703. */
  14704. export class BaseParticleSystem {
  14705. /**
  14706. * Source color is added to the destination color without alpha affecting the result
  14707. */
  14708. static BLENDMODE_ONEONE: number;
  14709. /**
  14710. * Blend current color and particle color using particle’s alpha
  14711. */
  14712. static BLENDMODE_STANDARD: number;
  14713. /**
  14714. * Add current color and particle color multiplied by particle’s alpha
  14715. */
  14716. static BLENDMODE_ADD: number;
  14717. /**
  14718. * Multiply current color with particle color
  14719. */
  14720. static BLENDMODE_MULTIPLY: number;
  14721. /**
  14722. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14723. */
  14724. static BLENDMODE_MULTIPLYADD: number;
  14725. /**
  14726. * List of animations used by the particle system.
  14727. */
  14728. animations: Animation[];
  14729. /**
  14730. * The id of the Particle system.
  14731. */
  14732. id: string;
  14733. /**
  14734. * The friendly name of the Particle system.
  14735. */
  14736. name: string;
  14737. /**
  14738. * The rendering group used by the Particle system to chose when to render.
  14739. */
  14740. renderingGroupId: number;
  14741. /**
  14742. * The emitter represents the Mesh or position we are attaching the particle system to.
  14743. */
  14744. emitter: Nullable<AbstractMesh | Vector3>;
  14745. /**
  14746. * The maximum number of particles to emit per frame
  14747. */
  14748. emitRate: number;
  14749. /**
  14750. * If you want to launch only a few particles at once, that can be done, as well.
  14751. */
  14752. manualEmitCount: number;
  14753. /**
  14754. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14755. */
  14756. updateSpeed: number;
  14757. /**
  14758. * The amount of time the particle system is running (depends of the overall update speed).
  14759. */
  14760. targetStopDuration: number;
  14761. /**
  14762. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14763. */
  14764. disposeOnStop: boolean;
  14765. /**
  14766. * Minimum power of emitting particles.
  14767. */
  14768. minEmitPower: number;
  14769. /**
  14770. * Maximum power of emitting particles.
  14771. */
  14772. maxEmitPower: number;
  14773. /**
  14774. * Minimum life time of emitting particles.
  14775. */
  14776. minLifeTime: number;
  14777. /**
  14778. * Maximum life time of emitting particles.
  14779. */
  14780. maxLifeTime: number;
  14781. /**
  14782. * Minimum Size of emitting particles.
  14783. */
  14784. minSize: number;
  14785. /**
  14786. * Maximum Size of emitting particles.
  14787. */
  14788. maxSize: number;
  14789. /**
  14790. * Minimum scale of emitting particles on X axis.
  14791. */
  14792. minScaleX: number;
  14793. /**
  14794. * Maximum scale of emitting particles on X axis.
  14795. */
  14796. maxScaleX: number;
  14797. /**
  14798. * Minimum scale of emitting particles on Y axis.
  14799. */
  14800. minScaleY: number;
  14801. /**
  14802. * Maximum scale of emitting particles on Y axis.
  14803. */
  14804. maxScaleY: number;
  14805. /**
  14806. * Gets or sets the minimal initial rotation in radians.
  14807. */
  14808. minInitialRotation: number;
  14809. /**
  14810. * Gets or sets the maximal initial rotation in radians.
  14811. */
  14812. maxInitialRotation: number;
  14813. /**
  14814. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14815. */
  14816. minAngularSpeed: number;
  14817. /**
  14818. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14819. */
  14820. maxAngularSpeed: number;
  14821. /**
  14822. * The texture used to render each particle. (this can be a spritesheet)
  14823. */
  14824. particleTexture: Nullable<Texture>;
  14825. /**
  14826. * The layer mask we are rendering the particles through.
  14827. */
  14828. layerMask: number;
  14829. /**
  14830. * This can help using your own shader to render the particle system.
  14831. * The according effect will be created
  14832. */
  14833. customShader: any;
  14834. /**
  14835. * By default particle system starts as soon as they are created. This prevents the
  14836. * automatic start to happen and let you decide when to start emitting particles.
  14837. */
  14838. preventAutoStart: boolean;
  14839. private _noiseTexture;
  14840. /**
  14841. * Gets or sets a texture used to add random noise to particle positions
  14842. */
  14843. noiseTexture: Nullable<ProceduralTexture>;
  14844. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14845. noiseStrength: Vector3;
  14846. /**
  14847. * Callback triggered when the particle animation is ending.
  14848. */
  14849. onAnimationEnd: Nullable<() => void>;
  14850. /**
  14851. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14852. */
  14853. blendMode: number;
  14854. /**
  14855. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14856. * to override the particles.
  14857. */
  14858. forceDepthWrite: boolean;
  14859. /** 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 */
  14860. preWarmCycles: number;
  14861. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14862. preWarmStepOffset: number;
  14863. /**
  14864. * 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)
  14865. */
  14866. spriteCellChangeSpeed: number;
  14867. /**
  14868. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14869. */
  14870. startSpriteCellID: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14873. */
  14874. endSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14877. */
  14878. spriteCellWidth: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14881. */
  14882. spriteCellHeight: number;
  14883. /**
  14884. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14885. */
  14886. spriteRandomStartCell: boolean;
  14887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14888. translationPivot: Vector2;
  14889. /** @hidden */
  14890. protected _isAnimationSheetEnabled: boolean;
  14891. /**
  14892. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14893. */
  14894. beginAnimationOnStart: boolean;
  14895. /**
  14896. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14897. */
  14898. beginAnimationFrom: number;
  14899. /**
  14900. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationTo: number;
  14903. /**
  14904. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationLoop: boolean;
  14907. /**
  14908. * Gets or sets a world offset applied to all particles
  14909. */
  14910. worldOffset: Vector3;
  14911. /**
  14912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14913. */
  14914. isAnimationSheetEnabled: boolean;
  14915. /**
  14916. * Get hosting scene
  14917. * @returns the scene
  14918. */
  14919. getScene(): Scene;
  14920. /**
  14921. * You can use gravity if you want to give an orientation to your particles.
  14922. */
  14923. gravity: Vector3;
  14924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14937. /**
  14938. * Defines the delay in milliseconds before starting the system (0 by default)
  14939. */
  14940. startDelay: number;
  14941. /**
  14942. * Gets the current list of drag gradients.
  14943. * You must use addDragGradient and removeDragGradient to udpate this list
  14944. * @returns the list of drag gradients
  14945. */
  14946. getDragGradients(): Nullable<Array<FactorGradient>>;
  14947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14948. limitVelocityDamping: number;
  14949. /**
  14950. * Gets the current list of limit velocity gradients.
  14951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14952. * @returns the list of limit velocity gradients
  14953. */
  14954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Gets the current list of color gradients.
  14957. * You must use addColorGradient and removeColorGradient to udpate this list
  14958. * @returns the list of color gradients
  14959. */
  14960. getColorGradients(): Nullable<Array<ColorGradient>>;
  14961. /**
  14962. * Gets the current list of size gradients.
  14963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14964. * @returns the list of size gradients
  14965. */
  14966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Gets the current list of alpha remap gradients.
  14975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14976. * @returns the list of alpha remap gradients
  14977. */
  14978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14979. /**
  14980. * Gets the current list of life time gradients.
  14981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14982. * @returns the list of life time gradients
  14983. */
  14984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14985. /**
  14986. * Gets the current list of angular speed gradients.
  14987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14988. * @returns the list of angular speed gradients
  14989. */
  14990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14991. /**
  14992. * Gets the current list of velocity gradients.
  14993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14994. * @returns the list of velocity gradients
  14995. */
  14996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14997. /**
  14998. * Gets the current list of start size gradients.
  14999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15000. * @returns the list of start size gradients
  15001. */
  15002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of emit rate gradients.
  15005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15006. * @returns the list of emit rate gradients
  15007. */
  15008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15009. /**
  15010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15012. */
  15013. direction1: Vector3;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. direction2: Vector3;
  15019. /**
  15020. * 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.
  15021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15022. */
  15023. minEmitBox: Vector3;
  15024. /**
  15025. * 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.
  15026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15027. */
  15028. maxEmitBox: Vector3;
  15029. /**
  15030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15031. */
  15032. color1: Color4;
  15033. /**
  15034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15035. */
  15036. color2: Color4;
  15037. /**
  15038. * Color the particle will have at the end of its lifetime
  15039. */
  15040. colorDead: Color4;
  15041. /**
  15042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15043. */
  15044. textureMask: Color4;
  15045. /**
  15046. * The particle emitter type defines the emitter used by the particle system.
  15047. * It can be for example box, sphere, or cone...
  15048. */
  15049. particleEmitterType: IParticleEmitterType;
  15050. /** @hidden */
  15051. _isSubEmitter: boolean;
  15052. /**
  15053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15055. */
  15056. billboardMode: number;
  15057. protected _isBillboardBased: boolean;
  15058. /**
  15059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15060. */
  15061. isBillboardBased: boolean;
  15062. /**
  15063. * The scene the particle system belongs to.
  15064. */
  15065. protected _scene: Scene;
  15066. /**
  15067. * Local cache of defines for image processing.
  15068. */
  15069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15070. /**
  15071. * Default configuration related to image processing available in the standard Material.
  15072. */
  15073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15074. /**
  15075. * Gets the image processing configuration used either in this material.
  15076. */
  15077. /**
  15078. * Sets the Default image processing configuration used either in the this material.
  15079. *
  15080. * If sets to null, the scene one is in use.
  15081. */
  15082. imageProcessingConfiguration: ImageProcessingConfiguration;
  15083. /**
  15084. * Attaches a new image processing configuration to the Standard Material.
  15085. * @param configuration
  15086. */
  15087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15088. /** @hidden */
  15089. protected _reset(): void;
  15090. /** @hidden */
  15091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15092. /**
  15093. * Instantiates a particle system.
  15094. * 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.
  15095. * @param name The name of the particle system
  15096. */
  15097. constructor(name: string);
  15098. /**
  15099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15102. * @returns the emitter
  15103. */
  15104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15105. /**
  15106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15107. * @param radius The radius of the hemisphere to emit from
  15108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15109. * @returns the emitter
  15110. */
  15111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15112. /**
  15113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15114. * @param radius The radius of the sphere to emit from
  15115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15116. * @returns the emitter
  15117. */
  15118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15119. /**
  15120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15121. * @param radius The radius of the sphere to emit from
  15122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15124. * @returns the emitter
  15125. */
  15126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15127. /**
  15128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15129. * @param radius The radius of the emission cylinder
  15130. * @param height The height of the emission cylinder
  15131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15133. * @returns the emitter
  15134. */
  15135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15136. /**
  15137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15138. * @param radius The radius of the cylinder to emit from
  15139. * @param height The height of the emission cylinder
  15140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15143. * @returns the emitter
  15144. */
  15145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15146. /**
  15147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15148. * @param radius The radius of the cone to emit from
  15149. * @param angle The base angle of the cone
  15150. * @returns the emitter
  15151. */
  15152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15153. /**
  15154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15159. * @returns the emitter
  15160. */
  15161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15162. }
  15163. }
  15164. declare module "babylonjs/Particles/subEmitter" {
  15165. import { Scene } from "babylonjs/scene";
  15166. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15167. /**
  15168. * Type of sub emitter
  15169. */
  15170. export enum SubEmitterType {
  15171. /**
  15172. * Attached to the particle over it's lifetime
  15173. */
  15174. ATTACHED = 0,
  15175. /**
  15176. * Created when the particle dies
  15177. */
  15178. END = 1
  15179. }
  15180. /**
  15181. * Sub emitter class used to emit particles from an existing particle
  15182. */
  15183. export class SubEmitter {
  15184. /**
  15185. * the particle system to be used by the sub emitter
  15186. */
  15187. particleSystem: ParticleSystem;
  15188. /**
  15189. * Type of the submitter (Default: END)
  15190. */
  15191. type: SubEmitterType;
  15192. /**
  15193. * 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)
  15194. * Note: This only is supported when using an emitter of type Mesh
  15195. */
  15196. inheritDirection: boolean;
  15197. /**
  15198. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15199. */
  15200. inheritedVelocityAmount: number;
  15201. /**
  15202. * Creates a sub emitter
  15203. * @param particleSystem the particle system to be used by the sub emitter
  15204. */
  15205. constructor(
  15206. /**
  15207. * the particle system to be used by the sub emitter
  15208. */
  15209. particleSystem: ParticleSystem);
  15210. /**
  15211. * Clones the sub emitter
  15212. * @returns the cloned sub emitter
  15213. */
  15214. clone(): SubEmitter;
  15215. /**
  15216. * Serialize current object to a JSON object
  15217. * @returns the serialized object
  15218. */
  15219. serialize(): any;
  15220. /** @hidden */
  15221. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15222. /**
  15223. * Creates a new SubEmitter from a serialized JSON version
  15224. * @param serializationObject defines the JSON object to read from
  15225. * @param scene defines the hosting scene
  15226. * @param rootUrl defines the rootUrl for data loading
  15227. * @returns a new SubEmitter
  15228. */
  15229. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15230. /** Release associated resources */
  15231. dispose(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15235. /** @hidden */
  15236. export var clipPlaneFragmentDeclaration: {
  15237. name: string;
  15238. shader: string;
  15239. };
  15240. }
  15241. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15242. /** @hidden */
  15243. export var imageProcessingDeclaration: {
  15244. name: string;
  15245. shader: string;
  15246. };
  15247. }
  15248. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15249. /** @hidden */
  15250. export var imageProcessingFunctions: {
  15251. name: string;
  15252. shader: string;
  15253. };
  15254. }
  15255. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15256. /** @hidden */
  15257. export var clipPlaneFragment: {
  15258. name: string;
  15259. shader: string;
  15260. };
  15261. }
  15262. declare module "babylonjs/Shaders/particles.fragment" {
  15263. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15264. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15266. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15267. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15268. /** @hidden */
  15269. export var particlesPixelShader: {
  15270. name: string;
  15271. shader: string;
  15272. };
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneVertexDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15282. /** @hidden */
  15283. export var clipPlaneVertex: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/particles.vertex" {
  15289. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15290. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15291. /** @hidden */
  15292. export var particlesVertexShader: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Particles/particleSystem" {
  15298. import { Nullable } from "babylonjs/types";
  15299. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15300. import { Observable } from "babylonjs/Misc/observable";
  15301. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15302. import { Effect } from "babylonjs/Materials/effect";
  15303. import { Scene, IDisposable } from "babylonjs/scene";
  15304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15305. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15306. import { Particle } from "babylonjs/Particles/particle";
  15307. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15308. import "babylonjs/Shaders/particles.fragment";
  15309. import "babylonjs/Shaders/particles.vertex";
  15310. /**
  15311. * This represents a particle system in Babylon.
  15312. * 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.
  15313. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15314. * @example https://doc.babylonjs.com/babylon101/particles
  15315. */
  15316. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15317. /**
  15318. * Billboard mode will only apply to Y axis
  15319. */
  15320. static readonly BILLBOARDMODE_Y: number;
  15321. /**
  15322. * Billboard mode will apply to all axes
  15323. */
  15324. static readonly BILLBOARDMODE_ALL: number;
  15325. /**
  15326. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15327. */
  15328. static readonly BILLBOARDMODE_STRETCHED: number;
  15329. /**
  15330. * This function can be defined to provide custom update for active particles.
  15331. * This function will be called instead of regular update (age, position, color, etc.).
  15332. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15333. */
  15334. updateFunction: (particles: Particle[]) => void;
  15335. private _emitterWorldMatrix;
  15336. /**
  15337. * This function can be defined to specify initial direction for every new particle.
  15338. * It by default use the emitterType defined function
  15339. */
  15340. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15341. /**
  15342. * This function can be defined to specify initial position for every new particle.
  15343. * It by default use the emitterType defined function
  15344. */
  15345. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15346. /**
  15347. * @hidden
  15348. */
  15349. _inheritedVelocityOffset: Vector3;
  15350. /**
  15351. * An event triggered when the system is disposed
  15352. */
  15353. onDisposeObservable: Observable<ParticleSystem>;
  15354. private _onDisposeObserver;
  15355. /**
  15356. * Sets a callback that will be triggered when the system is disposed
  15357. */
  15358. onDispose: () => void;
  15359. private _particles;
  15360. private _epsilon;
  15361. private _capacity;
  15362. private _stockParticles;
  15363. private _newPartsExcess;
  15364. private _vertexData;
  15365. private _vertexBuffer;
  15366. private _vertexBuffers;
  15367. private _spriteBuffer;
  15368. private _indexBuffer;
  15369. private _effect;
  15370. private _customEffect;
  15371. private _cachedDefines;
  15372. private _scaledColorStep;
  15373. private _colorDiff;
  15374. private _scaledDirection;
  15375. private _scaledGravity;
  15376. private _currentRenderId;
  15377. private _alive;
  15378. private _useInstancing;
  15379. private _started;
  15380. private _stopped;
  15381. private _actualFrame;
  15382. private _scaledUpdateSpeed;
  15383. private _vertexBufferSize;
  15384. /** @hidden */
  15385. _currentEmitRateGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentEmitRate1: number;
  15388. /** @hidden */
  15389. _currentEmitRate2: number;
  15390. /** @hidden */
  15391. _currentStartSizeGradient: Nullable<FactorGradient>;
  15392. /** @hidden */
  15393. _currentStartSize1: number;
  15394. /** @hidden */
  15395. _currentStartSize2: number;
  15396. private readonly _rawTextureWidth;
  15397. private _rampGradientsTexture;
  15398. private _useRampGradients;
  15399. /** Gets or sets a boolean indicating that ramp gradients must be used
  15400. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15401. */
  15402. useRampGradients: boolean;
  15403. /**
  15404. * 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.
  15405. * 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: [])
  15406. */
  15407. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15408. private _subEmitters;
  15409. /**
  15410. * @hidden
  15411. * If the particle systems emitter should be disposed when the particle system is disposed
  15412. */
  15413. _disposeEmitterOnDispose: boolean;
  15414. /**
  15415. * The current active Sub-systems, this property is used by the root particle system only.
  15416. */
  15417. activeSubSystems: Array<ParticleSystem>;
  15418. private _rootParticleSystem;
  15419. /**
  15420. * Gets the current list of active particles
  15421. */
  15422. readonly particles: Particle[];
  15423. /**
  15424. * Returns the string "ParticleSystem"
  15425. * @returns a string containing the class name
  15426. */
  15427. getClassName(): string;
  15428. /**
  15429. * Instantiates a particle system.
  15430. * 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.
  15431. * @param name The name of the particle system
  15432. * @param capacity The max number of particles alive at the same time
  15433. * @param scene The scene the particle system belongs to
  15434. * @param customEffect a custom effect used to change the way particles are rendered by default
  15435. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15436. * @param epsilon Offset used to render the particles
  15437. */
  15438. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15439. private _addFactorGradient;
  15440. private _removeFactorGradient;
  15441. /**
  15442. * Adds a new life time gradient
  15443. * @param gradient defines the gradient to use (between 0 and 1)
  15444. * @param factor defines the life time factor to affect to the specified gradient
  15445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15446. * @returns the current particle system
  15447. */
  15448. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15449. /**
  15450. * Remove a specific life time gradient
  15451. * @param gradient defines the gradient to remove
  15452. * @returns the current particle system
  15453. */
  15454. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15455. /**
  15456. * Adds a new size gradient
  15457. * @param gradient defines the gradient to use (between 0 and 1)
  15458. * @param factor defines the size factor to affect to the specified gradient
  15459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15460. * @returns the current particle system
  15461. */
  15462. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15463. /**
  15464. * Remove a specific size gradient
  15465. * @param gradient defines the gradient to remove
  15466. * @returns the current particle system
  15467. */
  15468. removeSizeGradient(gradient: number): IParticleSystem;
  15469. /**
  15470. * Adds a new color remap gradient
  15471. * @param gradient defines the gradient to use (between 0 and 1)
  15472. * @param min defines the color remap minimal range
  15473. * @param max defines the color remap maximal range
  15474. * @returns the current particle system
  15475. */
  15476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15477. /**
  15478. * Remove a specific color remap gradient
  15479. * @param gradient defines the gradient to remove
  15480. * @returns the current particle system
  15481. */
  15482. removeColorRemapGradient(gradient: number): IParticleSystem;
  15483. /**
  15484. * Adds a new alpha remap gradient
  15485. * @param gradient defines the gradient to use (between 0 and 1)
  15486. * @param min defines the alpha remap minimal range
  15487. * @param max defines the alpha remap maximal range
  15488. * @returns the current particle system
  15489. */
  15490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15491. /**
  15492. * Remove a specific alpha remap gradient
  15493. * @param gradient defines the gradient to remove
  15494. * @returns the current particle system
  15495. */
  15496. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15497. /**
  15498. * Adds a new angular speed gradient
  15499. * @param gradient defines the gradient to use (between 0 and 1)
  15500. * @param factor defines the angular speed to affect to the specified gradient
  15501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15502. * @returns the current particle system
  15503. */
  15504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15505. /**
  15506. * Remove a specific angular speed gradient
  15507. * @param gradient defines the gradient to remove
  15508. * @returns the current particle system
  15509. */
  15510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15511. /**
  15512. * Adds a new velocity gradient
  15513. * @param gradient defines the gradient to use (between 0 and 1)
  15514. * @param factor defines the velocity to affect to the specified gradient
  15515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15516. * @returns the current particle system
  15517. */
  15518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15519. /**
  15520. * Remove a specific velocity gradient
  15521. * @param gradient defines the gradient to remove
  15522. * @returns the current particle system
  15523. */
  15524. removeVelocityGradient(gradient: number): IParticleSystem;
  15525. /**
  15526. * Adds a new limit velocity gradient
  15527. * @param gradient defines the gradient to use (between 0 and 1)
  15528. * @param factor defines the limit velocity value to affect to the specified gradient
  15529. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15530. * @returns the current particle system
  15531. */
  15532. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15533. /**
  15534. * Remove a specific limit velocity gradient
  15535. * @param gradient defines the gradient to remove
  15536. * @returns the current particle system
  15537. */
  15538. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15539. /**
  15540. * Adds a new drag gradient
  15541. * @param gradient defines the gradient to use (between 0 and 1)
  15542. * @param factor defines the drag value to affect to the specified gradient
  15543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15544. * @returns the current particle system
  15545. */
  15546. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15547. /**
  15548. * Remove a specific drag gradient
  15549. * @param gradient defines the gradient to remove
  15550. * @returns the current particle system
  15551. */
  15552. removeDragGradient(gradient: number): IParticleSystem;
  15553. /**
  15554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15555. * @param gradient defines the gradient to use (between 0 and 1)
  15556. * @param factor defines the emit rate value to affect to the specified gradient
  15557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15558. * @returns the current particle system
  15559. */
  15560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15561. /**
  15562. * Remove a specific emit rate gradient
  15563. * @param gradient defines the gradient to remove
  15564. * @returns the current particle system
  15565. */
  15566. removeEmitRateGradient(gradient: number): IParticleSystem;
  15567. /**
  15568. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15569. * @param gradient defines the gradient to use (between 0 and 1)
  15570. * @param factor defines the start size value to affect to the specified gradient
  15571. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15572. * @returns the current particle system
  15573. */
  15574. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15575. /**
  15576. * Remove a specific start size gradient
  15577. * @param gradient defines the gradient to remove
  15578. * @returns the current particle system
  15579. */
  15580. removeStartSizeGradient(gradient: number): IParticleSystem;
  15581. private _createRampGradientTexture;
  15582. /**
  15583. * Gets the current list of ramp gradients.
  15584. * You must use addRampGradient and removeRampGradient to udpate this list
  15585. * @returns the list of ramp gradients
  15586. */
  15587. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15588. /**
  15589. * Adds a new ramp gradient used to remap particle colors
  15590. * @param gradient defines the gradient to use (between 0 and 1)
  15591. * @param color defines the color to affect to the specified gradient
  15592. * @returns the current particle system
  15593. */
  15594. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15595. /**
  15596. * Remove a specific ramp gradient
  15597. * @param gradient defines the gradient to remove
  15598. * @returns the current particle system
  15599. */
  15600. removeRampGradient(gradient: number): ParticleSystem;
  15601. /**
  15602. * Adds a new color gradient
  15603. * @param gradient defines the gradient to use (between 0 and 1)
  15604. * @param color1 defines the color to affect to the specified gradient
  15605. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15606. * @returns this particle system
  15607. */
  15608. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15609. /**
  15610. * Remove a specific color gradient
  15611. * @param gradient defines the gradient to remove
  15612. * @returns this particle system
  15613. */
  15614. removeColorGradient(gradient: number): IParticleSystem;
  15615. private _fetchR;
  15616. protected _reset(): void;
  15617. private _resetEffect;
  15618. private _createVertexBuffers;
  15619. private _createIndexBuffer;
  15620. /**
  15621. * Gets the maximum number of particles active at the same time.
  15622. * @returns The max number of active particles.
  15623. */
  15624. getCapacity(): number;
  15625. /**
  15626. * Gets whether there are still active particles in the system.
  15627. * @returns True if it is alive, otherwise false.
  15628. */
  15629. isAlive(): boolean;
  15630. /**
  15631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15632. * @returns True if it has been started, otherwise false.
  15633. */
  15634. isStarted(): boolean;
  15635. private _prepareSubEmitterInternalArray;
  15636. /**
  15637. * Starts the particle system and begins to emit
  15638. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15639. */
  15640. start(delay?: number): void;
  15641. /**
  15642. * Stops the particle system.
  15643. * @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.
  15644. */
  15645. stop(stopSubEmitters?: boolean): void;
  15646. /**
  15647. * Remove all active particles
  15648. */
  15649. reset(): void;
  15650. /**
  15651. * @hidden (for internal use only)
  15652. */
  15653. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15654. /**
  15655. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15656. * Its lifetime will start back at 0.
  15657. */
  15658. recycleParticle: (particle: Particle) => void;
  15659. private _stopSubEmitters;
  15660. private _createParticle;
  15661. private _removeFromRoot;
  15662. private _emitFromParticle;
  15663. private _update;
  15664. /** @hidden */
  15665. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15666. /** @hidden */
  15667. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15668. /** @hidden */
  15669. private _getEffect;
  15670. /**
  15671. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15672. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15673. */
  15674. animate(preWarmOnly?: boolean): void;
  15675. private _appendParticleVertices;
  15676. /**
  15677. * Rebuilds the particle system.
  15678. */
  15679. rebuild(): void;
  15680. /**
  15681. * Is this system ready to be used/rendered
  15682. * @return true if the system is ready
  15683. */
  15684. isReady(): boolean;
  15685. private _render;
  15686. /**
  15687. * Renders the particle system in its current state.
  15688. * @returns the current number of particles
  15689. */
  15690. render(): number;
  15691. /**
  15692. * Disposes the particle system and free the associated resources
  15693. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15694. */
  15695. dispose(disposeTexture?: boolean): void;
  15696. /**
  15697. * Clones the particle system.
  15698. * @param name The name of the cloned object
  15699. * @param newEmitter The new emitter to use
  15700. * @returns the cloned particle system
  15701. */
  15702. clone(name: string, newEmitter: any): ParticleSystem;
  15703. /**
  15704. * Serializes the particle system to a JSON object.
  15705. * @returns the JSON object
  15706. */
  15707. serialize(): any;
  15708. /** @hidden */
  15709. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15710. /** @hidden */
  15711. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15712. /**
  15713. * Parses a JSON object to create a particle system.
  15714. * @param parsedParticleSystem The JSON object to parse
  15715. * @param scene The scene to create the particle system in
  15716. * @param rootUrl The root url to use to load external dependencies like texture
  15717. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15718. * @returns the Parsed particle system
  15719. */
  15720. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15721. }
  15722. }
  15723. declare module "babylonjs/Particles/particle" {
  15724. import { Nullable } from "babylonjs/types";
  15725. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15726. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15727. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15728. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15729. /**
  15730. * A particle represents one of the element emitted by a particle system.
  15731. * This is mainly define by its coordinates, direction, velocity and age.
  15732. */
  15733. export class Particle {
  15734. /**
  15735. * The particle system the particle belongs to.
  15736. */
  15737. particleSystem: ParticleSystem;
  15738. private static _Count;
  15739. /**
  15740. * Unique ID of the particle
  15741. */
  15742. id: number;
  15743. /**
  15744. * The world position of the particle in the scene.
  15745. */
  15746. position: Vector3;
  15747. /**
  15748. * The world direction of the particle in the scene.
  15749. */
  15750. direction: Vector3;
  15751. /**
  15752. * The color of the particle.
  15753. */
  15754. color: Color4;
  15755. /**
  15756. * The color change of the particle per step.
  15757. */
  15758. colorStep: Color4;
  15759. /**
  15760. * Defines how long will the life of the particle be.
  15761. */
  15762. lifeTime: number;
  15763. /**
  15764. * The current age of the particle.
  15765. */
  15766. age: number;
  15767. /**
  15768. * The current size of the particle.
  15769. */
  15770. size: number;
  15771. /**
  15772. * The current scale of the particle.
  15773. */
  15774. scale: Vector2;
  15775. /**
  15776. * The current angle of the particle.
  15777. */
  15778. angle: number;
  15779. /**
  15780. * Defines how fast is the angle changing.
  15781. */
  15782. angularSpeed: number;
  15783. /**
  15784. * Defines the cell index used by the particle to be rendered from a sprite.
  15785. */
  15786. cellIndex: number;
  15787. /**
  15788. * The information required to support color remapping
  15789. */
  15790. remapData: Vector4;
  15791. /** @hidden */
  15792. _randomCellOffset?: number;
  15793. /** @hidden */
  15794. _initialDirection: Nullable<Vector3>;
  15795. /** @hidden */
  15796. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15797. /** @hidden */
  15798. _initialStartSpriteCellID: number;
  15799. /** @hidden */
  15800. _initialEndSpriteCellID: number;
  15801. /** @hidden */
  15802. _currentColorGradient: Nullable<ColorGradient>;
  15803. /** @hidden */
  15804. _currentColor1: Color4;
  15805. /** @hidden */
  15806. _currentColor2: Color4;
  15807. /** @hidden */
  15808. _currentSizeGradient: Nullable<FactorGradient>;
  15809. /** @hidden */
  15810. _currentSize1: number;
  15811. /** @hidden */
  15812. _currentSize2: number;
  15813. /** @hidden */
  15814. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15815. /** @hidden */
  15816. _currentAngularSpeed1: number;
  15817. /** @hidden */
  15818. _currentAngularSpeed2: number;
  15819. /** @hidden */
  15820. _currentVelocityGradient: Nullable<FactorGradient>;
  15821. /** @hidden */
  15822. _currentVelocity1: number;
  15823. /** @hidden */
  15824. _currentVelocity2: number;
  15825. /** @hidden */
  15826. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15827. /** @hidden */
  15828. _currentLimitVelocity1: number;
  15829. /** @hidden */
  15830. _currentLimitVelocity2: number;
  15831. /** @hidden */
  15832. _currentDragGradient: Nullable<FactorGradient>;
  15833. /** @hidden */
  15834. _currentDrag1: number;
  15835. /** @hidden */
  15836. _currentDrag2: number;
  15837. /** @hidden */
  15838. _randomNoiseCoordinates1: Vector3;
  15839. /** @hidden */
  15840. _randomNoiseCoordinates2: Vector3;
  15841. /**
  15842. * Creates a new instance Particle
  15843. * @param particleSystem the particle system the particle belongs to
  15844. */
  15845. constructor(
  15846. /**
  15847. * The particle system the particle belongs to.
  15848. */
  15849. particleSystem: ParticleSystem);
  15850. private updateCellInfoFromSystem;
  15851. /**
  15852. * Defines how the sprite cell index is updated for the particle
  15853. */
  15854. updateCellIndex(): void;
  15855. /** @hidden */
  15856. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15857. /** @hidden */
  15858. _inheritParticleInfoToSubEmitters(): void;
  15859. /** @hidden */
  15860. _reset(): void;
  15861. /**
  15862. * Copy the properties of particle to another one.
  15863. * @param other the particle to copy the information to.
  15864. */
  15865. copyTo(other: Particle): void;
  15866. }
  15867. }
  15868. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15869. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15870. import { Effect } from "babylonjs/Materials/effect";
  15871. import { Particle } from "babylonjs/Particles/particle";
  15872. /**
  15873. * Particle emitter represents a volume emitting particles.
  15874. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15875. */
  15876. export interface IParticleEmitterType {
  15877. /**
  15878. * Called by the particle System when the direction is computed for the created particle.
  15879. * @param worldMatrix is the world matrix of the particle system
  15880. * @param directionToUpdate is the direction vector to update with the result
  15881. * @param particle is the particle we are computed the direction for
  15882. */
  15883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15884. /**
  15885. * Called by the particle System when the position is computed for the created particle.
  15886. * @param worldMatrix is the world matrix of the particle system
  15887. * @param positionToUpdate is the position vector to update with the result
  15888. * @param particle is the particle we are computed the position for
  15889. */
  15890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15891. /**
  15892. * Clones the current emitter and returns a copy of it
  15893. * @returns the new emitter
  15894. */
  15895. clone(): IParticleEmitterType;
  15896. /**
  15897. * Called by the GPUParticleSystem to setup the update shader
  15898. * @param effect defines the update shader
  15899. */
  15900. applyToShader(effect: Effect): void;
  15901. /**
  15902. * Returns a string to use to update the GPU particles update shader
  15903. * @returns the effect defines string
  15904. */
  15905. getEffectDefines(): string;
  15906. /**
  15907. * Returns a string representing the class name
  15908. * @returns a string containing the class name
  15909. */
  15910. getClassName(): string;
  15911. /**
  15912. * Serializes the particle system to a JSON object.
  15913. * @returns the JSON object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Parse properties from a JSON object
  15918. * @param serializationObject defines the JSON object
  15919. */
  15920. parse(serializationObject: any): void;
  15921. }
  15922. }
  15923. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15924. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15925. import { Effect } from "babylonjs/Materials/effect";
  15926. import { Particle } from "babylonjs/Particles/particle";
  15927. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15928. /**
  15929. * Particle emitter emitting particles from the inside of a box.
  15930. * It emits the particles randomly between 2 given directions.
  15931. */
  15932. export class BoxParticleEmitter implements IParticleEmitterType {
  15933. /**
  15934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15935. */
  15936. direction1: Vector3;
  15937. /**
  15938. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15939. */
  15940. direction2: Vector3;
  15941. /**
  15942. * 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.
  15943. */
  15944. minEmitBox: Vector3;
  15945. /**
  15946. * 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.
  15947. */
  15948. maxEmitBox: Vector3;
  15949. /**
  15950. * Creates a new instance BoxParticleEmitter
  15951. */
  15952. constructor();
  15953. /**
  15954. * Called by the particle System when the direction is computed for the created particle.
  15955. * @param worldMatrix is the world matrix of the particle system
  15956. * @param directionToUpdate is the direction vector to update with the result
  15957. * @param particle is the particle we are computed the direction for
  15958. */
  15959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15960. /**
  15961. * Called by the particle System when the position is computed for the created particle.
  15962. * @param worldMatrix is the world matrix of the particle system
  15963. * @param positionToUpdate is the position vector to update with the result
  15964. * @param particle is the particle we are computed the position for
  15965. */
  15966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15967. /**
  15968. * Clones the current emitter and returns a copy of it
  15969. * @returns the new emitter
  15970. */
  15971. clone(): BoxParticleEmitter;
  15972. /**
  15973. * Called by the GPUParticleSystem to setup the update shader
  15974. * @param effect defines the update shader
  15975. */
  15976. applyToShader(effect: Effect): void;
  15977. /**
  15978. * Returns a string to use to update the GPU particles update shader
  15979. * @returns a string containng the defines string
  15980. */
  15981. getEffectDefines(): string;
  15982. /**
  15983. * Returns the string "BoxParticleEmitter"
  15984. * @returns a string containing the class name
  15985. */
  15986. getClassName(): string;
  15987. /**
  15988. * Serializes the particle system to a JSON object.
  15989. * @returns the JSON object
  15990. */
  15991. serialize(): any;
  15992. /**
  15993. * Parse properties from a JSON object
  15994. * @param serializationObject defines the JSON object
  15995. */
  15996. parse(serializationObject: any): void;
  15997. }
  15998. }
  15999. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16000. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16001. import { Effect } from "babylonjs/Materials/effect";
  16002. import { Particle } from "babylonjs/Particles/particle";
  16003. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16004. /**
  16005. * Particle emitter emitting particles from the inside of a cone.
  16006. * It emits the particles alongside the cone volume from the base to the particle.
  16007. * The emission direction might be randomized.
  16008. */
  16009. export class ConeParticleEmitter implements IParticleEmitterType {
  16010. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16011. directionRandomizer: number;
  16012. private _radius;
  16013. private _angle;
  16014. private _height;
  16015. /**
  16016. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16017. */
  16018. radiusRange: number;
  16019. /**
  16020. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16021. */
  16022. heightRange: number;
  16023. /**
  16024. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16025. */
  16026. emitFromSpawnPointOnly: boolean;
  16027. /**
  16028. * Gets or sets the radius of the emission cone
  16029. */
  16030. radius: number;
  16031. /**
  16032. * Gets or sets the angle of the emission cone
  16033. */
  16034. angle: number;
  16035. private _buildHeight;
  16036. /**
  16037. * Creates a new instance ConeParticleEmitter
  16038. * @param radius the radius of the emission cone (1 by default)
  16039. * @param angle the cone base angle (PI by default)
  16040. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16041. */
  16042. constructor(radius?: number, angle?: number,
  16043. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16044. directionRandomizer?: number);
  16045. /**
  16046. * Called by the particle System when the direction is computed for the created particle.
  16047. * @param worldMatrix is the world matrix of the particle system
  16048. * @param directionToUpdate is the direction vector to update with the result
  16049. * @param particle is the particle we are computed the direction for
  16050. */
  16051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16052. /**
  16053. * Called by the particle System when the position is computed for the created particle.
  16054. * @param worldMatrix is the world matrix of the particle system
  16055. * @param positionToUpdate is the position vector to update with the result
  16056. * @param particle is the particle we are computed the position for
  16057. */
  16058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16059. /**
  16060. * Clones the current emitter and returns a copy of it
  16061. * @returns the new emitter
  16062. */
  16063. clone(): ConeParticleEmitter;
  16064. /**
  16065. * Called by the GPUParticleSystem to setup the update shader
  16066. * @param effect defines the update shader
  16067. */
  16068. applyToShader(effect: Effect): void;
  16069. /**
  16070. * Returns a string to use to update the GPU particles update shader
  16071. * @returns a string containng the defines string
  16072. */
  16073. getEffectDefines(): string;
  16074. /**
  16075. * Returns the string "ConeParticleEmitter"
  16076. * @returns a string containing the class name
  16077. */
  16078. getClassName(): string;
  16079. /**
  16080. * Serializes the particle system to a JSON object.
  16081. * @returns the JSON object
  16082. */
  16083. serialize(): any;
  16084. /**
  16085. * Parse properties from a JSON object
  16086. * @param serializationObject defines the JSON object
  16087. */
  16088. parse(serializationObject: any): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16092. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16093. import { Effect } from "babylonjs/Materials/effect";
  16094. import { Particle } from "babylonjs/Particles/particle";
  16095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16096. /**
  16097. * Particle emitter emitting particles from the inside of a cylinder.
  16098. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16099. */
  16100. export class CylinderParticleEmitter implements IParticleEmitterType {
  16101. /**
  16102. * The radius of the emission cylinder.
  16103. */
  16104. radius: number;
  16105. /**
  16106. * The height of the emission cylinder.
  16107. */
  16108. height: number;
  16109. /**
  16110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16111. */
  16112. radiusRange: number;
  16113. /**
  16114. * How much to randomize the particle direction [0-1].
  16115. */
  16116. directionRandomizer: number;
  16117. /**
  16118. * Creates a new instance CylinderParticleEmitter
  16119. * @param radius the radius of the emission cylinder (1 by default)
  16120. * @param height the height of the emission cylinder (1 by default)
  16121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16122. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16123. */
  16124. constructor(
  16125. /**
  16126. * The radius of the emission cylinder.
  16127. */
  16128. radius?: number,
  16129. /**
  16130. * The height of the emission cylinder.
  16131. */
  16132. height?: number,
  16133. /**
  16134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16135. */
  16136. radiusRange?: number,
  16137. /**
  16138. * How much to randomize the particle direction [0-1].
  16139. */
  16140. directionRandomizer?: number);
  16141. /**
  16142. * Called by the particle System when the direction is computed for the created particle.
  16143. * @param worldMatrix is the world matrix of the particle system
  16144. * @param directionToUpdate is the direction vector to update with the result
  16145. * @param particle is the particle we are computed the direction for
  16146. */
  16147. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16148. /**
  16149. * Called by the particle System when the position is computed for the created particle.
  16150. * @param worldMatrix is the world matrix of the particle system
  16151. * @param positionToUpdate is the position vector to update with the result
  16152. * @param particle is the particle we are computed the position for
  16153. */
  16154. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16155. /**
  16156. * Clones the current emitter and returns a copy of it
  16157. * @returns the new emitter
  16158. */
  16159. clone(): CylinderParticleEmitter;
  16160. /**
  16161. * Called by the GPUParticleSystem to setup the update shader
  16162. * @param effect defines the update shader
  16163. */
  16164. applyToShader(effect: Effect): void;
  16165. /**
  16166. * Returns a string to use to update the GPU particles update shader
  16167. * @returns a string containng the defines string
  16168. */
  16169. getEffectDefines(): string;
  16170. /**
  16171. * Returns the string "CylinderParticleEmitter"
  16172. * @returns a string containing the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Serializes the particle system to a JSON object.
  16177. * @returns the JSON object
  16178. */
  16179. serialize(): any;
  16180. /**
  16181. * Parse properties from a JSON object
  16182. * @param serializationObject defines the JSON object
  16183. */
  16184. parse(serializationObject: any): void;
  16185. }
  16186. /**
  16187. * Particle emitter emitting particles from the inside of a cylinder.
  16188. * It emits the particles randomly between two vectors.
  16189. */
  16190. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16191. /**
  16192. * The min limit of the emission direction.
  16193. */
  16194. direction1: Vector3;
  16195. /**
  16196. * The max limit of the emission direction.
  16197. */
  16198. direction2: Vector3;
  16199. /**
  16200. * Creates a new instance CylinderDirectedParticleEmitter
  16201. * @param radius the radius of the emission cylinder (1 by default)
  16202. * @param height the height of the emission cylinder (1 by default)
  16203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16204. * @param direction1 the min limit of the emission direction (up vector by default)
  16205. * @param direction2 the max limit of the emission direction (up vector by default)
  16206. */
  16207. constructor(radius?: number, height?: number, radiusRange?: number,
  16208. /**
  16209. * The min limit of the emission direction.
  16210. */
  16211. direction1?: Vector3,
  16212. /**
  16213. * The max limit of the emission direction.
  16214. */
  16215. direction2?: Vector3);
  16216. /**
  16217. * Called by the particle System when the direction is computed for the created particle.
  16218. * @param worldMatrix is the world matrix of the particle system
  16219. * @param directionToUpdate is the direction vector to update with the result
  16220. * @param particle is the particle we are computed the direction for
  16221. */
  16222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16223. /**
  16224. * Clones the current emitter and returns a copy of it
  16225. * @returns the new emitter
  16226. */
  16227. clone(): CylinderDirectedParticleEmitter;
  16228. /**
  16229. * Called by the GPUParticleSystem to setup the update shader
  16230. * @param effect defines the update shader
  16231. */
  16232. applyToShader(effect: Effect): void;
  16233. /**
  16234. * Returns a string to use to update the GPU particles update shader
  16235. * @returns a string containng the defines string
  16236. */
  16237. getEffectDefines(): string;
  16238. /**
  16239. * Returns the string "CylinderDirectedParticleEmitter"
  16240. * @returns a string containing the class name
  16241. */
  16242. getClassName(): string;
  16243. /**
  16244. * Serializes the particle system to a JSON object.
  16245. * @returns the JSON object
  16246. */
  16247. serialize(): any;
  16248. /**
  16249. * Parse properties from a JSON object
  16250. * @param serializationObject defines the JSON object
  16251. */
  16252. parse(serializationObject: any): void;
  16253. }
  16254. }
  16255. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16256. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16257. import { Effect } from "babylonjs/Materials/effect";
  16258. import { Particle } from "babylonjs/Particles/particle";
  16259. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16260. /**
  16261. * Particle emitter emitting particles from the inside of a hemisphere.
  16262. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16263. */
  16264. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16265. /**
  16266. * The radius of the emission hemisphere.
  16267. */
  16268. radius: number;
  16269. /**
  16270. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16271. */
  16272. radiusRange: number;
  16273. /**
  16274. * How much to randomize the particle direction [0-1].
  16275. */
  16276. directionRandomizer: number;
  16277. /**
  16278. * Creates a new instance HemisphericParticleEmitter
  16279. * @param radius the radius of the emission hemisphere (1 by default)
  16280. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16281. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16282. */
  16283. constructor(
  16284. /**
  16285. * The radius of the emission hemisphere.
  16286. */
  16287. radius?: number,
  16288. /**
  16289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16290. */
  16291. radiusRange?: number,
  16292. /**
  16293. * How much to randomize the particle direction [0-1].
  16294. */
  16295. directionRandomizer?: number);
  16296. /**
  16297. * Called by the particle System when the direction is computed for the created particle.
  16298. * @param worldMatrix is the world matrix of the particle system
  16299. * @param directionToUpdate is the direction vector to update with the result
  16300. * @param particle is the particle we are computed the direction for
  16301. */
  16302. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16303. /**
  16304. * Called by the particle System when the position is computed for the created particle.
  16305. * @param worldMatrix is the world matrix of the particle system
  16306. * @param positionToUpdate is the position vector to update with the result
  16307. * @param particle is the particle we are computed the position for
  16308. */
  16309. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16310. /**
  16311. * Clones the current emitter and returns a copy of it
  16312. * @returns the new emitter
  16313. */
  16314. clone(): HemisphericParticleEmitter;
  16315. /**
  16316. * Called by the GPUParticleSystem to setup the update shader
  16317. * @param effect defines the update shader
  16318. */
  16319. applyToShader(effect: Effect): void;
  16320. /**
  16321. * Returns a string to use to update the GPU particles update shader
  16322. * @returns a string containng the defines string
  16323. */
  16324. getEffectDefines(): string;
  16325. /**
  16326. * Returns the string "HemisphericParticleEmitter"
  16327. * @returns a string containing the class name
  16328. */
  16329. getClassName(): string;
  16330. /**
  16331. * Serializes the particle system to a JSON object.
  16332. * @returns the JSON object
  16333. */
  16334. serialize(): any;
  16335. /**
  16336. * Parse properties from a JSON object
  16337. * @param serializationObject defines the JSON object
  16338. */
  16339. parse(serializationObject: any): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16343. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16344. import { Effect } from "babylonjs/Materials/effect";
  16345. import { Particle } from "babylonjs/Particles/particle";
  16346. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16347. /**
  16348. * Particle emitter emitting particles from a point.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class PointParticleEmitter implements IParticleEmitterType {
  16352. /**
  16353. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16354. */
  16355. direction1: Vector3;
  16356. /**
  16357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16358. */
  16359. direction2: Vector3;
  16360. /**
  16361. * Creates a new instance PointParticleEmitter
  16362. */
  16363. constructor();
  16364. /**
  16365. * Called by the particle System when the direction is computed for the created particle.
  16366. * @param worldMatrix is the world matrix of the particle system
  16367. * @param directionToUpdate is the direction vector to update with the result
  16368. * @param particle is the particle we are computed the direction for
  16369. */
  16370. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16371. /**
  16372. * Called by the particle System when the position is computed for the created particle.
  16373. * @param worldMatrix is the world matrix of the particle system
  16374. * @param positionToUpdate is the position vector to update with the result
  16375. * @param particle is the particle we are computed the position for
  16376. */
  16377. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16378. /**
  16379. * Clones the current emitter and returns a copy of it
  16380. * @returns the new emitter
  16381. */
  16382. clone(): PointParticleEmitter;
  16383. /**
  16384. * Called by the GPUParticleSystem to setup the update shader
  16385. * @param effect defines the update shader
  16386. */
  16387. applyToShader(effect: Effect): void;
  16388. /**
  16389. * Returns a string to use to update the GPU particles update shader
  16390. * @returns a string containng the defines string
  16391. */
  16392. getEffectDefines(): string;
  16393. /**
  16394. * Returns the string "PointParticleEmitter"
  16395. * @returns a string containing the class name
  16396. */
  16397. getClassName(): string;
  16398. /**
  16399. * Serializes the particle system to a JSON object.
  16400. * @returns the JSON object
  16401. */
  16402. serialize(): any;
  16403. /**
  16404. * Parse properties from a JSON object
  16405. * @param serializationObject defines the JSON object
  16406. */
  16407. parse(serializationObject: any): void;
  16408. }
  16409. }
  16410. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16411. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16412. import { Effect } from "babylonjs/Materials/effect";
  16413. import { Particle } from "babylonjs/Particles/particle";
  16414. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16415. /**
  16416. * Particle emitter emitting particles from the inside of a sphere.
  16417. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16418. */
  16419. export class SphereParticleEmitter implements IParticleEmitterType {
  16420. /**
  16421. * The radius of the emission sphere.
  16422. */
  16423. radius: number;
  16424. /**
  16425. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16426. */
  16427. radiusRange: number;
  16428. /**
  16429. * How much to randomize the particle direction [0-1].
  16430. */
  16431. directionRandomizer: number;
  16432. /**
  16433. * Creates a new instance SphereParticleEmitter
  16434. * @param radius the radius of the emission sphere (1 by default)
  16435. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16436. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16437. */
  16438. constructor(
  16439. /**
  16440. * The radius of the emission sphere.
  16441. */
  16442. radius?: number,
  16443. /**
  16444. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16445. */
  16446. radiusRange?: number,
  16447. /**
  16448. * How much to randomize the particle direction [0-1].
  16449. */
  16450. directionRandomizer?: number);
  16451. /**
  16452. * Called by the particle System when the direction is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param directionToUpdate is the direction vector to update with the result
  16455. * @param particle is the particle we are computed the direction for
  16456. */
  16457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16458. /**
  16459. * Called by the particle System when the position is computed for the created particle.
  16460. * @param worldMatrix is the world matrix of the particle system
  16461. * @param positionToUpdate is the position vector to update with the result
  16462. * @param particle is the particle we are computed the position for
  16463. */
  16464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16465. /**
  16466. * Clones the current emitter and returns a copy of it
  16467. * @returns the new emitter
  16468. */
  16469. clone(): SphereParticleEmitter;
  16470. /**
  16471. * Called by the GPUParticleSystem to setup the update shader
  16472. * @param effect defines the update shader
  16473. */
  16474. applyToShader(effect: Effect): void;
  16475. /**
  16476. * Returns a string to use to update the GPU particles update shader
  16477. * @returns a string containng the defines string
  16478. */
  16479. getEffectDefines(): string;
  16480. /**
  16481. * Returns the string "SphereParticleEmitter"
  16482. * @returns a string containing the class name
  16483. */
  16484. getClassName(): string;
  16485. /**
  16486. * Serializes the particle system to a JSON object.
  16487. * @returns the JSON object
  16488. */
  16489. serialize(): any;
  16490. /**
  16491. * Parse properties from a JSON object
  16492. * @param serializationObject defines the JSON object
  16493. */
  16494. parse(serializationObject: any): void;
  16495. }
  16496. /**
  16497. * Particle emitter emitting particles from the inside of a sphere.
  16498. * It emits the particles randomly between two vectors.
  16499. */
  16500. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16501. /**
  16502. * The min limit of the emission direction.
  16503. */
  16504. direction1: Vector3;
  16505. /**
  16506. * The max limit of the emission direction.
  16507. */
  16508. direction2: Vector3;
  16509. /**
  16510. * Creates a new instance SphereDirectedParticleEmitter
  16511. * @param radius the radius of the emission sphere (1 by default)
  16512. * @param direction1 the min limit of the emission direction (up vector by default)
  16513. * @param direction2 the max limit of the emission direction (up vector by default)
  16514. */
  16515. constructor(radius?: number,
  16516. /**
  16517. * The min limit of the emission direction.
  16518. */
  16519. direction1?: Vector3,
  16520. /**
  16521. * The max limit of the emission direction.
  16522. */
  16523. direction2?: Vector3);
  16524. /**
  16525. * Called by the particle System when the direction is computed for the created particle.
  16526. * @param worldMatrix is the world matrix of the particle system
  16527. * @param directionToUpdate is the direction vector to update with the result
  16528. * @param particle is the particle we are computed the direction for
  16529. */
  16530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16531. /**
  16532. * Clones the current emitter and returns a copy of it
  16533. * @returns the new emitter
  16534. */
  16535. clone(): SphereDirectedParticleEmitter;
  16536. /**
  16537. * Called by the GPUParticleSystem to setup the update shader
  16538. * @param effect defines the update shader
  16539. */
  16540. applyToShader(effect: Effect): void;
  16541. /**
  16542. * Returns a string to use to update the GPU particles update shader
  16543. * @returns a string containng the defines string
  16544. */
  16545. getEffectDefines(): string;
  16546. /**
  16547. * Returns the string "SphereDirectedParticleEmitter"
  16548. * @returns a string containing the class name
  16549. */
  16550. getClassName(): string;
  16551. /**
  16552. * Serializes the particle system to a JSON object.
  16553. * @returns the JSON object
  16554. */
  16555. serialize(): any;
  16556. /**
  16557. * Parse properties from a JSON object
  16558. * @param serializationObject defines the JSON object
  16559. */
  16560. parse(serializationObject: any): void;
  16561. }
  16562. }
  16563. declare module "babylonjs/Particles/EmitterTypes/index" {
  16564. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16565. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16566. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16567. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16568. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16569. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16570. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16571. }
  16572. declare module "babylonjs/Particles/IParticleSystem" {
  16573. import { Nullable } from "babylonjs/types";
  16574. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16577. import { Texture } from "babylonjs/Materials/Textures/texture";
  16578. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16579. import { Scene } from "babylonjs/scene";
  16580. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16581. import { Animation } from "babylonjs/Animations/animation";
  16582. /**
  16583. * Interface representing a particle system in Babylon.js.
  16584. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16585. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16586. */
  16587. export interface IParticleSystem {
  16588. /**
  16589. * List of animations used by the particle system.
  16590. */
  16591. animations: Animation[];
  16592. /**
  16593. * The id of the Particle system.
  16594. */
  16595. id: string;
  16596. /**
  16597. * The name of the Particle system.
  16598. */
  16599. name: string;
  16600. /**
  16601. * The emitter represents the Mesh or position we are attaching the particle system to.
  16602. */
  16603. emitter: Nullable<AbstractMesh | Vector3>;
  16604. /**
  16605. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16606. */
  16607. isBillboardBased: boolean;
  16608. /**
  16609. * The rendering group used by the Particle system to chose when to render.
  16610. */
  16611. renderingGroupId: number;
  16612. /**
  16613. * The layer mask we are rendering the particles through.
  16614. */
  16615. layerMask: number;
  16616. /**
  16617. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16618. */
  16619. updateSpeed: number;
  16620. /**
  16621. * The amount of time the particle system is running (depends of the overall update speed).
  16622. */
  16623. targetStopDuration: number;
  16624. /**
  16625. * The texture used to render each particle. (this can be a spritesheet)
  16626. */
  16627. particleTexture: Nullable<Texture>;
  16628. /**
  16629. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16630. */
  16631. blendMode: number;
  16632. /**
  16633. * Minimum life time of emitting particles.
  16634. */
  16635. minLifeTime: number;
  16636. /**
  16637. * Maximum life time of emitting particles.
  16638. */
  16639. maxLifeTime: number;
  16640. /**
  16641. * Minimum Size of emitting particles.
  16642. */
  16643. minSize: number;
  16644. /**
  16645. * Maximum Size of emitting particles.
  16646. */
  16647. maxSize: number;
  16648. /**
  16649. * Minimum scale of emitting particles on X axis.
  16650. */
  16651. minScaleX: number;
  16652. /**
  16653. * Maximum scale of emitting particles on X axis.
  16654. */
  16655. maxScaleX: number;
  16656. /**
  16657. * Minimum scale of emitting particles on Y axis.
  16658. */
  16659. minScaleY: number;
  16660. /**
  16661. * Maximum scale of emitting particles on Y axis.
  16662. */
  16663. maxScaleY: number;
  16664. /**
  16665. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16666. */
  16667. color1: Color4;
  16668. /**
  16669. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16670. */
  16671. color2: Color4;
  16672. /**
  16673. * Color the particle will have at the end of its lifetime.
  16674. */
  16675. colorDead: Color4;
  16676. /**
  16677. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16678. */
  16679. emitRate: number;
  16680. /**
  16681. * You can use gravity if you want to give an orientation to your particles.
  16682. */
  16683. gravity: Vector3;
  16684. /**
  16685. * Minimum power of emitting particles.
  16686. */
  16687. minEmitPower: number;
  16688. /**
  16689. * Maximum power of emitting particles.
  16690. */
  16691. maxEmitPower: number;
  16692. /**
  16693. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16694. */
  16695. minAngularSpeed: number;
  16696. /**
  16697. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16698. */
  16699. maxAngularSpeed: number;
  16700. /**
  16701. * Gets or sets the minimal initial rotation in radians.
  16702. */
  16703. minInitialRotation: number;
  16704. /**
  16705. * Gets or sets the maximal initial rotation in radians.
  16706. */
  16707. maxInitialRotation: number;
  16708. /**
  16709. * The particle emitter type defines the emitter used by the particle system.
  16710. * It can be for example box, sphere, or cone...
  16711. */
  16712. particleEmitterType: Nullable<IParticleEmitterType>;
  16713. /**
  16714. * Defines the delay in milliseconds before starting the system (0 by default)
  16715. */
  16716. startDelay: number;
  16717. /**
  16718. * 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
  16719. */
  16720. preWarmCycles: number;
  16721. /**
  16722. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16723. */
  16724. preWarmStepOffset: number;
  16725. /**
  16726. * 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)
  16727. */
  16728. spriteCellChangeSpeed: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16731. */
  16732. startSpriteCellID: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16735. */
  16736. endSpriteCellID: number;
  16737. /**
  16738. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16739. */
  16740. spriteCellWidth: number;
  16741. /**
  16742. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16743. */
  16744. spriteCellHeight: number;
  16745. /**
  16746. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16747. */
  16748. spriteRandomStartCell: boolean;
  16749. /**
  16750. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16751. */
  16752. isAnimationSheetEnabled: boolean;
  16753. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16754. translationPivot: Vector2;
  16755. /**
  16756. * Gets or sets a texture used to add random noise to particle positions
  16757. */
  16758. noiseTexture: Nullable<BaseTexture>;
  16759. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16760. noiseStrength: Vector3;
  16761. /**
  16762. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16763. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16764. */
  16765. billboardMode: number;
  16766. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16767. limitVelocityDamping: number;
  16768. /**
  16769. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16770. */
  16771. beginAnimationOnStart: boolean;
  16772. /**
  16773. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16774. */
  16775. beginAnimationFrom: number;
  16776. /**
  16777. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16778. */
  16779. beginAnimationTo: number;
  16780. /**
  16781. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16782. */
  16783. beginAnimationLoop: boolean;
  16784. /**
  16785. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16786. */
  16787. disposeOnStop: boolean;
  16788. /**
  16789. * Gets the maximum number of particles active at the same time.
  16790. * @returns The max number of active particles.
  16791. */
  16792. getCapacity(): number;
  16793. /**
  16794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16795. * @returns True if it has been started, otherwise false.
  16796. */
  16797. isStarted(): boolean;
  16798. /**
  16799. * Animates the particle system for this frame.
  16800. */
  16801. animate(): void;
  16802. /**
  16803. * Renders the particle system in its current state.
  16804. * @returns the current number of particles
  16805. */
  16806. render(): number;
  16807. /**
  16808. * Dispose the particle system and frees its associated resources.
  16809. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16810. */
  16811. dispose(disposeTexture?: boolean): void;
  16812. /**
  16813. * Clones the particle system.
  16814. * @param name The name of the cloned object
  16815. * @param newEmitter The new emitter to use
  16816. * @returns the cloned particle system
  16817. */
  16818. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16819. /**
  16820. * Serializes the particle system to a JSON object.
  16821. * @returns the JSON object
  16822. */
  16823. serialize(): any;
  16824. /**
  16825. * Rebuild the particle system
  16826. */
  16827. rebuild(): void;
  16828. /**
  16829. * Starts the particle system and begins to emit
  16830. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16831. */
  16832. start(delay?: number): void;
  16833. /**
  16834. * Stops the particle system.
  16835. */
  16836. stop(): void;
  16837. /**
  16838. * Remove all active particles
  16839. */
  16840. reset(): void;
  16841. /**
  16842. * Is this system ready to be used/rendered
  16843. * @return true if the system is ready
  16844. */
  16845. isReady(): boolean;
  16846. /**
  16847. * Adds a new color gradient
  16848. * @param gradient defines the gradient to use (between 0 and 1)
  16849. * @param color1 defines the color to affect to the specified gradient
  16850. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16851. * @returns the current particle system
  16852. */
  16853. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16854. /**
  16855. * Remove a specific color gradient
  16856. * @param gradient defines the gradient to remove
  16857. * @returns the current particle system
  16858. */
  16859. removeColorGradient(gradient: number): IParticleSystem;
  16860. /**
  16861. * Adds a new size gradient
  16862. * @param gradient defines the gradient to use (between 0 and 1)
  16863. * @param factor defines the size factor to affect to the specified gradient
  16864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16865. * @returns the current particle system
  16866. */
  16867. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16868. /**
  16869. * Remove a specific size gradient
  16870. * @param gradient defines the gradient to remove
  16871. * @returns the current particle system
  16872. */
  16873. removeSizeGradient(gradient: number): IParticleSystem;
  16874. /**
  16875. * Gets the current list of color gradients.
  16876. * You must use addColorGradient and removeColorGradient to udpate this list
  16877. * @returns the list of color gradients
  16878. */
  16879. getColorGradients(): Nullable<Array<ColorGradient>>;
  16880. /**
  16881. * Gets the current list of size gradients.
  16882. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16883. * @returns the list of size gradients
  16884. */
  16885. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16886. /**
  16887. * Gets the current list of angular speed gradients.
  16888. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16889. * @returns the list of angular speed gradients
  16890. */
  16891. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16892. /**
  16893. * Adds a new angular speed gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the angular speed to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific angular speed gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Gets the current list of velocity gradients.
  16908. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16909. * @returns the list of velocity gradients
  16910. */
  16911. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16912. /**
  16913. * Adds a new velocity gradient
  16914. * @param gradient defines the gradient to use (between 0 and 1)
  16915. * @param factor defines the velocity to affect to the specified gradient
  16916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16917. * @returns the current particle system
  16918. */
  16919. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16920. /**
  16921. * Remove a specific velocity gradient
  16922. * @param gradient defines the gradient to remove
  16923. * @returns the current particle system
  16924. */
  16925. removeVelocityGradient(gradient: number): IParticleSystem;
  16926. /**
  16927. * Gets the current list of limit velocity gradients.
  16928. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16929. * @returns the list of limit velocity gradients
  16930. */
  16931. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16932. /**
  16933. * Adds a new limit velocity gradient
  16934. * @param gradient defines the gradient to use (between 0 and 1)
  16935. * @param factor defines the limit velocity to affect to the specified gradient
  16936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16937. * @returns the current particle system
  16938. */
  16939. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16940. /**
  16941. * Remove a specific limit velocity gradient
  16942. * @param gradient defines the gradient to remove
  16943. * @returns the current particle system
  16944. */
  16945. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16946. /**
  16947. * Adds a new drag gradient
  16948. * @param gradient defines the gradient to use (between 0 and 1)
  16949. * @param factor defines the drag to affect to the specified gradient
  16950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16951. * @returns the current particle system
  16952. */
  16953. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16954. /**
  16955. * Remove a specific drag gradient
  16956. * @param gradient defines the gradient to remove
  16957. * @returns the current particle system
  16958. */
  16959. removeDragGradient(gradient: number): IParticleSystem;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /**
  16967. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16968. * @param gradient defines the gradient to use (between 0 and 1)
  16969. * @param factor defines the emit rate to affect to the specified gradient
  16970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16971. * @returns the current particle system
  16972. */
  16973. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16974. /**
  16975. * Remove a specific emit rate gradient
  16976. * @param gradient defines the gradient to remove
  16977. * @returns the current particle system
  16978. */
  16979. removeEmitRateGradient(gradient: number): IParticleSystem;
  16980. /**
  16981. * Gets the current list of emit rate gradients.
  16982. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16983. * @returns the list of emit rate gradients
  16984. */
  16985. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16988. * @param gradient defines the gradient to use (between 0 and 1)
  16989. * @param factor defines the start size to affect to the specified gradient
  16990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16991. * @returns the current particle system
  16992. */
  16993. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16994. /**
  16995. * Remove a specific start size gradient
  16996. * @param gradient defines the gradient to remove
  16997. * @returns the current particle system
  16998. */
  16999. removeStartSizeGradient(gradient: number): IParticleSystem;
  17000. /**
  17001. * Gets the current list of start size gradients.
  17002. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17003. * @returns the list of start size gradients
  17004. */
  17005. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17006. /**
  17007. * Adds a new life time gradient
  17008. * @param gradient defines the gradient to use (between 0 and 1)
  17009. * @param factor defines the life time factor to affect to the specified gradient
  17010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17011. * @returns the current particle system
  17012. */
  17013. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17014. /**
  17015. * Remove a specific life time gradient
  17016. * @param gradient defines the gradient to remove
  17017. * @returns the current particle system
  17018. */
  17019. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17020. /**
  17021. * Gets the current list of life time gradients.
  17022. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17023. * @returns the list of life time gradients
  17024. */
  17025. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17026. /**
  17027. * Gets the current list of color gradients.
  17028. * You must use addColorGradient and removeColorGradient to udpate this list
  17029. * @returns the list of color gradients
  17030. */
  17031. getColorGradients(): Nullable<Array<ColorGradient>>;
  17032. /**
  17033. * Adds a new ramp gradient used to remap particle colors
  17034. * @param gradient defines the gradient to use (between 0 and 1)
  17035. * @param color defines the color to affect to the specified gradient
  17036. * @returns the current particle system
  17037. */
  17038. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17039. /**
  17040. * Gets the current list of ramp gradients.
  17041. * You must use addRampGradient and removeRampGradient to udpate this list
  17042. * @returns the list of ramp gradients
  17043. */
  17044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17045. /** Gets or sets a boolean indicating that ramp gradients must be used
  17046. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17047. */
  17048. useRampGradients: boolean;
  17049. /**
  17050. * Adds a new color remap gradient
  17051. * @param gradient defines the gradient to use (between 0 and 1)
  17052. * @param min defines the color remap minimal range
  17053. * @param max defines the color remap maximal range
  17054. * @returns the current particle system
  17055. */
  17056. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17057. /**
  17058. * Gets the current list of color remap gradients.
  17059. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17060. * @returns the list of color remap gradients
  17061. */
  17062. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17063. /**
  17064. * Adds a new alpha remap gradient
  17065. * @param gradient defines the gradient to use (between 0 and 1)
  17066. * @param min defines the alpha remap minimal range
  17067. * @param max defines the alpha remap maximal range
  17068. * @returns the current particle system
  17069. */
  17070. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17071. /**
  17072. * Gets the current list of alpha remap gradients.
  17073. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17074. * @returns the list of alpha remap gradients
  17075. */
  17076. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17077. /**
  17078. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @returns the emitter
  17082. */
  17083. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17084. /**
  17085. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17086. * @param radius The radius of the hemisphere to emit from
  17087. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17088. * @returns the emitter
  17089. */
  17090. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17091. /**
  17092. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17093. * @param radius The radius of the sphere to emit from
  17094. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17095. * @returns the emitter
  17096. */
  17097. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17098. /**
  17099. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17100. * @param radius The radius of the sphere to emit from
  17101. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17102. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17103. * @returns the emitter
  17104. */
  17105. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17106. /**
  17107. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17108. * @param radius The radius of the emission cylinder
  17109. * @param height The height of the emission cylinder
  17110. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17111. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17112. * @returns the emitter
  17113. */
  17114. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17115. /**
  17116. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17117. * @param radius The radius of the cylinder to emit from
  17118. * @param height The height of the emission cylinder
  17119. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17120. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17121. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17122. * @returns the emitter
  17123. */
  17124. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17125. /**
  17126. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17127. * @param radius The radius of the cone to emit from
  17128. * @param angle The base angle of the cone
  17129. * @returns the emitter
  17130. */
  17131. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17132. /**
  17133. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17136. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17137. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17138. * @returns the emitter
  17139. */
  17140. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17141. /**
  17142. * Get hosting scene
  17143. * @returns the scene
  17144. */
  17145. getScene(): Scene;
  17146. }
  17147. }
  17148. declare module "babylonjs/Meshes/instancedMesh" {
  17149. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17150. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17151. import { Camera } from "babylonjs/Cameras/camera";
  17152. import { Node } from "babylonjs/node";
  17153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17154. import { Mesh } from "babylonjs/Meshes/mesh";
  17155. import { Material } from "babylonjs/Materials/material";
  17156. import { Skeleton } from "babylonjs/Bones/skeleton";
  17157. import { Light } from "babylonjs/Lights/light";
  17158. /**
  17159. * Creates an instance based on a source mesh.
  17160. */
  17161. export class InstancedMesh extends AbstractMesh {
  17162. private _sourceMesh;
  17163. private _currentLOD;
  17164. /** @hidden */
  17165. _indexInSourceMeshInstanceArray: number;
  17166. constructor(name: string, source: Mesh);
  17167. /**
  17168. * Returns the string "InstancedMesh".
  17169. */
  17170. getClassName(): string;
  17171. /** Gets the list of lights affecting that mesh */
  17172. readonly lightSources: Light[];
  17173. _resyncLightSources(): void;
  17174. _resyncLighSource(light: Light): void;
  17175. _removeLightSource(light: Light): void;
  17176. /**
  17177. * If the source mesh receives shadows
  17178. */
  17179. readonly receiveShadows: boolean;
  17180. /**
  17181. * The material of the source mesh
  17182. */
  17183. readonly material: Nullable<Material>;
  17184. /**
  17185. * Visibility of the source mesh
  17186. */
  17187. readonly visibility: number;
  17188. /**
  17189. * Skeleton of the source mesh
  17190. */
  17191. readonly skeleton: Nullable<Skeleton>;
  17192. /**
  17193. * Rendering ground id of the source mesh
  17194. */
  17195. renderingGroupId: number;
  17196. /**
  17197. * Returns the total number of vertices (integer).
  17198. */
  17199. getTotalVertices(): number;
  17200. /**
  17201. * Returns a positive integer : the total number of indices in this mesh geometry.
  17202. * @returns the numner of indices or zero if the mesh has no geometry.
  17203. */
  17204. getTotalIndices(): number;
  17205. /**
  17206. * The source mesh of the instance
  17207. */
  17208. readonly sourceMesh: Mesh;
  17209. /**
  17210. * Is this node ready to be used/rendered
  17211. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17212. * @return {boolean} is it ready
  17213. */
  17214. isReady(completeCheck?: boolean): boolean;
  17215. /**
  17216. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17217. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17218. * @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.
  17219. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17220. */
  17221. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17222. /**
  17223. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17224. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17225. * The `data` are either a numeric array either a Float32Array.
  17226. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17227. * 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).
  17228. * Note that a new underlying VertexBuffer object is created each call.
  17229. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17230. *
  17231. * Possible `kind` values :
  17232. * - VertexBuffer.PositionKind
  17233. * - VertexBuffer.UVKind
  17234. * - VertexBuffer.UV2Kind
  17235. * - VertexBuffer.UV3Kind
  17236. * - VertexBuffer.UV4Kind
  17237. * - VertexBuffer.UV5Kind
  17238. * - VertexBuffer.UV6Kind
  17239. * - VertexBuffer.ColorKind
  17240. * - VertexBuffer.MatricesIndicesKind
  17241. * - VertexBuffer.MatricesIndicesExtraKind
  17242. * - VertexBuffer.MatricesWeightsKind
  17243. * - VertexBuffer.MatricesWeightsExtraKind
  17244. *
  17245. * Returns the Mesh.
  17246. */
  17247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17248. /**
  17249. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17250. * If the mesh has no geometry, it is simply returned as it is.
  17251. * The `data` are either a numeric array either a Float32Array.
  17252. * No new underlying VertexBuffer object is created.
  17253. * 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.
  17254. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17255. *
  17256. * Possible `kind` values :
  17257. * - VertexBuffer.PositionKind
  17258. * - VertexBuffer.UVKind
  17259. * - VertexBuffer.UV2Kind
  17260. * - VertexBuffer.UV3Kind
  17261. * - VertexBuffer.UV4Kind
  17262. * - VertexBuffer.UV5Kind
  17263. * - VertexBuffer.UV6Kind
  17264. * - VertexBuffer.ColorKind
  17265. * - VertexBuffer.MatricesIndicesKind
  17266. * - VertexBuffer.MatricesIndicesExtraKind
  17267. * - VertexBuffer.MatricesWeightsKind
  17268. * - VertexBuffer.MatricesWeightsExtraKind
  17269. *
  17270. * Returns the Mesh.
  17271. */
  17272. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17273. /**
  17274. * Sets the mesh indices.
  17275. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17276. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17277. * This method creates a new index buffer each call.
  17278. * Returns the Mesh.
  17279. */
  17280. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17281. /**
  17282. * Boolean : True if the mesh owns the requested kind of data.
  17283. */
  17284. isVerticesDataPresent(kind: string): boolean;
  17285. /**
  17286. * Returns an array of indices (IndicesArray).
  17287. */
  17288. getIndices(): Nullable<IndicesArray>;
  17289. readonly _positions: Nullable<Vector3[]>;
  17290. /**
  17291. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17292. * This means the mesh underlying bounding box and sphere are recomputed.
  17293. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17294. * @returns the current mesh
  17295. */
  17296. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17297. /** @hidden */
  17298. _preActivate(): InstancedMesh;
  17299. /** @hidden */
  17300. _activate(renderId: number): boolean;
  17301. /** @hidden */
  17302. _postActivate(): void;
  17303. getWorldMatrix(): Matrix;
  17304. readonly isAnInstance: boolean;
  17305. /**
  17306. * Returns the current associated LOD AbstractMesh.
  17307. */
  17308. getLOD(camera: Camera): AbstractMesh;
  17309. /** @hidden */
  17310. _syncSubMeshes(): InstancedMesh;
  17311. /** @hidden */
  17312. _generatePointsArray(): boolean;
  17313. /**
  17314. * Creates a new InstancedMesh from the current mesh.
  17315. * - name (string) : the cloned mesh name
  17316. * - newParent (optional Node) : the optional Node to parent the clone to.
  17317. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17318. *
  17319. * Returns the clone.
  17320. */
  17321. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17322. /**
  17323. * Disposes the InstancedMesh.
  17324. * Returns nothing.
  17325. */
  17326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17327. }
  17328. }
  17329. declare module "babylonjs/Materials/shaderMaterial" {
  17330. import { Scene } from "babylonjs/scene";
  17331. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17333. import { Mesh } from "babylonjs/Meshes/mesh";
  17334. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17336. import { Texture } from "babylonjs/Materials/Textures/texture";
  17337. import { Material } from "babylonjs/Materials/material";
  17338. /**
  17339. * Defines the options associated with the creation of a shader material.
  17340. */
  17341. export interface IShaderMaterialOptions {
  17342. /**
  17343. * Does the material work in alpha blend mode
  17344. */
  17345. needAlphaBlending: boolean;
  17346. /**
  17347. * Does the material work in alpha test mode
  17348. */
  17349. needAlphaTesting: boolean;
  17350. /**
  17351. * The list of attribute names used in the shader
  17352. */
  17353. attributes: string[];
  17354. /**
  17355. * The list of unifrom names used in the shader
  17356. */
  17357. uniforms: string[];
  17358. /**
  17359. * The list of UBO names used in the shader
  17360. */
  17361. uniformBuffers: string[];
  17362. /**
  17363. * The list of sampler names used in the shader
  17364. */
  17365. samplers: string[];
  17366. /**
  17367. * The list of defines used in the shader
  17368. */
  17369. defines: string[];
  17370. }
  17371. /**
  17372. * 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.
  17373. *
  17374. * This returned material effects how the mesh will look based on the code in the shaders.
  17375. *
  17376. * @see http://doc.babylonjs.com/how_to/shader_material
  17377. */
  17378. export class ShaderMaterial extends Material {
  17379. private _shaderPath;
  17380. private _options;
  17381. private _textures;
  17382. private _textureArrays;
  17383. private _floats;
  17384. private _ints;
  17385. private _floatsArrays;
  17386. private _colors3;
  17387. private _colors3Arrays;
  17388. private _colors4;
  17389. private _vectors2;
  17390. private _vectors3;
  17391. private _vectors4;
  17392. private _matrices;
  17393. private _matrices3x3;
  17394. private _matrices2x2;
  17395. private _vectors2Arrays;
  17396. private _vectors3Arrays;
  17397. private _cachedWorldViewMatrix;
  17398. private _renderId;
  17399. /**
  17400. * Instantiate a new shader material.
  17401. * 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.
  17402. * This returned material effects how the mesh will look based on the code in the shaders.
  17403. * @see http://doc.babylonjs.com/how_to/shader_material
  17404. * @param name Define the name of the material in the scene
  17405. * @param scene Define the scene the material belongs to
  17406. * @param shaderPath Defines the route to the shader code in one of three ways:
  17407. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17408. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17409. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17410. * @param options Define the options used to create the shader
  17411. */
  17412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17413. /**
  17414. * Gets the options used to compile the shader.
  17415. * They can be modified to trigger a new compilation
  17416. */
  17417. readonly options: IShaderMaterialOptions;
  17418. /**
  17419. * Gets the current class name of the material e.g. "ShaderMaterial"
  17420. * Mainly use in serialization.
  17421. * @returns the class name
  17422. */
  17423. getClassName(): string;
  17424. /**
  17425. * Specifies if the material will require alpha blending
  17426. * @returns a boolean specifying if alpha blending is needed
  17427. */
  17428. needAlphaBlending(): boolean;
  17429. /**
  17430. * Specifies if this material should be rendered in alpha test mode
  17431. * @returns a boolean specifying if an alpha test is needed.
  17432. */
  17433. needAlphaTesting(): boolean;
  17434. private _checkUniform;
  17435. /**
  17436. * Set a texture in the shader.
  17437. * @param name Define the name of the uniform samplers as defined in the shader
  17438. * @param texture Define the texture to bind to this sampler
  17439. * @return the material itself allowing "fluent" like uniform updates
  17440. */
  17441. setTexture(name: string, texture: Texture): ShaderMaterial;
  17442. /**
  17443. * Set a texture array in the shader.
  17444. * @param name Define the name of the uniform sampler array as defined in the shader
  17445. * @param textures Define the list of textures to bind to this sampler
  17446. * @return the material itself allowing "fluent" like uniform updates
  17447. */
  17448. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17449. /**
  17450. * Set a float in the shader.
  17451. * @param name Define the name of the uniform as defined in the shader
  17452. * @param value Define the value to give to the uniform
  17453. * @return the material itself allowing "fluent" like uniform updates
  17454. */
  17455. setFloat(name: string, value: number): ShaderMaterial;
  17456. /**
  17457. * Set a int in the shader.
  17458. * @param name Define the name of the uniform as defined in the shader
  17459. * @param value Define the value to give to the uniform
  17460. * @return the material itself allowing "fluent" like uniform updates
  17461. */
  17462. setInt(name: string, value: number): ShaderMaterial;
  17463. /**
  17464. * Set an array of floats in the shader.
  17465. * @param name Define the name of the uniform as defined in the shader
  17466. * @param value Define the value to give to the uniform
  17467. * @return the material itself allowing "fluent" like uniform updates
  17468. */
  17469. setFloats(name: string, value: number[]): ShaderMaterial;
  17470. /**
  17471. * Set a vec3 in the shader from a Color3.
  17472. * @param name Define the name of the uniform as defined in the shader
  17473. * @param value Define the value to give to the uniform
  17474. * @return the material itself allowing "fluent" like uniform updates
  17475. */
  17476. setColor3(name: string, value: Color3): ShaderMaterial;
  17477. /**
  17478. * Set a vec3 array in the shader from a Color3 array.
  17479. * @param name Define the name of the uniform as defined in the shader
  17480. * @param value Define the value to give to the uniform
  17481. * @return the material itself allowing "fluent" like uniform updates
  17482. */
  17483. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17484. /**
  17485. * Set a vec4 in the shader from a Color4.
  17486. * @param name Define the name of the uniform as defined in the shader
  17487. * @param value Define the value to give to the uniform
  17488. * @return the material itself allowing "fluent" like uniform updates
  17489. */
  17490. setColor4(name: string, value: Color4): ShaderMaterial;
  17491. /**
  17492. * Set a vec2 in the shader from a Vector2.
  17493. * @param name Define the name of the uniform as defined in the shader
  17494. * @param value Define the value to give to the uniform
  17495. * @return the material itself allowing "fluent" like uniform updates
  17496. */
  17497. setVector2(name: string, value: Vector2): ShaderMaterial;
  17498. /**
  17499. * Set a vec3 in the shader from a Vector3.
  17500. * @param name Define the name of the uniform as defined in the shader
  17501. * @param value Define the value to give to the uniform
  17502. * @return the material itself allowing "fluent" like uniform updates
  17503. */
  17504. setVector3(name: string, value: Vector3): ShaderMaterial;
  17505. /**
  17506. * Set a vec4 in the shader from a Vector4.
  17507. * @param name Define the name of the uniform as defined in the shader
  17508. * @param value Define the value to give to the uniform
  17509. * @return the material itself allowing "fluent" like uniform updates
  17510. */
  17511. setVector4(name: string, value: Vector4): ShaderMaterial;
  17512. /**
  17513. * Set a mat4 in the shader from a Matrix.
  17514. * @param name Define the name of the uniform as defined in the shader
  17515. * @param value Define the value to give to the uniform
  17516. * @return the material itself allowing "fluent" like uniform updates
  17517. */
  17518. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17519. /**
  17520. * Set a mat3 in the shader from a Float32Array.
  17521. * @param name Define the name of the uniform as defined in the shader
  17522. * @param value Define the value to give to the uniform
  17523. * @return the material itself allowing "fluent" like uniform updates
  17524. */
  17525. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17526. /**
  17527. * Set a mat2 in the shader from a Float32Array.
  17528. * @param name Define the name of the uniform as defined in the shader
  17529. * @param value Define the value to give to the uniform
  17530. * @return the material itself allowing "fluent" like uniform updates
  17531. */
  17532. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17533. /**
  17534. * Set a vec2 array in the shader from a number array.
  17535. * @param name Define the name of the uniform as defined in the shader
  17536. * @param value Define the value to give to the uniform
  17537. * @return the material itself allowing "fluent" like uniform updates
  17538. */
  17539. setArray2(name: string, value: number[]): ShaderMaterial;
  17540. /**
  17541. * Set a vec3 array in the shader from a number array.
  17542. * @param name Define the name of the uniform as defined in the shader
  17543. * @param value Define the value to give to the uniform
  17544. * @return the material itself allowing "fluent" like uniform updates
  17545. */
  17546. setArray3(name: string, value: number[]): ShaderMaterial;
  17547. private _checkCache;
  17548. /**
  17549. * Specifies that the submesh is ready to be used
  17550. * @param mesh defines the mesh to check
  17551. * @param subMesh defines which submesh to check
  17552. * @param useInstances specifies that instances should be used
  17553. * @returns a boolean indicating that the submesh is ready or not
  17554. */
  17555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17556. /**
  17557. * Checks if the material is ready to render the requested mesh
  17558. * @param mesh Define the mesh to render
  17559. * @param useInstances Define whether or not the material is used with instances
  17560. * @returns true if ready, otherwise false
  17561. */
  17562. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17563. /**
  17564. * Binds the world matrix to the material
  17565. * @param world defines the world transformation matrix
  17566. */
  17567. bindOnlyWorldMatrix(world: Matrix): void;
  17568. /**
  17569. * Binds the material to the mesh
  17570. * @param world defines the world transformation matrix
  17571. * @param mesh defines the mesh to bind the material to
  17572. */
  17573. bind(world: Matrix, mesh?: Mesh): void;
  17574. /**
  17575. * Gets the active textures from the material
  17576. * @returns an array of textures
  17577. */
  17578. getActiveTextures(): BaseTexture[];
  17579. /**
  17580. * Specifies if the material uses a texture
  17581. * @param texture defines the texture to check against the material
  17582. * @returns a boolean specifying if the material uses the texture
  17583. */
  17584. hasTexture(texture: BaseTexture): boolean;
  17585. /**
  17586. * Makes a duplicate of the material, and gives it a new name
  17587. * @param name defines the new name for the duplicated material
  17588. * @returns the cloned material
  17589. */
  17590. clone(name: string): ShaderMaterial;
  17591. /**
  17592. * Disposes the material
  17593. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17594. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17595. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17596. */
  17597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17598. /**
  17599. * Serializes this material in a JSON representation
  17600. * @returns the serialized material object
  17601. */
  17602. serialize(): any;
  17603. /**
  17604. * Creates a shader material from parsed shader material data
  17605. * @param source defines the JSON represnetation of the material
  17606. * @param scene defines the hosting scene
  17607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17608. * @returns a new material
  17609. */
  17610. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17611. }
  17612. }
  17613. declare module "babylonjs/Shaders/color.fragment" {
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17616. /** @hidden */
  17617. export var colorPixelShader: {
  17618. name: string;
  17619. shader: string;
  17620. };
  17621. }
  17622. declare module "babylonjs/Shaders/color.vertex" {
  17623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17625. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17626. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17627. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17628. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17629. /** @hidden */
  17630. export var colorVertexShader: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Meshes/linesMesh" {
  17636. import { Nullable } from "babylonjs/types";
  17637. import { Scene } from "babylonjs/scene";
  17638. import { Color3 } from "babylonjs/Maths/math";
  17639. import { Node } from "babylonjs/node";
  17640. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17641. import { Mesh } from "babylonjs/Meshes/mesh";
  17642. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17643. import { Effect } from "babylonjs/Materials/effect";
  17644. import { Material } from "babylonjs/Materials/material";
  17645. import "babylonjs/Shaders/color.fragment";
  17646. import "babylonjs/Shaders/color.vertex";
  17647. /**
  17648. * Line mesh
  17649. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17650. */
  17651. export class LinesMesh extends Mesh {
  17652. /**
  17653. * If vertex color should be applied to the mesh
  17654. */
  17655. useVertexColor?: boolean | undefined;
  17656. /**
  17657. * If vertex alpha should be applied to the mesh
  17658. */
  17659. useVertexAlpha?: boolean | undefined;
  17660. /**
  17661. * Color of the line (Default: White)
  17662. */
  17663. color: Color3;
  17664. /**
  17665. * Alpha of the line (Default: 1)
  17666. */
  17667. alpha: number;
  17668. /**
  17669. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17670. * This margin is expressed in world space coordinates, so its value may vary.
  17671. * Default value is 0.1
  17672. */
  17673. intersectionThreshold: number;
  17674. private _colorShader;
  17675. /**
  17676. * Creates a new LinesMesh
  17677. * @param name defines the name
  17678. * @param scene defines the hosting scene
  17679. * @param parent defines the parent mesh if any
  17680. * @param source defines the optional source LinesMesh used to clone data from
  17681. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17682. * When false, achieved by calling a clone(), also passing False.
  17683. * This will make creation of children, recursive.
  17684. * @param useVertexColor defines if this LinesMesh supports vertex color
  17685. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17686. */
  17687. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17688. /**
  17689. * If vertex color should be applied to the mesh
  17690. */
  17691. useVertexColor?: boolean | undefined,
  17692. /**
  17693. * If vertex alpha should be applied to the mesh
  17694. */
  17695. useVertexAlpha?: boolean | undefined);
  17696. private _addClipPlaneDefine;
  17697. private _removeClipPlaneDefine;
  17698. isReady(): boolean;
  17699. /**
  17700. * Returns the string "LineMesh"
  17701. */
  17702. getClassName(): string;
  17703. /**
  17704. * @hidden
  17705. */
  17706. /**
  17707. * @hidden
  17708. */
  17709. material: Material;
  17710. /**
  17711. * @hidden
  17712. */
  17713. readonly checkCollisions: boolean;
  17714. /** @hidden */
  17715. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17716. /** @hidden */
  17717. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17718. /**
  17719. * Disposes of the line mesh
  17720. * @param doNotRecurse If children should be disposed
  17721. */
  17722. dispose(doNotRecurse?: boolean): void;
  17723. /**
  17724. * Returns a new LineMesh object cloned from the current one.
  17725. */
  17726. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17727. /**
  17728. * Creates a new InstancedLinesMesh object from the mesh model.
  17729. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17730. * @param name defines the name of the new instance
  17731. * @returns a new InstancedLinesMesh
  17732. */
  17733. createInstance(name: string): InstancedLinesMesh;
  17734. }
  17735. /**
  17736. * Creates an instance based on a source LinesMesh
  17737. */
  17738. export class InstancedLinesMesh extends InstancedMesh {
  17739. /**
  17740. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17741. * This margin is expressed in world space coordinates, so its value may vary.
  17742. * Initilized with the intersectionThreshold value of the source LinesMesh
  17743. */
  17744. intersectionThreshold: number;
  17745. constructor(name: string, source: LinesMesh);
  17746. /**
  17747. * Returns the string "InstancedLinesMesh".
  17748. */
  17749. getClassName(): string;
  17750. }
  17751. }
  17752. declare module "babylonjs/Shaders/line.fragment" {
  17753. /** @hidden */
  17754. export var linePixelShader: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/line.vertex" {
  17760. /** @hidden */
  17761. export var lineVertexShader: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Rendering/edgesRenderer" {
  17767. import { Nullable } from "babylonjs/types";
  17768. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17770. import { Vector3 } from "babylonjs/Maths/math";
  17771. import { IDisposable } from "babylonjs/scene";
  17772. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17773. import "babylonjs/Shaders/line.fragment";
  17774. import "babylonjs/Shaders/line.vertex";
  17775. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17776. module "babylonjs/Meshes/abstractMesh" {
  17777. interface AbstractMesh {
  17778. /**
  17779. * Disables the mesh edge rendering mode
  17780. * @returns the currentAbstractMesh
  17781. */
  17782. disableEdgesRendering(): AbstractMesh;
  17783. /**
  17784. * Enables the edge rendering mode on the mesh.
  17785. * This mode makes the mesh edges visible
  17786. * @param epsilon defines the maximal distance between two angles to detect a face
  17787. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17788. * @returns the currentAbstractMesh
  17789. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17790. */
  17791. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17792. /**
  17793. * Gets the edgesRenderer associated with the mesh
  17794. */
  17795. edgesRenderer: Nullable<EdgesRenderer>;
  17796. }
  17797. }
  17798. module "babylonjs/Meshes/linesMesh" {
  17799. interface LinesMesh {
  17800. /**
  17801. * Enables the edge rendering mode on the mesh.
  17802. * This mode makes the mesh edges visible
  17803. * @param epsilon defines the maximal distance between two angles to detect a face
  17804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17805. * @returns the currentAbstractMesh
  17806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17807. */
  17808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17809. }
  17810. }
  17811. module "babylonjs/Meshes/linesMesh" {
  17812. interface InstancedLinesMesh {
  17813. /**
  17814. * Enables the edge rendering mode on the mesh.
  17815. * This mode makes the mesh edges visible
  17816. * @param epsilon defines the maximal distance between two angles to detect a face
  17817. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17818. * @returns the current InstancedLinesMesh
  17819. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17820. */
  17821. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17822. }
  17823. }
  17824. /**
  17825. * Defines the minimum contract an Edges renderer should follow.
  17826. */
  17827. export interface IEdgesRenderer extends IDisposable {
  17828. /**
  17829. * Gets or sets a boolean indicating if the edgesRenderer is active
  17830. */
  17831. isEnabled: boolean;
  17832. /**
  17833. * Renders the edges of the attached mesh,
  17834. */
  17835. render(): void;
  17836. /**
  17837. * Checks wether or not the edges renderer is ready to render.
  17838. * @return true if ready, otherwise false.
  17839. */
  17840. isReady(): boolean;
  17841. }
  17842. /**
  17843. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17844. */
  17845. export class EdgesRenderer implements IEdgesRenderer {
  17846. /**
  17847. * Define the size of the edges with an orthographic camera
  17848. */
  17849. edgesWidthScalerForOrthographic: number;
  17850. /**
  17851. * Define the size of the edges with a perspective camera
  17852. */
  17853. edgesWidthScalerForPerspective: number;
  17854. protected _source: AbstractMesh;
  17855. protected _linesPositions: number[];
  17856. protected _linesNormals: number[];
  17857. protected _linesIndices: number[];
  17858. protected _epsilon: number;
  17859. protected _indicesCount: number;
  17860. protected _lineShader: ShaderMaterial;
  17861. protected _ib: DataBuffer;
  17862. protected _buffers: {
  17863. [key: string]: Nullable<VertexBuffer>;
  17864. };
  17865. protected _checkVerticesInsteadOfIndices: boolean;
  17866. private _meshRebuildObserver;
  17867. private _meshDisposeObserver;
  17868. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17869. isEnabled: boolean;
  17870. /**
  17871. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17872. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17873. * @param source Mesh used to create edges
  17874. * @param epsilon sum of angles in adjacency to check for edge
  17875. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17876. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17877. */
  17878. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17879. protected _prepareRessources(): void;
  17880. /** @hidden */
  17881. _rebuild(): void;
  17882. /**
  17883. * Releases the required resources for the edges renderer
  17884. */
  17885. dispose(): void;
  17886. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17887. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17888. /**
  17889. * Checks if the pair of p0 and p1 is en edge
  17890. * @param faceIndex
  17891. * @param edge
  17892. * @param faceNormals
  17893. * @param p0
  17894. * @param p1
  17895. * @private
  17896. */
  17897. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17898. /**
  17899. * push line into the position, normal and index buffer
  17900. * @protected
  17901. */
  17902. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17903. /**
  17904. * Generates lines edges from adjacencjes
  17905. * @private
  17906. */
  17907. _generateEdgesLines(): void;
  17908. /**
  17909. * Checks wether or not the edges renderer is ready to render.
  17910. * @return true if ready, otherwise false.
  17911. */
  17912. isReady(): boolean;
  17913. /**
  17914. * Renders the edges of the attached mesh,
  17915. */
  17916. render(): void;
  17917. }
  17918. /**
  17919. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17920. */
  17921. export class LineEdgesRenderer extends EdgesRenderer {
  17922. /**
  17923. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17924. * @param source LineMesh used to generate edges
  17925. * @param epsilon not important (specified angle for edge detection)
  17926. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17927. */
  17928. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17929. /**
  17930. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17931. */
  17932. _generateEdgesLines(): void;
  17933. }
  17934. }
  17935. declare module "babylonjs/Rendering/renderingGroup" {
  17936. import { SmartArray } from "babylonjs/Misc/smartArray";
  17937. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17939. import { Nullable } from "babylonjs/types";
  17940. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17941. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17942. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17943. import { Material } from "babylonjs/Materials/material";
  17944. import { Scene } from "babylonjs/scene";
  17945. /**
  17946. * This represents the object necessary to create a rendering group.
  17947. * This is exclusively used and created by the rendering manager.
  17948. * To modify the behavior, you use the available helpers in your scene or meshes.
  17949. * @hidden
  17950. */
  17951. export class RenderingGroup {
  17952. index: number;
  17953. private _scene;
  17954. private _opaqueSubMeshes;
  17955. private _transparentSubMeshes;
  17956. private _alphaTestSubMeshes;
  17957. private _depthOnlySubMeshes;
  17958. private _particleSystems;
  17959. private _spriteManagers;
  17960. private _opaqueSortCompareFn;
  17961. private _alphaTestSortCompareFn;
  17962. private _transparentSortCompareFn;
  17963. private _renderOpaque;
  17964. private _renderAlphaTest;
  17965. private _renderTransparent;
  17966. /** @hidden */
  17967. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17968. onBeforeTransparentRendering: () => void;
  17969. /**
  17970. * Set the opaque sort comparison function.
  17971. * If null the sub meshes will be render in the order they were created
  17972. */
  17973. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17974. /**
  17975. * Set the alpha test sort comparison function.
  17976. * If null the sub meshes will be render in the order they were created
  17977. */
  17978. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17979. /**
  17980. * Set the transparent sort comparison function.
  17981. * If null the sub meshes will be render in the order they were created
  17982. */
  17983. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17984. /**
  17985. * Creates a new rendering group.
  17986. * @param index The rendering group index
  17987. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17988. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17989. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17990. */
  17991. 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>);
  17992. /**
  17993. * Render all the sub meshes contained in the group.
  17994. * @param customRenderFunction Used to override the default render behaviour of the group.
  17995. * @returns true if rendered some submeshes.
  17996. */
  17997. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17998. /**
  17999. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18000. * @param subMeshes The submeshes to render
  18001. */
  18002. private renderOpaqueSorted;
  18003. /**
  18004. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18005. * @param subMeshes The submeshes to render
  18006. */
  18007. private renderAlphaTestSorted;
  18008. /**
  18009. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18010. * @param subMeshes The submeshes to render
  18011. */
  18012. private renderTransparentSorted;
  18013. /**
  18014. * Renders the submeshes in a specified order.
  18015. * @param subMeshes The submeshes to sort before render
  18016. * @param sortCompareFn The comparison function use to sort
  18017. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18018. * @param transparent Specifies to activate blending if true
  18019. */
  18020. private static renderSorted;
  18021. /**
  18022. * Renders the submeshes in the order they were dispatched (no sort applied).
  18023. * @param subMeshes The submeshes to render
  18024. */
  18025. private static renderUnsorted;
  18026. /**
  18027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18028. * are rendered back to front if in the same alpha index.
  18029. *
  18030. * @param a The first submesh
  18031. * @param b The second submesh
  18032. * @returns The result of the comparison
  18033. */
  18034. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18035. /**
  18036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18037. * are rendered back to front.
  18038. *
  18039. * @param a The first submesh
  18040. * @param b The second submesh
  18041. * @returns The result of the comparison
  18042. */
  18043. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18044. /**
  18045. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18046. * are rendered front to back (prevent overdraw).
  18047. *
  18048. * @param a The first submesh
  18049. * @param b The second submesh
  18050. * @returns The result of the comparison
  18051. */
  18052. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18053. /**
  18054. * Resets the different lists of submeshes to prepare a new frame.
  18055. */
  18056. prepare(): void;
  18057. dispose(): void;
  18058. /**
  18059. * Inserts the submesh in its correct queue depending on its material.
  18060. * @param subMesh The submesh to dispatch
  18061. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18062. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18063. */
  18064. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18065. dispatchSprites(spriteManager: ISpriteManager): void;
  18066. dispatchParticles(particleSystem: IParticleSystem): void;
  18067. private _renderParticles;
  18068. private _renderSprites;
  18069. }
  18070. }
  18071. declare module "babylonjs/Rendering/renderingManager" {
  18072. import { Nullable } from "babylonjs/types";
  18073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18075. import { SmartArray } from "babylonjs/Misc/smartArray";
  18076. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18077. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18078. import { Material } from "babylonjs/Materials/material";
  18079. import { Scene } from "babylonjs/scene";
  18080. import { Camera } from "babylonjs/Cameras/camera";
  18081. /**
  18082. * Interface describing the different options available in the rendering manager
  18083. * regarding Auto Clear between groups.
  18084. */
  18085. export interface IRenderingManagerAutoClearSetup {
  18086. /**
  18087. * Defines whether or not autoclear is enable.
  18088. */
  18089. autoClear: boolean;
  18090. /**
  18091. * Defines whether or not to autoclear the depth buffer.
  18092. */
  18093. depth: boolean;
  18094. /**
  18095. * Defines whether or not to autoclear the stencil buffer.
  18096. */
  18097. stencil: boolean;
  18098. }
  18099. /**
  18100. * This class is used by the onRenderingGroupObservable
  18101. */
  18102. export class RenderingGroupInfo {
  18103. /**
  18104. * The Scene that being rendered
  18105. */
  18106. scene: Scene;
  18107. /**
  18108. * The camera currently used for the rendering pass
  18109. */
  18110. camera: Nullable<Camera>;
  18111. /**
  18112. * The ID of the renderingGroup being processed
  18113. */
  18114. renderingGroupId: number;
  18115. }
  18116. /**
  18117. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18118. * It is enable to manage the different groups as well as the different necessary sort functions.
  18119. * This should not be used directly aside of the few static configurations
  18120. */
  18121. export class RenderingManager {
  18122. /**
  18123. * The max id used for rendering groups (not included)
  18124. */
  18125. static MAX_RENDERINGGROUPS: number;
  18126. /**
  18127. * The min id used for rendering groups (included)
  18128. */
  18129. static MIN_RENDERINGGROUPS: number;
  18130. /**
  18131. * Used to globally prevent autoclearing scenes.
  18132. */
  18133. static AUTOCLEAR: boolean;
  18134. /**
  18135. * @hidden
  18136. */
  18137. _useSceneAutoClearSetup: boolean;
  18138. private _scene;
  18139. private _renderingGroups;
  18140. private _depthStencilBufferAlreadyCleaned;
  18141. private _autoClearDepthStencil;
  18142. private _customOpaqueSortCompareFn;
  18143. private _customAlphaTestSortCompareFn;
  18144. private _customTransparentSortCompareFn;
  18145. private _renderingGroupInfo;
  18146. /**
  18147. * Instantiates a new rendering group for a particular scene
  18148. * @param scene Defines the scene the groups belongs to
  18149. */
  18150. constructor(scene: Scene);
  18151. private _clearDepthStencilBuffer;
  18152. /**
  18153. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18154. * @hidden
  18155. */
  18156. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18157. /**
  18158. * Resets the different information of the group to prepare a new frame
  18159. * @hidden
  18160. */
  18161. reset(): void;
  18162. /**
  18163. * Dispose and release the group and its associated resources.
  18164. * @hidden
  18165. */
  18166. dispose(): void;
  18167. /**
  18168. * Clear the info related to rendering groups preventing retention points during dispose.
  18169. */
  18170. freeRenderingGroups(): void;
  18171. private _prepareRenderingGroup;
  18172. /**
  18173. * Add a sprite manager to the rendering manager in order to render it this frame.
  18174. * @param spriteManager Define the sprite manager to render
  18175. */
  18176. dispatchSprites(spriteManager: ISpriteManager): void;
  18177. /**
  18178. * Add a particle system to the rendering manager in order to render it this frame.
  18179. * @param particleSystem Define the particle system to render
  18180. */
  18181. dispatchParticles(particleSystem: IParticleSystem): void;
  18182. /**
  18183. * Add a submesh to the manager in order to render it this frame
  18184. * @param subMesh The submesh to dispatch
  18185. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18186. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18187. */
  18188. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18189. /**
  18190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18191. * This allowed control for front to back rendering or reversly depending of the special needs.
  18192. *
  18193. * @param renderingGroupId The rendering group id corresponding to its index
  18194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18197. */
  18198. 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;
  18199. /**
  18200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18201. *
  18202. * @param renderingGroupId The rendering group id corresponding to its index
  18203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18206. */
  18207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18208. /**
  18209. * Gets the current auto clear configuration for one rendering group of the rendering
  18210. * manager.
  18211. * @param index the rendering group index to get the information for
  18212. * @returns The auto clear setup for the requested rendering group
  18213. */
  18214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18215. }
  18216. }
  18217. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18218. import { Observable } from "babylonjs/Misc/observable";
  18219. import { SmartArray } from "babylonjs/Misc/smartArray";
  18220. import { Nullable } from "babylonjs/types";
  18221. import { Camera } from "babylonjs/Cameras/camera";
  18222. import { Scene } from "babylonjs/scene";
  18223. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18224. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18228. import { Texture } from "babylonjs/Materials/Textures/texture";
  18229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18230. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18231. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18232. import { Engine } from "babylonjs/Engines/engine";
  18233. /**
  18234. * This Helps creating a texture that will be created from a camera in your scene.
  18235. * It is basically a dynamic texture that could be used to create special effects for instance.
  18236. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18237. */
  18238. export class RenderTargetTexture extends Texture {
  18239. isCube: boolean;
  18240. /**
  18241. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18242. */
  18243. static readonly REFRESHRATE_RENDER_ONCE: number;
  18244. /**
  18245. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18246. */
  18247. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18248. /**
  18249. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18250. * the central point of your effect and can save a lot of performances.
  18251. */
  18252. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18253. /**
  18254. * Use this predicate to dynamically define the list of mesh you want to render.
  18255. * If set, the renderList property will be overwritten.
  18256. */
  18257. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18258. private _renderList;
  18259. /**
  18260. * Use this list to define the list of mesh you want to render.
  18261. */
  18262. renderList: Nullable<Array<AbstractMesh>>;
  18263. private _hookArray;
  18264. /**
  18265. * Define if particles should be rendered in your texture.
  18266. */
  18267. renderParticles: boolean;
  18268. /**
  18269. * Define if sprites should be rendered in your texture.
  18270. */
  18271. renderSprites: boolean;
  18272. /**
  18273. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18274. */
  18275. coordinatesMode: number;
  18276. /**
  18277. * Define the camera used to render the texture.
  18278. */
  18279. activeCamera: Nullable<Camera>;
  18280. /**
  18281. * Override the render function of the texture with your own one.
  18282. */
  18283. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18284. /**
  18285. * Define if camera post processes should be use while rendering the texture.
  18286. */
  18287. useCameraPostProcesses: boolean;
  18288. /**
  18289. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18290. */
  18291. ignoreCameraViewport: boolean;
  18292. private _postProcessManager;
  18293. private _postProcesses;
  18294. private _resizeObserver;
  18295. /**
  18296. * An event triggered when the texture is unbind.
  18297. */
  18298. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18299. /**
  18300. * An event triggered when the texture is unbind.
  18301. */
  18302. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18303. private _onAfterUnbindObserver;
  18304. /**
  18305. * Set a after unbind callback in the texture.
  18306. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18307. */
  18308. onAfterUnbind: () => void;
  18309. /**
  18310. * An event triggered before rendering the texture
  18311. */
  18312. onBeforeRenderObservable: Observable<number>;
  18313. private _onBeforeRenderObserver;
  18314. /**
  18315. * Set a before render callback in the texture.
  18316. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18317. */
  18318. onBeforeRender: (faceIndex: number) => void;
  18319. /**
  18320. * An event triggered after rendering the texture
  18321. */
  18322. onAfterRenderObservable: Observable<number>;
  18323. private _onAfterRenderObserver;
  18324. /**
  18325. * Set a after render callback in the texture.
  18326. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18327. */
  18328. onAfterRender: (faceIndex: number) => void;
  18329. /**
  18330. * An event triggered after the texture clear
  18331. */
  18332. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18333. private _onClearObserver;
  18334. /**
  18335. * Set a clear callback in the texture.
  18336. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18337. */
  18338. onClear: (Engine: Engine) => void;
  18339. /**
  18340. * Define the clear color of the Render Target if it should be different from the scene.
  18341. */
  18342. clearColor: Color4;
  18343. protected _size: number | {
  18344. width: number;
  18345. height: number;
  18346. };
  18347. protected _initialSizeParameter: number | {
  18348. width: number;
  18349. height: number;
  18350. } | {
  18351. ratio: number;
  18352. };
  18353. protected _sizeRatio: Nullable<number>;
  18354. /** @hidden */
  18355. _generateMipMaps: boolean;
  18356. protected _renderingManager: RenderingManager;
  18357. /** @hidden */
  18358. _waitingRenderList: string[];
  18359. protected _doNotChangeAspectRatio: boolean;
  18360. protected _currentRefreshId: number;
  18361. protected _refreshRate: number;
  18362. protected _textureMatrix: Matrix;
  18363. protected _samples: number;
  18364. protected _renderTargetOptions: RenderTargetCreationOptions;
  18365. /**
  18366. * Gets render target creation options that were used.
  18367. */
  18368. readonly renderTargetOptions: RenderTargetCreationOptions;
  18369. protected _engine: Engine;
  18370. protected _onRatioRescale(): void;
  18371. /**
  18372. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18373. * It must define where the camera used to render the texture is set
  18374. */
  18375. boundingBoxPosition: Vector3;
  18376. private _boundingBoxSize;
  18377. /**
  18378. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18379. * When defined, the cubemap will switch to local mode
  18380. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18381. * @example https://www.babylonjs-playground.com/#RNASML
  18382. */
  18383. boundingBoxSize: Vector3;
  18384. /**
  18385. * In case the RTT has been created with a depth texture, get the associated
  18386. * depth texture.
  18387. * Otherwise, return null.
  18388. */
  18389. depthStencilTexture: Nullable<InternalTexture>;
  18390. /**
  18391. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18392. * or used a shadow, depth texture...
  18393. * @param name The friendly name of the texture
  18394. * @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)
  18395. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18396. * @param generateMipMaps True if mip maps need to be generated after render.
  18397. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18398. * @param type The type of the buffer in the RTT (int, half float, float...)
  18399. * @param isCube True if a cube texture needs to be created
  18400. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18401. * @param generateDepthBuffer True to generate a depth buffer
  18402. * @param generateStencilBuffer True to generate a stencil buffer
  18403. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18404. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18406. */
  18407. constructor(name: string, size: number | {
  18408. width: number;
  18409. height: number;
  18410. } | {
  18411. ratio: number;
  18412. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18413. /**
  18414. * Creates a depth stencil texture.
  18415. * This is only available in WebGL 2 or with the depth texture extension available.
  18416. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18417. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18418. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18419. */
  18420. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18421. private _processSizeParameter;
  18422. /**
  18423. * Define the number of samples to use in case of MSAA.
  18424. * It defaults to one meaning no MSAA has been enabled.
  18425. */
  18426. samples: number;
  18427. /**
  18428. * Resets the refresh counter of the texture and start bak from scratch.
  18429. * Could be useful to regenerate the texture if it is setup to render only once.
  18430. */
  18431. resetRefreshCounter(): void;
  18432. /**
  18433. * Define the refresh rate of the texture or the rendering frequency.
  18434. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18435. */
  18436. refreshRate: number;
  18437. /**
  18438. * Adds a post process to the render target rendering passes.
  18439. * @param postProcess define the post process to add
  18440. */
  18441. addPostProcess(postProcess: PostProcess): void;
  18442. /**
  18443. * Clear all the post processes attached to the render target
  18444. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18445. */
  18446. clearPostProcesses(dispose?: boolean): void;
  18447. /**
  18448. * Remove one of the post process from the list of attached post processes to the texture
  18449. * @param postProcess define the post process to remove from the list
  18450. */
  18451. removePostProcess(postProcess: PostProcess): void;
  18452. /** @hidden */
  18453. _shouldRender(): boolean;
  18454. /**
  18455. * Gets the actual render size of the texture.
  18456. * @returns the width of the render size
  18457. */
  18458. getRenderSize(): number;
  18459. /**
  18460. * Gets the actual render width of the texture.
  18461. * @returns the width of the render size
  18462. */
  18463. getRenderWidth(): number;
  18464. /**
  18465. * Gets the actual render height of the texture.
  18466. * @returns the height of the render size
  18467. */
  18468. getRenderHeight(): number;
  18469. /**
  18470. * Get if the texture can be rescaled or not.
  18471. */
  18472. readonly canRescale: boolean;
  18473. /**
  18474. * Resize the texture using a ratio.
  18475. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18476. */
  18477. scale(ratio: number): void;
  18478. /**
  18479. * Get the texture reflection matrix used to rotate/transform the reflection.
  18480. * @returns the reflection matrix
  18481. */
  18482. getReflectionTextureMatrix(): Matrix;
  18483. /**
  18484. * Resize the texture to a new desired size.
  18485. * Be carrefull as it will recreate all the data in the new texture.
  18486. * @param size Define the new size. It can be:
  18487. * - a number for squared texture,
  18488. * - an object containing { width: number, height: number }
  18489. * - or an object containing a ratio { ratio: number }
  18490. */
  18491. resize(size: number | {
  18492. width: number;
  18493. height: number;
  18494. } | {
  18495. ratio: number;
  18496. }): void;
  18497. /**
  18498. * Renders all the objects from the render list into the texture.
  18499. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18500. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18501. */
  18502. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18503. private _bestReflectionRenderTargetDimension;
  18504. /**
  18505. * @hidden
  18506. * @param faceIndex face index to bind to if this is a cubetexture
  18507. */
  18508. _bindFrameBuffer(faceIndex?: number): void;
  18509. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18510. private renderToTarget;
  18511. /**
  18512. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18513. * This allowed control for front to back rendering or reversly depending of the special needs.
  18514. *
  18515. * @param renderingGroupId The rendering group id corresponding to its index
  18516. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18517. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18518. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18519. */
  18520. 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;
  18521. /**
  18522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18523. *
  18524. * @param renderingGroupId The rendering group id corresponding to its index
  18525. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18526. */
  18527. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18528. /**
  18529. * Clones the texture.
  18530. * @returns the cloned texture
  18531. */
  18532. clone(): RenderTargetTexture;
  18533. /**
  18534. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18535. * @returns The JSON representation of the texture
  18536. */
  18537. serialize(): any;
  18538. /**
  18539. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18540. */
  18541. disposeFramebufferObjects(): void;
  18542. /**
  18543. * Dispose the texture and release its associated resources.
  18544. */
  18545. dispose(): void;
  18546. /** @hidden */
  18547. _rebuild(): void;
  18548. /**
  18549. * Clear the info related to rendering groups preventing retention point in material dispose.
  18550. */
  18551. freeRenderingGroups(): void;
  18552. /**
  18553. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18554. * @returns the view count
  18555. */
  18556. getViewCount(): number;
  18557. }
  18558. }
  18559. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18560. import { Scene } from "babylonjs/scene";
  18561. import { Plane } from "babylonjs/Maths/math";
  18562. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18563. /**
  18564. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18565. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18566. * You can then easily use it as a reflectionTexture on a flat surface.
  18567. * In case the surface is not a plane, please consider relying on reflection probes.
  18568. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18569. */
  18570. export class MirrorTexture extends RenderTargetTexture {
  18571. private scene;
  18572. /**
  18573. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18574. * 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.
  18575. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18576. */
  18577. mirrorPlane: Plane;
  18578. /**
  18579. * Define the blur ratio used to blur the reflection if needed.
  18580. */
  18581. blurRatio: number;
  18582. /**
  18583. * Define the adaptive blur kernel used to blur the reflection if needed.
  18584. * This will autocompute the closest best match for the `blurKernel`
  18585. */
  18586. adaptiveBlurKernel: number;
  18587. /**
  18588. * Define the blur kernel used to blur the reflection if needed.
  18589. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18590. */
  18591. blurKernel: number;
  18592. /**
  18593. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18594. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18595. */
  18596. blurKernelX: number;
  18597. /**
  18598. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18599. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18600. */
  18601. blurKernelY: number;
  18602. private _autoComputeBlurKernel;
  18603. protected _onRatioRescale(): void;
  18604. private _updateGammaSpace;
  18605. private _imageProcessingConfigChangeObserver;
  18606. private _transformMatrix;
  18607. private _mirrorMatrix;
  18608. private _savedViewMatrix;
  18609. private _blurX;
  18610. private _blurY;
  18611. private _adaptiveBlurKernel;
  18612. private _blurKernelX;
  18613. private _blurKernelY;
  18614. private _blurRatio;
  18615. /**
  18616. * Instantiates a Mirror Texture.
  18617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18619. * You can then easily use it as a reflectionTexture on a flat surface.
  18620. * In case the surface is not a plane, please consider relying on reflection probes.
  18621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18622. * @param name
  18623. * @param size
  18624. * @param scene
  18625. * @param generateMipMaps
  18626. * @param type
  18627. * @param samplingMode
  18628. * @param generateDepthBuffer
  18629. */
  18630. constructor(name: string, size: number | {
  18631. width: number;
  18632. height: number;
  18633. } | {
  18634. ratio: number;
  18635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18636. private _preparePostProcesses;
  18637. /**
  18638. * Clone the mirror texture.
  18639. * @returns the cloned texture
  18640. */
  18641. clone(): MirrorTexture;
  18642. /**
  18643. * Serialize the texture to a JSON representation you could use in Parse later on
  18644. * @returns the serialized JSON representation
  18645. */
  18646. serialize(): any;
  18647. /**
  18648. * Dispose the texture and release its associated resources.
  18649. */
  18650. dispose(): void;
  18651. }
  18652. }
  18653. declare module "babylonjs/Materials/Textures/texture" {
  18654. import { Observable } from "babylonjs/Misc/observable";
  18655. import { Nullable } from "babylonjs/types";
  18656. import { Scene } from "babylonjs/scene";
  18657. import { Matrix } from "babylonjs/Maths/math";
  18658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18659. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18660. /**
  18661. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18662. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18663. */
  18664. export class Texture extends BaseTexture {
  18665. /** @hidden */
  18666. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18667. /** @hidden */
  18668. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18669. /** @hidden */
  18670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18671. /** nearest is mag = nearest and min = nearest and mip = linear */
  18672. static readonly NEAREST_SAMPLINGMODE: number;
  18673. /** nearest is mag = nearest and min = nearest and mip = linear */
  18674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18676. static readonly BILINEAR_SAMPLINGMODE: number;
  18677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18679. /** Trilinear is mag = linear and min = linear and mip = linear */
  18680. static readonly TRILINEAR_SAMPLINGMODE: number;
  18681. /** Trilinear is mag = linear and min = linear and mip = linear */
  18682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18683. /** mag = nearest and min = nearest and mip = nearest */
  18684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18685. /** mag = nearest and min = linear and mip = nearest */
  18686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18687. /** mag = nearest and min = linear and mip = linear */
  18688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18689. /** mag = nearest and min = linear and mip = none */
  18690. static readonly NEAREST_LINEAR: number;
  18691. /** mag = nearest and min = nearest and mip = none */
  18692. static readonly NEAREST_NEAREST: number;
  18693. /** mag = linear and min = nearest and mip = nearest */
  18694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18695. /** mag = linear and min = nearest and mip = linear */
  18696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18697. /** mag = linear and min = linear and mip = none */
  18698. static readonly LINEAR_LINEAR: number;
  18699. /** mag = linear and min = nearest and mip = none */
  18700. static readonly LINEAR_NEAREST: number;
  18701. /** Explicit coordinates mode */
  18702. static readonly EXPLICIT_MODE: number;
  18703. /** Spherical coordinates mode */
  18704. static readonly SPHERICAL_MODE: number;
  18705. /** Planar coordinates mode */
  18706. static readonly PLANAR_MODE: number;
  18707. /** Cubic coordinates mode */
  18708. static readonly CUBIC_MODE: number;
  18709. /** Projection coordinates mode */
  18710. static readonly PROJECTION_MODE: number;
  18711. /** Inverse Cubic coordinates mode */
  18712. static readonly SKYBOX_MODE: number;
  18713. /** Inverse Cubic coordinates mode */
  18714. static readonly INVCUBIC_MODE: number;
  18715. /** Equirectangular coordinates mode */
  18716. static readonly EQUIRECTANGULAR_MODE: number;
  18717. /** Equirectangular Fixed coordinates mode */
  18718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18719. /** Equirectangular Fixed Mirrored coordinates mode */
  18720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18721. /** Texture is not repeating outside of 0..1 UVs */
  18722. static readonly CLAMP_ADDRESSMODE: number;
  18723. /** Texture is repeating outside of 0..1 UVs */
  18724. static readonly WRAP_ADDRESSMODE: number;
  18725. /** Texture is repeating and mirrored */
  18726. static readonly MIRROR_ADDRESSMODE: number;
  18727. /**
  18728. * 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
  18729. */
  18730. static UseSerializedUrlIfAny: boolean;
  18731. /**
  18732. * Define the url of the texture.
  18733. */
  18734. url: Nullable<string>;
  18735. /**
  18736. * Define an offset on the texture to offset the u coordinates of the UVs
  18737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18738. */
  18739. uOffset: number;
  18740. /**
  18741. * Define an offset on the texture to offset the v coordinates of the UVs
  18742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18743. */
  18744. vOffset: number;
  18745. /**
  18746. * Define an offset on the texture to scale the u coordinates of the UVs
  18747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18748. */
  18749. uScale: number;
  18750. /**
  18751. * Define an offset on the texture to scale the v coordinates of the UVs
  18752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18753. */
  18754. vScale: number;
  18755. /**
  18756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18757. * @see http://doc.babylonjs.com/how_to/more_materials
  18758. */
  18759. uAng: number;
  18760. /**
  18761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18762. * @see http://doc.babylonjs.com/how_to/more_materials
  18763. */
  18764. vAng: number;
  18765. /**
  18766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18767. * @see http://doc.babylonjs.com/how_to/more_materials
  18768. */
  18769. wAng: number;
  18770. /**
  18771. * Defines the center of rotation (U)
  18772. */
  18773. uRotationCenter: number;
  18774. /**
  18775. * Defines the center of rotation (V)
  18776. */
  18777. vRotationCenter: number;
  18778. /**
  18779. * Defines the center of rotation (W)
  18780. */
  18781. wRotationCenter: number;
  18782. /**
  18783. * Are mip maps generated for this texture or not.
  18784. */
  18785. readonly noMipmap: boolean;
  18786. /**
  18787. * List of inspectable custom properties (used by the Inspector)
  18788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18789. */
  18790. inspectableCustomProperties: Nullable<IInspectable[]>;
  18791. private _noMipmap;
  18792. /** @hidden */
  18793. _invertY: boolean;
  18794. private _rowGenerationMatrix;
  18795. private _cachedTextureMatrix;
  18796. private _projectionModeMatrix;
  18797. private _t0;
  18798. private _t1;
  18799. private _t2;
  18800. private _cachedUOffset;
  18801. private _cachedVOffset;
  18802. private _cachedUScale;
  18803. private _cachedVScale;
  18804. private _cachedUAng;
  18805. private _cachedVAng;
  18806. private _cachedWAng;
  18807. private _cachedProjectionMatrixId;
  18808. private _cachedCoordinatesMode;
  18809. /** @hidden */
  18810. protected _initialSamplingMode: number;
  18811. /** @hidden */
  18812. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18813. private _deleteBuffer;
  18814. protected _format: Nullable<number>;
  18815. private _delayedOnLoad;
  18816. private _delayedOnError;
  18817. /**
  18818. * Observable triggered once the texture has been loaded.
  18819. */
  18820. onLoadObservable: Observable<Texture>;
  18821. protected _isBlocking: boolean;
  18822. /**
  18823. * Is the texture preventing material to render while loading.
  18824. * If false, a default texture will be used instead of the loading one during the preparation step.
  18825. */
  18826. isBlocking: boolean;
  18827. /**
  18828. * Get the current sampling mode associated with the texture.
  18829. */
  18830. readonly samplingMode: number;
  18831. /**
  18832. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18833. */
  18834. readonly invertY: boolean;
  18835. /**
  18836. * Instantiates a new texture.
  18837. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18838. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18839. * @param url define the url of the picture to load as a texture
  18840. * @param scene define the scene the texture will belong to
  18841. * @param noMipmap define if the texture will require mip maps or not
  18842. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18843. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18844. * @param onLoad define a callback triggered when the texture has been loaded
  18845. * @param onError define a callback triggered when an error occurred during the loading session
  18846. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18847. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18848. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18849. */
  18850. 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);
  18851. /**
  18852. * Update the url (and optional buffer) of this texture if url was null during construction.
  18853. * @param url the url of the texture
  18854. * @param buffer the buffer of the texture (defaults to null)
  18855. * @param onLoad callback called when the texture is loaded (defaults to null)
  18856. */
  18857. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18858. /**
  18859. * Finish the loading sequence of a texture flagged as delayed load.
  18860. * @hidden
  18861. */
  18862. delayLoad(): void;
  18863. private _prepareRowForTextureGeneration;
  18864. /**
  18865. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18866. * @returns the transform matrix of the texture.
  18867. */
  18868. getTextureMatrix(): Matrix;
  18869. /**
  18870. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18871. * @returns The reflection texture transform
  18872. */
  18873. getReflectionTextureMatrix(): Matrix;
  18874. /**
  18875. * Clones the texture.
  18876. * @returns the cloned texture
  18877. */
  18878. clone(): Texture;
  18879. /**
  18880. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18881. * @returns The JSON representation of the texture
  18882. */
  18883. serialize(): any;
  18884. /**
  18885. * Get the current class name of the texture useful for serialization or dynamic coding.
  18886. * @returns "Texture"
  18887. */
  18888. getClassName(): string;
  18889. /**
  18890. * Dispose the texture and release its associated resources.
  18891. */
  18892. dispose(): void;
  18893. /**
  18894. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18895. * @param parsedTexture Define the JSON representation of the texture
  18896. * @param scene Define the scene the parsed texture should be instantiated in
  18897. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18898. * @returns The parsed texture if successful
  18899. */
  18900. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18901. /**
  18902. * Creates a texture from its base 64 representation.
  18903. * @param data Define the base64 payload without the data: prefix
  18904. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18905. * @param scene Define the scene the texture should belong to
  18906. * @param noMipmap Forces the texture to not create mip map information if true
  18907. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18908. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18909. * @param onLoad define a callback triggered when the texture has been loaded
  18910. * @param onError define a callback triggered when an error occurred during the loading session
  18911. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18912. * @returns the created texture
  18913. */
  18914. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18915. /**
  18916. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18917. * @param data Define the base64 payload without the data: prefix
  18918. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18919. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18920. * @param scene Define the scene the texture should belong to
  18921. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18922. * @param noMipmap Forces the texture to not create mip map information if true
  18923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18925. * @param onLoad define a callback triggered when the texture has been loaded
  18926. * @param onError define a callback triggered when an error occurred during the loading session
  18927. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18928. * @returns the created texture
  18929. */
  18930. 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;
  18931. }
  18932. }
  18933. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18934. import { Nullable } from "babylonjs/types";
  18935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18936. import { Scene } from "babylonjs/scene";
  18937. module "babylonjs/Engines/engine" {
  18938. interface Engine {
  18939. /**
  18940. * Creates a raw texture
  18941. * @param data defines the data to store in the texture
  18942. * @param width defines the width of the texture
  18943. * @param height defines the height of the texture
  18944. * @param format defines the format of the data
  18945. * @param generateMipMaps defines if the engine should generate the mip levels
  18946. * @param invertY defines if data must be stored with Y axis inverted
  18947. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18948. * @param compression defines the compression used (null by default)
  18949. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18950. * @returns the raw texture inside an InternalTexture
  18951. */
  18952. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18953. /**
  18954. * Update a raw texture
  18955. * @param texture defines the texture to update
  18956. * @param data defines the data to store in the texture
  18957. * @param format defines the format of the data
  18958. * @param invertY defines if data must be stored with Y axis inverted
  18959. */
  18960. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18961. /**
  18962. * Update a raw texture
  18963. * @param texture defines the texture to update
  18964. * @param data defines the data to store in the texture
  18965. * @param format defines the format of the data
  18966. * @param invertY defines if data must be stored with Y axis inverted
  18967. * @param compression defines the compression used (null by default)
  18968. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18969. */
  18970. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18971. /**
  18972. * Creates a new raw cube texture
  18973. * @param data defines the array of data to use to create each face
  18974. * @param size defines the size of the textures
  18975. * @param format defines the format of the data
  18976. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18977. * @param generateMipMaps defines if the engine should generate the mip levels
  18978. * @param invertY defines if data must be stored with Y axis inverted
  18979. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18980. * @param compression defines the compression used (null by default)
  18981. * @returns the cube texture as an InternalTexture
  18982. */
  18983. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18984. /**
  18985. * Update a raw cube texture
  18986. * @param texture defines the texture to udpdate
  18987. * @param data defines the data to store
  18988. * @param format defines the data format
  18989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18990. * @param invertY defines if data must be stored with Y axis inverted
  18991. */
  18992. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18993. /**
  18994. * Update a raw cube texture
  18995. * @param texture defines the texture to udpdate
  18996. * @param data defines the data to store
  18997. * @param format defines the data format
  18998. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18999. * @param invertY defines if data must be stored with Y axis inverted
  19000. * @param compression defines the compression used (null by default)
  19001. */
  19002. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19003. /**
  19004. * Update a raw cube texture
  19005. * @param texture defines the texture to udpdate
  19006. * @param data defines the data to store
  19007. * @param format defines the data format
  19008. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19009. * @param invertY defines if data must be stored with Y axis inverted
  19010. * @param compression defines the compression used (null by default)
  19011. * @param level defines which level of the texture to update
  19012. */
  19013. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19014. /**
  19015. * Creates a new raw cube texture from a specified url
  19016. * @param url defines the url where the data is located
  19017. * @param scene defines the current scene
  19018. * @param size defines the size of the textures
  19019. * @param format defines the format of the data
  19020. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19021. * @param noMipmap defines if the engine should avoid generating the mip levels
  19022. * @param callback defines a callback used to extract texture data from loaded data
  19023. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19024. * @param onLoad defines a callback called when texture is loaded
  19025. * @param onError defines a callback called if there is an error
  19026. * @returns the cube texture as an InternalTexture
  19027. */
  19028. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  19029. /**
  19030. * Creates a new raw cube texture from a specified url
  19031. * @param url defines the url where the data is located
  19032. * @param scene defines the current scene
  19033. * @param size defines the size of the textures
  19034. * @param format defines the format of the data
  19035. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19036. * @param noMipmap defines if the engine should avoid generating the mip levels
  19037. * @param callback defines a callback used to extract texture data from loaded data
  19038. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19039. * @param onLoad defines a callback called when texture is loaded
  19040. * @param onError defines a callback called if there is an error
  19041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19042. * @param invertY defines if data must be stored with Y axis inverted
  19043. * @returns the cube texture as an InternalTexture
  19044. */
  19045. 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;
  19046. /**
  19047. * Creates a new raw 3D texture
  19048. * @param data defines the data used to create the texture
  19049. * @param width defines the width of the texture
  19050. * @param height defines the height of the texture
  19051. * @param depth defines the depth of the texture
  19052. * @param format defines the format of the texture
  19053. * @param generateMipMaps defines if the engine must generate mip levels
  19054. * @param invertY defines if data must be stored with Y axis inverted
  19055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19056. * @param compression defines the compressed used (can be null)
  19057. * @param textureType defines the compressed used (can be null)
  19058. * @returns a new raw 3D texture (stored in an InternalTexture)
  19059. */
  19060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19061. /**
  19062. * Update a raw 3D texture
  19063. * @param texture defines the texture to update
  19064. * @param data defines the data to store
  19065. * @param format defines the data format
  19066. * @param invertY defines if data must be stored with Y axis inverted
  19067. */
  19068. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19069. /**
  19070. * Update a raw 3D texture
  19071. * @param texture defines the texture to update
  19072. * @param data defines the data to store
  19073. * @param format defines the data format
  19074. * @param invertY defines if data must be stored with Y axis inverted
  19075. * @param compression defines the used compression (can be null)
  19076. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19077. */
  19078. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19079. }
  19080. }
  19081. }
  19082. declare module "babylonjs/Materials/Textures/rawTexture" {
  19083. import { Scene } from "babylonjs/scene";
  19084. import { Texture } from "babylonjs/Materials/Textures/texture";
  19085. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19086. /**
  19087. * Raw texture can help creating a texture directly from an array of data.
  19088. * This can be super useful if you either get the data from an uncompressed source or
  19089. * if you wish to create your texture pixel by pixel.
  19090. */
  19091. export class RawTexture extends Texture {
  19092. /**
  19093. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19094. */
  19095. format: number;
  19096. private _engine;
  19097. /**
  19098. * Instantiates a new RawTexture.
  19099. * Raw texture can help creating a texture directly from an array of data.
  19100. * This can be super useful if you either get the data from an uncompressed source or
  19101. * if you wish to create your texture pixel by pixel.
  19102. * @param data define the array of data to use to create the texture
  19103. * @param width define the width of the texture
  19104. * @param height define the height of the texture
  19105. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19106. * @param scene define the scene the texture belongs to
  19107. * @param generateMipMaps define whether mip maps should be generated or not
  19108. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19109. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19110. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19111. */
  19112. constructor(data: ArrayBufferView, width: number, height: number,
  19113. /**
  19114. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19115. */
  19116. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19117. /**
  19118. * Updates the texture underlying data.
  19119. * @param data Define the new data of the texture
  19120. */
  19121. update(data: ArrayBufferView): void;
  19122. /**
  19123. * Creates a luminance texture from some data.
  19124. * @param data Define the texture data
  19125. * @param width Define the width of the texture
  19126. * @param height Define the height of the texture
  19127. * @param scene Define the scene the texture belongs to
  19128. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19129. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19130. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19131. * @returns the luminance texture
  19132. */
  19133. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19134. /**
  19135. * Creates a luminance alpha texture from some data.
  19136. * @param data Define the texture data
  19137. * @param width Define the width of the texture
  19138. * @param height Define the height of the texture
  19139. * @param scene Define the scene the texture belongs to
  19140. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19141. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19142. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19143. * @returns the luminance alpha texture
  19144. */
  19145. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19146. /**
  19147. * Creates an alpha texture from some data.
  19148. * @param data Define the texture data
  19149. * @param width Define the width of the texture
  19150. * @param height Define the height of the texture
  19151. * @param scene Define the scene the texture belongs to
  19152. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19153. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19154. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19155. * @returns the alpha texture
  19156. */
  19157. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19158. /**
  19159. * Creates a RGB texture from some data.
  19160. * @param data Define the texture data
  19161. * @param width Define the width of the texture
  19162. * @param height Define the height of the texture
  19163. * @param scene Define the scene the texture belongs to
  19164. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19165. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19166. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19167. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19168. * @returns the RGB alpha texture
  19169. */
  19170. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19171. /**
  19172. * Creates a RGBA texture from some data.
  19173. * @param data Define the texture data
  19174. * @param width Define the width of the texture
  19175. * @param height Define the height of the texture
  19176. * @param scene Define the scene the texture belongs to
  19177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19180. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19181. * @returns the RGBA texture
  19182. */
  19183. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19184. /**
  19185. * Creates a R texture from some data.
  19186. * @param data Define the texture data
  19187. * @param width Define the width of the texture
  19188. * @param height Define the height of the texture
  19189. * @param scene Define the scene the texture belongs to
  19190. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19191. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19192. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19193. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19194. * @returns the R texture
  19195. */
  19196. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19197. }
  19198. }
  19199. declare module "babylonjs/Animations/runtimeAnimation" {
  19200. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19201. import { Animatable } from "babylonjs/Animations/animatable";
  19202. import { Scene } from "babylonjs/scene";
  19203. /**
  19204. * Defines a runtime animation
  19205. */
  19206. export class RuntimeAnimation {
  19207. private _events;
  19208. /**
  19209. * The current frame of the runtime animation
  19210. */
  19211. private _currentFrame;
  19212. /**
  19213. * The animation used by the runtime animation
  19214. */
  19215. private _animation;
  19216. /**
  19217. * The target of the runtime animation
  19218. */
  19219. private _target;
  19220. /**
  19221. * The initiating animatable
  19222. */
  19223. private _host;
  19224. /**
  19225. * The original value of the runtime animation
  19226. */
  19227. private _originalValue;
  19228. /**
  19229. * The original blend value of the runtime animation
  19230. */
  19231. private _originalBlendValue;
  19232. /**
  19233. * The offsets cache of the runtime animation
  19234. */
  19235. private _offsetsCache;
  19236. /**
  19237. * The high limits cache of the runtime animation
  19238. */
  19239. private _highLimitsCache;
  19240. /**
  19241. * Specifies if the runtime animation has been stopped
  19242. */
  19243. private _stopped;
  19244. /**
  19245. * The blending factor of the runtime animation
  19246. */
  19247. private _blendingFactor;
  19248. /**
  19249. * The BabylonJS scene
  19250. */
  19251. private _scene;
  19252. /**
  19253. * The current value of the runtime animation
  19254. */
  19255. private _currentValue;
  19256. /** @hidden */
  19257. _animationState: _IAnimationState;
  19258. /**
  19259. * The active target of the runtime animation
  19260. */
  19261. private _activeTargets;
  19262. private _currentActiveTarget;
  19263. private _directTarget;
  19264. /**
  19265. * The target path of the runtime animation
  19266. */
  19267. private _targetPath;
  19268. /**
  19269. * The weight of the runtime animation
  19270. */
  19271. private _weight;
  19272. /**
  19273. * The ratio offset of the runtime animation
  19274. */
  19275. private _ratioOffset;
  19276. /**
  19277. * The previous delay of the runtime animation
  19278. */
  19279. private _previousDelay;
  19280. /**
  19281. * The previous ratio of the runtime animation
  19282. */
  19283. private _previousRatio;
  19284. private _enableBlending;
  19285. private _keys;
  19286. private _minFrame;
  19287. private _maxFrame;
  19288. private _minValue;
  19289. private _maxValue;
  19290. private _targetIsArray;
  19291. /**
  19292. * Gets the current frame of the runtime animation
  19293. */
  19294. readonly currentFrame: number;
  19295. /**
  19296. * Gets the weight of the runtime animation
  19297. */
  19298. readonly weight: number;
  19299. /**
  19300. * Gets the current value of the runtime animation
  19301. */
  19302. readonly currentValue: any;
  19303. /**
  19304. * Gets the target path of the runtime animation
  19305. */
  19306. readonly targetPath: string;
  19307. /**
  19308. * Gets the actual target of the runtime animation
  19309. */
  19310. readonly target: any;
  19311. /** @hidden */
  19312. _onLoop: () => void;
  19313. /**
  19314. * Create a new RuntimeAnimation object
  19315. * @param target defines the target of the animation
  19316. * @param animation defines the source animation object
  19317. * @param scene defines the hosting scene
  19318. * @param host defines the initiating Animatable
  19319. */
  19320. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19321. private _preparePath;
  19322. /**
  19323. * Gets the animation from the runtime animation
  19324. */
  19325. readonly animation: Animation;
  19326. /**
  19327. * Resets the runtime animation to the beginning
  19328. * @param restoreOriginal defines whether to restore the target property to the original value
  19329. */
  19330. reset(restoreOriginal?: boolean): void;
  19331. /**
  19332. * Specifies if the runtime animation is stopped
  19333. * @returns Boolean specifying if the runtime animation is stopped
  19334. */
  19335. isStopped(): boolean;
  19336. /**
  19337. * Disposes of the runtime animation
  19338. */
  19339. dispose(): void;
  19340. /**
  19341. * Apply the interpolated value to the target
  19342. * @param currentValue defines the value computed by the animation
  19343. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19344. */
  19345. setValue(currentValue: any, weight: number): void;
  19346. private _getOriginalValues;
  19347. private _setValue;
  19348. /**
  19349. * Gets the loop pmode of the runtime animation
  19350. * @returns Loop Mode
  19351. */
  19352. private _getCorrectLoopMode;
  19353. /**
  19354. * Move the current animation to a given frame
  19355. * @param frame defines the frame to move to
  19356. */
  19357. goToFrame(frame: number): void;
  19358. /**
  19359. * @hidden Internal use only
  19360. */
  19361. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19362. /**
  19363. * Execute the current animation
  19364. * @param delay defines the delay to add to the current frame
  19365. * @param from defines the lower bound of the animation range
  19366. * @param to defines the upper bound of the animation range
  19367. * @param loop defines if the current animation must loop
  19368. * @param speedRatio defines the current speed ratio
  19369. * @param weight defines the weight of the animation (default is -1 so no weight)
  19370. * @param onLoop optional callback called when animation loops
  19371. * @returns a boolean indicating if the animation is running
  19372. */
  19373. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19374. }
  19375. }
  19376. declare module "babylonjs/Animations/animatable" {
  19377. import { Animation } from "babylonjs/Animations/animation";
  19378. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19379. import { Nullable } from "babylonjs/types";
  19380. import { Observable } from "babylonjs/Misc/observable";
  19381. import { Scene } from "babylonjs/scene";
  19382. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19383. import { Node } from "babylonjs/node";
  19384. /**
  19385. * Class used to store an actual running animation
  19386. */
  19387. export class Animatable {
  19388. /** defines the target object */
  19389. target: any;
  19390. /** defines the starting frame number (default is 0) */
  19391. fromFrame: number;
  19392. /** defines the ending frame number (default is 100) */
  19393. toFrame: number;
  19394. /** defines if the animation must loop (default is false) */
  19395. loopAnimation: boolean;
  19396. /** defines a callback to call when animation ends if it is not looping */
  19397. onAnimationEnd?: (() => void) | null | undefined;
  19398. /** defines a callback to call when animation loops */
  19399. onAnimationLoop?: (() => void) | null | undefined;
  19400. private _localDelayOffset;
  19401. private _pausedDelay;
  19402. private _runtimeAnimations;
  19403. private _paused;
  19404. private _scene;
  19405. private _speedRatio;
  19406. private _weight;
  19407. private _syncRoot;
  19408. /**
  19409. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19410. * This will only apply for non looping animation (default is true)
  19411. */
  19412. disposeOnEnd: boolean;
  19413. /**
  19414. * Gets a boolean indicating if the animation has started
  19415. */
  19416. animationStarted: boolean;
  19417. /**
  19418. * Observer raised when the animation ends
  19419. */
  19420. onAnimationEndObservable: Observable<Animatable>;
  19421. /**
  19422. * Observer raised when the animation loops
  19423. */
  19424. onAnimationLoopObservable: Observable<Animatable>;
  19425. /**
  19426. * Gets the root Animatable used to synchronize and normalize animations
  19427. */
  19428. readonly syncRoot: Nullable<Animatable>;
  19429. /**
  19430. * Gets the current frame of the first RuntimeAnimation
  19431. * Used to synchronize Animatables
  19432. */
  19433. readonly masterFrame: number;
  19434. /**
  19435. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19436. */
  19437. weight: number;
  19438. /**
  19439. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19440. */
  19441. speedRatio: number;
  19442. /**
  19443. * Creates a new Animatable
  19444. * @param scene defines the hosting scene
  19445. * @param target defines the target object
  19446. * @param fromFrame defines the starting frame number (default is 0)
  19447. * @param toFrame defines the ending frame number (default is 100)
  19448. * @param loopAnimation defines if the animation must loop (default is false)
  19449. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19450. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19451. * @param animations defines a group of animation to add to the new Animatable
  19452. * @param onAnimationLoop defines a callback to call when animation loops
  19453. */
  19454. constructor(scene: Scene,
  19455. /** defines the target object */
  19456. target: any,
  19457. /** defines the starting frame number (default is 0) */
  19458. fromFrame?: number,
  19459. /** defines the ending frame number (default is 100) */
  19460. toFrame?: number,
  19461. /** defines if the animation must loop (default is false) */
  19462. loopAnimation?: boolean, speedRatio?: number,
  19463. /** defines a callback to call when animation ends if it is not looping */
  19464. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19465. /** defines a callback to call when animation loops */
  19466. onAnimationLoop?: (() => void) | null | undefined);
  19467. /**
  19468. * Synchronize and normalize current Animatable with a source Animatable
  19469. * This is useful when using animation weights and when animations are not of the same length
  19470. * @param root defines the root Animatable to synchronize with
  19471. * @returns the current Animatable
  19472. */
  19473. syncWith(root: Animatable): Animatable;
  19474. /**
  19475. * Gets the list of runtime animations
  19476. * @returns an array of RuntimeAnimation
  19477. */
  19478. getAnimations(): RuntimeAnimation[];
  19479. /**
  19480. * Adds more animations to the current animatable
  19481. * @param target defines the target of the animations
  19482. * @param animations defines the new animations to add
  19483. */
  19484. appendAnimations(target: any, animations: Animation[]): void;
  19485. /**
  19486. * Gets the source animation for a specific property
  19487. * @param property defines the propertyu to look for
  19488. * @returns null or the source animation for the given property
  19489. */
  19490. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19491. /**
  19492. * Gets the runtime animation for a specific property
  19493. * @param property defines the propertyu to look for
  19494. * @returns null or the runtime animation for the given property
  19495. */
  19496. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19497. /**
  19498. * Resets the animatable to its original state
  19499. */
  19500. reset(): void;
  19501. /**
  19502. * Allows the animatable to blend with current running animations
  19503. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19504. * @param blendingSpeed defines the blending speed to use
  19505. */
  19506. enableBlending(blendingSpeed: number): void;
  19507. /**
  19508. * Disable animation blending
  19509. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19510. */
  19511. disableBlending(): void;
  19512. /**
  19513. * Jump directly to a given frame
  19514. * @param frame defines the frame to jump to
  19515. */
  19516. goToFrame(frame: number): void;
  19517. /**
  19518. * Pause the animation
  19519. */
  19520. pause(): void;
  19521. /**
  19522. * Restart the animation
  19523. */
  19524. restart(): void;
  19525. private _raiseOnAnimationEnd;
  19526. /**
  19527. * Stop and delete the current animation
  19528. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19529. * @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)
  19530. */
  19531. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19532. /**
  19533. * Wait asynchronously for the animation to end
  19534. * @returns a promise which will be fullfilled when the animation ends
  19535. */
  19536. waitAsync(): Promise<Animatable>;
  19537. /** @hidden */
  19538. _animate(delay: number): boolean;
  19539. }
  19540. module "babylonjs/scene" {
  19541. interface Scene {
  19542. /** @hidden */
  19543. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19544. /** @hidden */
  19545. _processLateAnimationBindingsForMatrices(holder: {
  19546. totalWeight: number;
  19547. animations: RuntimeAnimation[];
  19548. originalValue: Matrix;
  19549. }): any;
  19550. /** @hidden */
  19551. _processLateAnimationBindingsForQuaternions(holder: {
  19552. totalWeight: number;
  19553. animations: RuntimeAnimation[];
  19554. originalValue: Quaternion;
  19555. }, refQuaternion: Quaternion): Quaternion;
  19556. /** @hidden */
  19557. _processLateAnimationBindings(): void;
  19558. /**
  19559. * Will start the animation sequence of a given target
  19560. * @param target defines the target
  19561. * @param from defines from which frame should animation start
  19562. * @param to defines until which frame should animation run.
  19563. * @param weight defines the weight to apply to the animation (1.0 by default)
  19564. * @param loop defines if the animation loops
  19565. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19566. * @param onAnimationEnd defines the function to be executed when the animation ends
  19567. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19568. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19569. * @param onAnimationLoop defines the callback to call when an animation loops
  19570. * @returns the animatable object created for this animation
  19571. */
  19572. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19573. /**
  19574. * Will start the animation sequence of a given target
  19575. * @param target defines the target
  19576. * @param from defines from which frame should animation start
  19577. * @param to defines until which frame should animation run.
  19578. * @param loop defines if the animation loops
  19579. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19580. * @param onAnimationEnd defines the function to be executed when the animation ends
  19581. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19582. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19583. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19584. * @param onAnimationLoop defines the callback to call when an animation loops
  19585. * @returns the animatable object created for this animation
  19586. */
  19587. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19588. /**
  19589. * Will start the animation sequence of a given target and its hierarchy
  19590. * @param target defines the target
  19591. * @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.
  19592. * @param from defines from which frame should animation start
  19593. * @param to defines until which frame should animation run.
  19594. * @param loop defines if the animation loops
  19595. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19596. * @param onAnimationEnd defines the function to be executed when the animation ends
  19597. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19598. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19599. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19600. * @param onAnimationLoop defines the callback to call when an animation loops
  19601. * @returns the list of created animatables
  19602. */
  19603. 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[];
  19604. /**
  19605. * Begin a new animation on a given node
  19606. * @param target defines the target where the animation will take place
  19607. * @param animations defines the list of animations to start
  19608. * @param from defines the initial value
  19609. * @param to defines the final value
  19610. * @param loop defines if you want animation to loop (off by default)
  19611. * @param speedRatio defines the speed ratio to apply to all animations
  19612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19613. * @param onAnimationLoop defines the callback to call when an animation loops
  19614. * @returns the list of created animatables
  19615. */
  19616. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19617. /**
  19618. * Begin a new animation on a given node and its hierarchy
  19619. * @param target defines the root node where the animation will take place
  19620. * @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.
  19621. * @param animations defines the list of animations to start
  19622. * @param from defines the initial value
  19623. * @param to defines the final value
  19624. * @param loop defines if you want animation to loop (off by default)
  19625. * @param speedRatio defines the speed ratio to apply to all animations
  19626. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19627. * @param onAnimationLoop defines the callback to call when an animation loops
  19628. * @returns the list of animatables created for all nodes
  19629. */
  19630. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19631. /**
  19632. * Gets the animatable associated with a specific target
  19633. * @param target defines the target of the animatable
  19634. * @returns the required animatable if found
  19635. */
  19636. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19637. /**
  19638. * Gets all animatables associated with a given target
  19639. * @param target defines the target to look animatables for
  19640. * @returns an array of Animatables
  19641. */
  19642. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19643. /**
  19644. * Stops and removes all animations that have been applied to the scene
  19645. */
  19646. stopAllAnimations(): void;
  19647. }
  19648. }
  19649. module "babylonjs/Bones/bone" {
  19650. interface Bone {
  19651. /**
  19652. * Copy an animation range from another bone
  19653. * @param source defines the source bone
  19654. * @param rangeName defines the range name to copy
  19655. * @param frameOffset defines the frame offset
  19656. * @param rescaleAsRequired defines if rescaling must be applied if required
  19657. * @param skelDimensionsRatio defines the scaling ratio
  19658. * @returns true if operation was successful
  19659. */
  19660. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19661. }
  19662. }
  19663. }
  19664. declare module "babylonjs/Bones/skeleton" {
  19665. import { Bone } from "babylonjs/Bones/bone";
  19666. import { IAnimatable } from "babylonjs/Misc/tools";
  19667. import { Observable } from "babylonjs/Misc/observable";
  19668. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19669. import { Scene } from "babylonjs/scene";
  19670. import { Nullable } from "babylonjs/types";
  19671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19672. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19673. import { Animatable } from "babylonjs/Animations/animatable";
  19674. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19675. import { Animation } from "babylonjs/Animations/animation";
  19676. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19677. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19678. /**
  19679. * Class used to handle skinning animations
  19680. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19681. */
  19682. export class Skeleton implements IAnimatable {
  19683. /** defines the skeleton name */
  19684. name: string;
  19685. /** defines the skeleton Id */
  19686. id: string;
  19687. /**
  19688. * Defines the list of child bones
  19689. */
  19690. bones: Bone[];
  19691. /**
  19692. * Defines an estimate of the dimension of the skeleton at rest
  19693. */
  19694. dimensionsAtRest: Vector3;
  19695. /**
  19696. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19697. */
  19698. needInitialSkinMatrix: boolean;
  19699. /**
  19700. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19701. */
  19702. overrideMesh: Nullable<AbstractMesh>;
  19703. /**
  19704. * Gets the list of animations attached to this skeleton
  19705. */
  19706. animations: Array<Animation>;
  19707. private _scene;
  19708. private _isDirty;
  19709. private _transformMatrices;
  19710. private _transformMatrixTexture;
  19711. private _meshesWithPoseMatrix;
  19712. private _animatables;
  19713. private _identity;
  19714. private _synchronizedWithMesh;
  19715. private _ranges;
  19716. private _lastAbsoluteTransformsUpdateId;
  19717. private _canUseTextureForBones;
  19718. private _uniqueId;
  19719. /** @hidden */
  19720. _numBonesWithLinkedTransformNode: number;
  19721. /**
  19722. * Specifies if the skeleton should be serialized
  19723. */
  19724. doNotSerialize: boolean;
  19725. private _useTextureToStoreBoneMatrices;
  19726. /**
  19727. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19728. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19729. */
  19730. useTextureToStoreBoneMatrices: boolean;
  19731. private _animationPropertiesOverride;
  19732. /**
  19733. * Gets or sets the animation properties override
  19734. */
  19735. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19736. /**
  19737. * List of inspectable custom properties (used by the Inspector)
  19738. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19739. */
  19740. inspectableCustomProperties: IInspectable[];
  19741. /**
  19742. * An observable triggered before computing the skeleton's matrices
  19743. */
  19744. onBeforeComputeObservable: Observable<Skeleton>;
  19745. /**
  19746. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19747. */
  19748. readonly isUsingTextureForMatrices: boolean;
  19749. /**
  19750. * Gets the unique ID of this skeleton
  19751. */
  19752. readonly uniqueId: number;
  19753. /**
  19754. * Creates a new skeleton
  19755. * @param name defines the skeleton name
  19756. * @param id defines the skeleton Id
  19757. * @param scene defines the hosting scene
  19758. */
  19759. constructor(
  19760. /** defines the skeleton name */
  19761. name: string,
  19762. /** defines the skeleton Id */
  19763. id: string, scene: Scene);
  19764. /**
  19765. * Gets the current object class name.
  19766. * @return the class name
  19767. */
  19768. getClassName(): string;
  19769. /**
  19770. * Returns an array containing the root bones
  19771. * @returns an array containing the root bones
  19772. */
  19773. getChildren(): Array<Bone>;
  19774. /**
  19775. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19776. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19777. * @returns a Float32Array containing matrices data
  19778. */
  19779. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19780. /**
  19781. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19782. * @returns a raw texture containing the data
  19783. */
  19784. getTransformMatrixTexture(): Nullable<RawTexture>;
  19785. /**
  19786. * Gets the current hosting scene
  19787. * @returns a scene object
  19788. */
  19789. getScene(): Scene;
  19790. /**
  19791. * Gets a string representing the current skeleton data
  19792. * @param fullDetails defines a boolean indicating if we want a verbose version
  19793. * @returns a string representing the current skeleton data
  19794. */
  19795. toString(fullDetails?: boolean): string;
  19796. /**
  19797. * Get bone's index searching by name
  19798. * @param name defines bone's name to search for
  19799. * @return the indice of the bone. Returns -1 if not found
  19800. */
  19801. getBoneIndexByName(name: string): number;
  19802. /**
  19803. * Creater a new animation range
  19804. * @param name defines the name of the range
  19805. * @param from defines the start key
  19806. * @param to defines the end key
  19807. */
  19808. createAnimationRange(name: string, from: number, to: number): void;
  19809. /**
  19810. * Delete a specific animation range
  19811. * @param name defines the name of the range
  19812. * @param deleteFrames defines if frames must be removed as well
  19813. */
  19814. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19815. /**
  19816. * Gets a specific animation range
  19817. * @param name defines the name of the range to look for
  19818. * @returns the requested animation range or null if not found
  19819. */
  19820. getAnimationRange(name: string): Nullable<AnimationRange>;
  19821. /**
  19822. * Gets the list of all animation ranges defined on this skeleton
  19823. * @returns an array
  19824. */
  19825. getAnimationRanges(): Nullable<AnimationRange>[];
  19826. /**
  19827. * Copy animation range from a source skeleton.
  19828. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19829. * @param source defines the source skeleton
  19830. * @param name defines the name of the range to copy
  19831. * @param rescaleAsRequired defines if rescaling must be applied if required
  19832. * @returns true if operation was successful
  19833. */
  19834. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19835. /**
  19836. * Forces the skeleton to go to rest pose
  19837. */
  19838. returnToRest(): void;
  19839. private _getHighestAnimationFrame;
  19840. /**
  19841. * Begin a specific animation range
  19842. * @param name defines the name of the range to start
  19843. * @param loop defines if looping must be turned on (false by default)
  19844. * @param speedRatio defines the speed ratio to apply (1 by default)
  19845. * @param onAnimationEnd defines a callback which will be called when animation will end
  19846. * @returns a new animatable
  19847. */
  19848. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19849. /** @hidden */
  19850. _markAsDirty(): void;
  19851. /** @hidden */
  19852. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19853. /** @hidden */
  19854. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19855. private _computeTransformMatrices;
  19856. /**
  19857. * Build all resources required to render a skeleton
  19858. */
  19859. prepare(): void;
  19860. /**
  19861. * Gets the list of animatables currently running for this skeleton
  19862. * @returns an array of animatables
  19863. */
  19864. getAnimatables(): IAnimatable[];
  19865. /**
  19866. * Clone the current skeleton
  19867. * @param name defines the name of the new skeleton
  19868. * @param id defines the id of the new skeleton
  19869. * @returns the new skeleton
  19870. */
  19871. clone(name: string, id: string): Skeleton;
  19872. /**
  19873. * Enable animation blending for this skeleton
  19874. * @param blendingSpeed defines the blending speed to apply
  19875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19876. */
  19877. enableBlending(blendingSpeed?: number): void;
  19878. /**
  19879. * Releases all resources associated with the current skeleton
  19880. */
  19881. dispose(): void;
  19882. /**
  19883. * Serialize the skeleton in a JSON object
  19884. * @returns a JSON object
  19885. */
  19886. serialize(): any;
  19887. /**
  19888. * Creates a new skeleton from serialized data
  19889. * @param parsedSkeleton defines the serialized data
  19890. * @param scene defines the hosting scene
  19891. * @returns a new skeleton
  19892. */
  19893. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19894. /**
  19895. * Compute all node absolute transforms
  19896. * @param forceUpdate defines if computation must be done even if cache is up to date
  19897. */
  19898. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19899. /**
  19900. * Gets the root pose matrix
  19901. * @returns a matrix
  19902. */
  19903. getPoseMatrix(): Nullable<Matrix>;
  19904. /**
  19905. * Sorts bones per internal index
  19906. */
  19907. sortBones(): void;
  19908. private _sortBones;
  19909. }
  19910. }
  19911. declare module "babylonjs/Morph/morphTarget" {
  19912. import { IAnimatable } from "babylonjs/Misc/tools";
  19913. import { Observable } from "babylonjs/Misc/observable";
  19914. import { Nullable, FloatArray } from "babylonjs/types";
  19915. import { Scene } from "babylonjs/scene";
  19916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19917. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19918. /**
  19919. * Defines a target to use with MorphTargetManager
  19920. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19921. */
  19922. export class MorphTarget implements IAnimatable {
  19923. /** defines the name of the target */
  19924. name: string;
  19925. /**
  19926. * Gets or sets the list of animations
  19927. */
  19928. animations: import("babylonjs/Animations/animation").Animation[];
  19929. private _scene;
  19930. private _positions;
  19931. private _normals;
  19932. private _tangents;
  19933. private _influence;
  19934. /**
  19935. * Observable raised when the influence changes
  19936. */
  19937. onInfluenceChanged: Observable<boolean>;
  19938. /** @hidden */
  19939. _onDataLayoutChanged: Observable<void>;
  19940. /**
  19941. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19942. */
  19943. influence: number;
  19944. /**
  19945. * Gets or sets the id of the morph Target
  19946. */
  19947. id: string;
  19948. private _animationPropertiesOverride;
  19949. /**
  19950. * Gets or sets the animation properties override
  19951. */
  19952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19953. /**
  19954. * Creates a new MorphTarget
  19955. * @param name defines the name of the target
  19956. * @param influence defines the influence to use
  19957. * @param scene defines the scene the morphtarget belongs to
  19958. */
  19959. constructor(
  19960. /** defines the name of the target */
  19961. name: string, influence?: number, scene?: Nullable<Scene>);
  19962. /**
  19963. * Gets a boolean defining if the target contains position data
  19964. */
  19965. readonly hasPositions: boolean;
  19966. /**
  19967. * Gets a boolean defining if the target contains normal data
  19968. */
  19969. readonly hasNormals: boolean;
  19970. /**
  19971. * Gets a boolean defining if the target contains tangent data
  19972. */
  19973. readonly hasTangents: boolean;
  19974. /**
  19975. * Affects position data to this target
  19976. * @param data defines the position data to use
  19977. */
  19978. setPositions(data: Nullable<FloatArray>): void;
  19979. /**
  19980. * Gets the position data stored in this target
  19981. * @returns a FloatArray containing the position data (or null if not present)
  19982. */
  19983. getPositions(): Nullable<FloatArray>;
  19984. /**
  19985. * Affects normal data to this target
  19986. * @param data defines the normal data to use
  19987. */
  19988. setNormals(data: Nullable<FloatArray>): void;
  19989. /**
  19990. * Gets the normal data stored in this target
  19991. * @returns a FloatArray containing the normal data (or null if not present)
  19992. */
  19993. getNormals(): Nullable<FloatArray>;
  19994. /**
  19995. * Affects tangent data to this target
  19996. * @param data defines the tangent data to use
  19997. */
  19998. setTangents(data: Nullable<FloatArray>): void;
  19999. /**
  20000. * Gets the tangent data stored in this target
  20001. * @returns a FloatArray containing the tangent data (or null if not present)
  20002. */
  20003. getTangents(): Nullable<FloatArray>;
  20004. /**
  20005. * Serializes the current target into a Serialization object
  20006. * @returns the serialized object
  20007. */
  20008. serialize(): any;
  20009. /**
  20010. * Returns the string "MorphTarget"
  20011. * @returns "MorphTarget"
  20012. */
  20013. getClassName(): string;
  20014. /**
  20015. * Creates a new target from serialized data
  20016. * @param serializationObject defines the serialized data to use
  20017. * @returns a new MorphTarget
  20018. */
  20019. static Parse(serializationObject: any): MorphTarget;
  20020. /**
  20021. * Creates a MorphTarget from mesh data
  20022. * @param mesh defines the source mesh
  20023. * @param name defines the name to use for the new target
  20024. * @param influence defines the influence to attach to the target
  20025. * @returns a new MorphTarget
  20026. */
  20027. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20028. }
  20029. }
  20030. declare module "babylonjs/Morph/morphTargetManager" {
  20031. import { Nullable } from "babylonjs/types";
  20032. import { Scene } from "babylonjs/scene";
  20033. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20034. /**
  20035. * This class is used to deform meshes using morphing between different targets
  20036. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20037. */
  20038. export class MorphTargetManager {
  20039. private _targets;
  20040. private _targetInfluenceChangedObservers;
  20041. private _targetDataLayoutChangedObservers;
  20042. private _activeTargets;
  20043. private _scene;
  20044. private _influences;
  20045. private _supportsNormals;
  20046. private _supportsTangents;
  20047. private _vertexCount;
  20048. private _uniqueId;
  20049. private _tempInfluences;
  20050. /**
  20051. * Creates a new MorphTargetManager
  20052. * @param scene defines the current scene
  20053. */
  20054. constructor(scene?: Nullable<Scene>);
  20055. /**
  20056. * Gets the unique ID of this manager
  20057. */
  20058. readonly uniqueId: number;
  20059. /**
  20060. * Gets the number of vertices handled by this manager
  20061. */
  20062. readonly vertexCount: number;
  20063. /**
  20064. * Gets a boolean indicating if this manager supports morphing of normals
  20065. */
  20066. readonly supportsNormals: boolean;
  20067. /**
  20068. * Gets a boolean indicating if this manager supports morphing of tangents
  20069. */
  20070. readonly supportsTangents: boolean;
  20071. /**
  20072. * Gets the number of targets stored in this manager
  20073. */
  20074. readonly numTargets: number;
  20075. /**
  20076. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20077. */
  20078. readonly numInfluencers: number;
  20079. /**
  20080. * Gets the list of influences (one per target)
  20081. */
  20082. readonly influences: Float32Array;
  20083. /**
  20084. * Gets the active target at specified index. An active target is a target with an influence > 0
  20085. * @param index defines the index to check
  20086. * @returns the requested target
  20087. */
  20088. getActiveTarget(index: number): MorphTarget;
  20089. /**
  20090. * Gets the target at specified index
  20091. * @param index defines the index to check
  20092. * @returns the requested target
  20093. */
  20094. getTarget(index: number): MorphTarget;
  20095. /**
  20096. * Add a new target to this manager
  20097. * @param target defines the target to add
  20098. */
  20099. addTarget(target: MorphTarget): void;
  20100. /**
  20101. * Removes a target from the manager
  20102. * @param target defines the target to remove
  20103. */
  20104. removeTarget(target: MorphTarget): void;
  20105. /**
  20106. * Serializes the current manager into a Serialization object
  20107. * @returns the serialized object
  20108. */
  20109. serialize(): any;
  20110. private _syncActiveTargets;
  20111. /**
  20112. * Syncrhonize the targets with all the meshes using this morph target manager
  20113. */
  20114. synchronize(): void;
  20115. /**
  20116. * Creates a new MorphTargetManager from serialized data
  20117. * @param serializationObject defines the serialized data
  20118. * @param scene defines the hosting scene
  20119. * @returns the new MorphTargetManager
  20120. */
  20121. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20122. }
  20123. }
  20124. declare module "babylonjs/Meshes/meshLODLevel" {
  20125. import { Mesh } from "babylonjs/Meshes/mesh";
  20126. import { Nullable } from "babylonjs/types";
  20127. /**
  20128. * Class used to represent a specific level of detail of a mesh
  20129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20130. */
  20131. export class MeshLODLevel {
  20132. /** Defines the distance where this level should star being displayed */
  20133. distance: number;
  20134. /** Defines the mesh to use to render this level */
  20135. mesh: Nullable<Mesh>;
  20136. /**
  20137. * Creates a new LOD level
  20138. * @param distance defines the distance where this level should star being displayed
  20139. * @param mesh defines the mesh to use to render this level
  20140. */
  20141. constructor(
  20142. /** Defines the distance where this level should star being displayed */
  20143. distance: number,
  20144. /** Defines the mesh to use to render this level */
  20145. mesh: Nullable<Mesh>);
  20146. }
  20147. }
  20148. declare module "babylonjs/Meshes/groundMesh" {
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Vector3 } from "babylonjs/Maths/math";
  20151. import { Mesh } from "babylonjs/Meshes/mesh";
  20152. /**
  20153. * Mesh representing the gorund
  20154. */
  20155. export class GroundMesh extends Mesh {
  20156. /** If octree should be generated */
  20157. generateOctree: boolean;
  20158. private _heightQuads;
  20159. /** @hidden */
  20160. _subdivisionsX: number;
  20161. /** @hidden */
  20162. _subdivisionsY: number;
  20163. /** @hidden */
  20164. _width: number;
  20165. /** @hidden */
  20166. _height: number;
  20167. /** @hidden */
  20168. _minX: number;
  20169. /** @hidden */
  20170. _maxX: number;
  20171. /** @hidden */
  20172. _minZ: number;
  20173. /** @hidden */
  20174. _maxZ: number;
  20175. constructor(name: string, scene: Scene);
  20176. /**
  20177. * "GroundMesh"
  20178. * @returns "GroundMesh"
  20179. */
  20180. getClassName(): string;
  20181. /**
  20182. * The minimum of x and y subdivisions
  20183. */
  20184. readonly subdivisions: number;
  20185. /**
  20186. * X subdivisions
  20187. */
  20188. readonly subdivisionsX: number;
  20189. /**
  20190. * Y subdivisions
  20191. */
  20192. readonly subdivisionsY: number;
  20193. /**
  20194. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20195. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20196. * @param chunksCount the number of subdivisions for x and y
  20197. * @param octreeBlocksSize (Default: 32)
  20198. */
  20199. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20200. /**
  20201. * Returns a height (y) value in the Worl system :
  20202. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20203. * @param x x coordinate
  20204. * @param z z coordinate
  20205. * @returns the ground y position if (x, z) are outside the ground surface.
  20206. */
  20207. getHeightAtCoordinates(x: number, z: number): number;
  20208. /**
  20209. * Returns a normalized vector (Vector3) orthogonal to the ground
  20210. * at the ground coordinates (x, z) expressed in the World system.
  20211. * @param x x coordinate
  20212. * @param z z coordinate
  20213. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20214. */
  20215. getNormalAtCoordinates(x: number, z: number): Vector3;
  20216. /**
  20217. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20218. * at the ground coordinates (x, z) expressed in the World system.
  20219. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20220. * @param x x coordinate
  20221. * @param z z coordinate
  20222. * @param ref vector to store the result
  20223. * @returns the GroundMesh.
  20224. */
  20225. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20226. /**
  20227. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20228. * if the ground has been updated.
  20229. * This can be used in the render loop.
  20230. * @returns the GroundMesh.
  20231. */
  20232. updateCoordinateHeights(): GroundMesh;
  20233. private _getFacetAt;
  20234. private _initHeightQuads;
  20235. private _computeHeightQuads;
  20236. /**
  20237. * Serializes this ground mesh
  20238. * @param serializationObject object to write serialization to
  20239. */
  20240. serialize(serializationObject: any): void;
  20241. /**
  20242. * Parses a serialized ground mesh
  20243. * @param parsedMesh the serialized mesh
  20244. * @param scene the scene to create the ground mesh in
  20245. * @returns the created ground mesh
  20246. */
  20247. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20248. }
  20249. }
  20250. declare module "babylonjs/Physics/physicsJoint" {
  20251. import { Vector3 } from "babylonjs/Maths/math";
  20252. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20253. /**
  20254. * Interface for Physics-Joint data
  20255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20256. */
  20257. export interface PhysicsJointData {
  20258. /**
  20259. * The main pivot of the joint
  20260. */
  20261. mainPivot?: Vector3;
  20262. /**
  20263. * The connected pivot of the joint
  20264. */
  20265. connectedPivot?: Vector3;
  20266. /**
  20267. * The main axis of the joint
  20268. */
  20269. mainAxis?: Vector3;
  20270. /**
  20271. * The connected axis of the joint
  20272. */
  20273. connectedAxis?: Vector3;
  20274. /**
  20275. * The collision of the joint
  20276. */
  20277. collision?: boolean;
  20278. /**
  20279. * Native Oimo/Cannon/Energy data
  20280. */
  20281. nativeParams?: any;
  20282. }
  20283. /**
  20284. * This is a holder class for the physics joint created by the physics plugin
  20285. * It holds a set of functions to control the underlying joint
  20286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20287. */
  20288. export class PhysicsJoint {
  20289. /**
  20290. * The type of the physics joint
  20291. */
  20292. type: number;
  20293. /**
  20294. * The data for the physics joint
  20295. */
  20296. jointData: PhysicsJointData;
  20297. private _physicsJoint;
  20298. protected _physicsPlugin: IPhysicsEnginePlugin;
  20299. /**
  20300. * Initializes the physics joint
  20301. * @param type The type of the physics joint
  20302. * @param jointData The data for the physics joint
  20303. */
  20304. constructor(
  20305. /**
  20306. * The type of the physics joint
  20307. */
  20308. type: number,
  20309. /**
  20310. * The data for the physics joint
  20311. */
  20312. jointData: PhysicsJointData);
  20313. /**
  20314. * Gets the physics joint
  20315. */
  20316. /**
  20317. * Sets the physics joint
  20318. */
  20319. physicsJoint: any;
  20320. /**
  20321. * Sets the physics plugin
  20322. */
  20323. physicsPlugin: IPhysicsEnginePlugin;
  20324. /**
  20325. * Execute a function that is physics-plugin specific.
  20326. * @param {Function} func the function that will be executed.
  20327. * It accepts two parameters: the physics world and the physics joint
  20328. */
  20329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20330. /**
  20331. * Distance-Joint type
  20332. */
  20333. static DistanceJoint: number;
  20334. /**
  20335. * Hinge-Joint type
  20336. */
  20337. static HingeJoint: number;
  20338. /**
  20339. * Ball-and-Socket joint type
  20340. */
  20341. static BallAndSocketJoint: number;
  20342. /**
  20343. * Wheel-Joint type
  20344. */
  20345. static WheelJoint: number;
  20346. /**
  20347. * Slider-Joint type
  20348. */
  20349. static SliderJoint: number;
  20350. /**
  20351. * Prismatic-Joint type
  20352. */
  20353. static PrismaticJoint: number;
  20354. /**
  20355. * Universal-Joint type
  20356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20357. */
  20358. static UniversalJoint: number;
  20359. /**
  20360. * Hinge-Joint 2 type
  20361. */
  20362. static Hinge2Joint: number;
  20363. /**
  20364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20365. */
  20366. static PointToPointJoint: number;
  20367. /**
  20368. * Spring-Joint type
  20369. */
  20370. static SpringJoint: number;
  20371. /**
  20372. * Lock-Joint type
  20373. */
  20374. static LockJoint: number;
  20375. }
  20376. /**
  20377. * A class representing a physics distance joint
  20378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20379. */
  20380. export class DistanceJoint extends PhysicsJoint {
  20381. /**
  20382. *
  20383. * @param jointData The data for the Distance-Joint
  20384. */
  20385. constructor(jointData: DistanceJointData);
  20386. /**
  20387. * Update the predefined distance.
  20388. * @param maxDistance The maximum preferred distance
  20389. * @param minDistance The minimum preferred distance
  20390. */
  20391. updateDistance(maxDistance: number, minDistance?: number): void;
  20392. }
  20393. /**
  20394. * Represents a Motor-Enabled Joint
  20395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20396. */
  20397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20398. /**
  20399. * Initializes the Motor-Enabled Joint
  20400. * @param type The type of the joint
  20401. * @param jointData The physica joint data for the joint
  20402. */
  20403. constructor(type: number, jointData: PhysicsJointData);
  20404. /**
  20405. * Set the motor values.
  20406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20407. * @param force the force to apply
  20408. * @param maxForce max force for this motor.
  20409. */
  20410. setMotor(force?: number, maxForce?: number): void;
  20411. /**
  20412. * Set the motor's limits.
  20413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20414. * @param upperLimit The upper limit of the motor
  20415. * @param lowerLimit The lower limit of the motor
  20416. */
  20417. setLimit(upperLimit: number, lowerLimit?: number): void;
  20418. }
  20419. /**
  20420. * This class represents a single physics Hinge-Joint
  20421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20422. */
  20423. export class HingeJoint extends MotorEnabledJoint {
  20424. /**
  20425. * Initializes the Hinge-Joint
  20426. * @param jointData The joint data for the Hinge-Joint
  20427. */
  20428. constructor(jointData: PhysicsJointData);
  20429. /**
  20430. * Set the motor values.
  20431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20432. * @param {number} force the force to apply
  20433. * @param {number} maxForce max force for this motor.
  20434. */
  20435. setMotor(force?: number, maxForce?: number): void;
  20436. /**
  20437. * Set the motor's limits.
  20438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20439. * @param upperLimit The upper limit of the motor
  20440. * @param lowerLimit The lower limit of the motor
  20441. */
  20442. setLimit(upperLimit: number, lowerLimit?: number): void;
  20443. }
  20444. /**
  20445. * This class represents a dual hinge physics joint (same as wheel joint)
  20446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20447. */
  20448. export class Hinge2Joint extends MotorEnabledJoint {
  20449. /**
  20450. * Initializes the Hinge2-Joint
  20451. * @param jointData The joint data for the Hinge2-Joint
  20452. */
  20453. constructor(jointData: PhysicsJointData);
  20454. /**
  20455. * Set the motor values.
  20456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20457. * @param {number} targetSpeed the speed the motor is to reach
  20458. * @param {number} maxForce max force for this motor.
  20459. * @param {motorIndex} the motor's index, 0 or 1.
  20460. */
  20461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20462. /**
  20463. * Set the motor limits.
  20464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20465. * @param {number} upperLimit the upper limit
  20466. * @param {number} lowerLimit lower limit
  20467. * @param {motorIndex} the motor's index, 0 or 1.
  20468. */
  20469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20470. }
  20471. /**
  20472. * Interface for a motor enabled joint
  20473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20474. */
  20475. export interface IMotorEnabledJoint {
  20476. /**
  20477. * Physics joint
  20478. */
  20479. physicsJoint: any;
  20480. /**
  20481. * Sets the motor of the motor-enabled joint
  20482. * @param force The force of the motor
  20483. * @param maxForce The maximum force of the motor
  20484. * @param motorIndex The index of the motor
  20485. */
  20486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20487. /**
  20488. * Sets the limit of the motor
  20489. * @param upperLimit The upper limit of the motor
  20490. * @param lowerLimit The lower limit of the motor
  20491. * @param motorIndex The index of the motor
  20492. */
  20493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20494. }
  20495. /**
  20496. * Joint data for a Distance-Joint
  20497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20498. */
  20499. export interface DistanceJointData extends PhysicsJointData {
  20500. /**
  20501. * Max distance the 2 joint objects can be apart
  20502. */
  20503. maxDistance: number;
  20504. }
  20505. /**
  20506. * Joint data from a spring joint
  20507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20508. */
  20509. export interface SpringJointData extends PhysicsJointData {
  20510. /**
  20511. * Length of the spring
  20512. */
  20513. length: number;
  20514. /**
  20515. * Stiffness of the spring
  20516. */
  20517. stiffness: number;
  20518. /**
  20519. * Damping of the spring
  20520. */
  20521. damping: number;
  20522. /** this callback will be called when applying the force to the impostors. */
  20523. forceApplicationCallback: () => void;
  20524. }
  20525. }
  20526. declare module "babylonjs/Physics/physicsRaycastResult" {
  20527. import { Vector3 } from "babylonjs/Maths/math";
  20528. /**
  20529. * Holds the data for the raycast result
  20530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20531. */
  20532. export class PhysicsRaycastResult {
  20533. private _hasHit;
  20534. private _hitDistance;
  20535. private _hitNormalWorld;
  20536. private _hitPointWorld;
  20537. private _rayFromWorld;
  20538. private _rayToWorld;
  20539. /**
  20540. * Gets if there was a hit
  20541. */
  20542. readonly hasHit: boolean;
  20543. /**
  20544. * Gets the distance from the hit
  20545. */
  20546. readonly hitDistance: number;
  20547. /**
  20548. * Gets the hit normal/direction in the world
  20549. */
  20550. readonly hitNormalWorld: Vector3;
  20551. /**
  20552. * Gets the hit point in the world
  20553. */
  20554. readonly hitPointWorld: Vector3;
  20555. /**
  20556. * Gets the ray "start point" of the ray in the world
  20557. */
  20558. readonly rayFromWorld: Vector3;
  20559. /**
  20560. * Gets the ray "end point" of the ray in the world
  20561. */
  20562. readonly rayToWorld: Vector3;
  20563. /**
  20564. * Sets the hit data (normal & point in world space)
  20565. * @param hitNormalWorld defines the normal in world space
  20566. * @param hitPointWorld defines the point in world space
  20567. */
  20568. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20569. /**
  20570. * Sets the distance from the start point to the hit point
  20571. * @param distance
  20572. */
  20573. setHitDistance(distance: number): void;
  20574. /**
  20575. * Calculates the distance manually
  20576. */
  20577. calculateHitDistance(): void;
  20578. /**
  20579. * Resets all the values to default
  20580. * @param from The from point on world space
  20581. * @param to The to point on world space
  20582. */
  20583. reset(from?: Vector3, to?: Vector3): void;
  20584. }
  20585. /**
  20586. * Interface for the size containing width and height
  20587. */
  20588. interface IXYZ {
  20589. /**
  20590. * X
  20591. */
  20592. x: number;
  20593. /**
  20594. * Y
  20595. */
  20596. y: number;
  20597. /**
  20598. * Z
  20599. */
  20600. z: number;
  20601. }
  20602. }
  20603. declare module "babylonjs/Physics/IPhysicsEngine" {
  20604. import { Nullable } from "babylonjs/types";
  20605. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20607. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20608. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20609. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20610. /**
  20611. * Interface used to describe a physics joint
  20612. */
  20613. export interface PhysicsImpostorJoint {
  20614. /** Defines the main impostor to which the joint is linked */
  20615. mainImpostor: PhysicsImpostor;
  20616. /** Defines the impostor that is connected to the main impostor using this joint */
  20617. connectedImpostor: PhysicsImpostor;
  20618. /** Defines the joint itself */
  20619. joint: PhysicsJoint;
  20620. }
  20621. /** @hidden */
  20622. export interface IPhysicsEnginePlugin {
  20623. world: any;
  20624. name: string;
  20625. setGravity(gravity: Vector3): void;
  20626. setTimeStep(timeStep: number): void;
  20627. getTimeStep(): number;
  20628. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20630. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20631. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20632. removePhysicsBody(impostor: PhysicsImpostor): void;
  20633. generateJoint(joint: PhysicsImpostorJoint): void;
  20634. removeJoint(joint: PhysicsImpostorJoint): void;
  20635. isSupported(): boolean;
  20636. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20637. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20643. getBodyMass(impostor: PhysicsImpostor): number;
  20644. getBodyFriction(impostor: PhysicsImpostor): number;
  20645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20646. getBodyRestitution(impostor: PhysicsImpostor): number;
  20647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20648. getBodyPressure?(impostor: PhysicsImpostor): number;
  20649. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20650. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20651. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20652. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20653. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20654. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20655. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20656. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20657. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20658. sleepBody(impostor: PhysicsImpostor): void;
  20659. wakeUpBody(impostor: PhysicsImpostor): void;
  20660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20661. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20662. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20663. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20664. getRadius(impostor: PhysicsImpostor): number;
  20665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20667. dispose(): void;
  20668. }
  20669. /**
  20670. * Interface used to define a physics engine
  20671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20672. */
  20673. export interface IPhysicsEngine {
  20674. /**
  20675. * Gets the gravity vector used by the simulation
  20676. */
  20677. gravity: Vector3;
  20678. /**
  20679. * Sets the gravity vector used by the simulation
  20680. * @param gravity defines the gravity vector to use
  20681. */
  20682. setGravity(gravity: Vector3): void;
  20683. /**
  20684. * Set the time step of the physics engine.
  20685. * Default is 1/60.
  20686. * To slow it down, enter 1/600 for example.
  20687. * To speed it up, 1/30
  20688. * @param newTimeStep the new timestep to apply to this world.
  20689. */
  20690. setTimeStep(newTimeStep: number): void;
  20691. /**
  20692. * Get the time step of the physics engine.
  20693. * @returns the current time step
  20694. */
  20695. getTimeStep(): number;
  20696. /**
  20697. * Release all resources
  20698. */
  20699. dispose(): void;
  20700. /**
  20701. * Gets the name of the current physics plugin
  20702. * @returns the name of the plugin
  20703. */
  20704. getPhysicsPluginName(): string;
  20705. /**
  20706. * Adding a new impostor for the impostor tracking.
  20707. * This will be done by the impostor itself.
  20708. * @param impostor the impostor to add
  20709. */
  20710. addImpostor(impostor: PhysicsImpostor): void;
  20711. /**
  20712. * Remove an impostor from the engine.
  20713. * This impostor and its mesh will not longer be updated by the physics engine.
  20714. * @param impostor the impostor to remove
  20715. */
  20716. removeImpostor(impostor: PhysicsImpostor): void;
  20717. /**
  20718. * Add a joint to the physics engine
  20719. * @param mainImpostor defines the main impostor to which the joint is added.
  20720. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20721. * @param joint defines the joint that will connect both impostors.
  20722. */
  20723. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20724. /**
  20725. * Removes a joint from the simulation
  20726. * @param mainImpostor defines the impostor used with the joint
  20727. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20728. * @param joint defines the joint to remove
  20729. */
  20730. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20731. /**
  20732. * Gets the current plugin used to run the simulation
  20733. * @returns current plugin
  20734. */
  20735. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20736. /**
  20737. * Gets the list of physic impostors
  20738. * @returns an array of PhysicsImpostor
  20739. */
  20740. getImpostors(): Array<PhysicsImpostor>;
  20741. /**
  20742. * Gets the impostor for a physics enabled object
  20743. * @param object defines the object impersonated by the impostor
  20744. * @returns the PhysicsImpostor or null if not found
  20745. */
  20746. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20747. /**
  20748. * Gets the impostor for a physics body object
  20749. * @param body defines physics body used by the impostor
  20750. * @returns the PhysicsImpostor or null if not found
  20751. */
  20752. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20753. /**
  20754. * Does a raycast in the physics world
  20755. * @param from when should the ray start?
  20756. * @param to when should the ray end?
  20757. * @returns PhysicsRaycastResult
  20758. */
  20759. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20760. /**
  20761. * Called by the scene. No need to call it.
  20762. * @param delta defines the timespam between frames
  20763. */
  20764. _step(delta: number): void;
  20765. }
  20766. }
  20767. declare module "babylonjs/Physics/physicsImpostor" {
  20768. import { Nullable, IndicesArray } from "babylonjs/types";
  20769. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20772. import { Scene } from "babylonjs/scene";
  20773. import { Bone } from "babylonjs/Bones/bone";
  20774. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20775. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20776. /**
  20777. * The interface for the physics imposter parameters
  20778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20779. */
  20780. export interface PhysicsImpostorParameters {
  20781. /**
  20782. * The mass of the physics imposter
  20783. */
  20784. mass: number;
  20785. /**
  20786. * The friction of the physics imposter
  20787. */
  20788. friction?: number;
  20789. /**
  20790. * The coefficient of restitution of the physics imposter
  20791. */
  20792. restitution?: number;
  20793. /**
  20794. * The native options of the physics imposter
  20795. */
  20796. nativeOptions?: any;
  20797. /**
  20798. * Specifies if the parent should be ignored
  20799. */
  20800. ignoreParent?: boolean;
  20801. /**
  20802. * Specifies if bi-directional transformations should be disabled
  20803. */
  20804. disableBidirectionalTransformation?: boolean;
  20805. /**
  20806. * The pressure inside the physics imposter, soft object only
  20807. */
  20808. pressure?: number;
  20809. /**
  20810. * The stiffness the physics imposter, soft object only
  20811. */
  20812. stiffness?: number;
  20813. /**
  20814. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20815. */
  20816. velocityIterations?: number;
  20817. /**
  20818. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20819. */
  20820. positionIterations?: number;
  20821. /**
  20822. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20823. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20824. * Add to fix multiple points
  20825. */
  20826. fixedPoints?: number;
  20827. /**
  20828. * The collision margin around a soft object
  20829. */
  20830. margin?: number;
  20831. /**
  20832. * The collision margin around a soft object
  20833. */
  20834. damping?: number;
  20835. /**
  20836. * The path for a rope based on an extrusion
  20837. */
  20838. path?: any;
  20839. /**
  20840. * The shape of an extrusion used for a rope based on an extrusion
  20841. */
  20842. shape?: any;
  20843. }
  20844. /**
  20845. * Interface for a physics-enabled object
  20846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20847. */
  20848. export interface IPhysicsEnabledObject {
  20849. /**
  20850. * The position of the physics-enabled object
  20851. */
  20852. position: Vector3;
  20853. /**
  20854. * The rotation of the physics-enabled object
  20855. */
  20856. rotationQuaternion: Nullable<Quaternion>;
  20857. /**
  20858. * The scale of the physics-enabled object
  20859. */
  20860. scaling: Vector3;
  20861. /**
  20862. * The rotation of the physics-enabled object
  20863. */
  20864. rotation?: Vector3;
  20865. /**
  20866. * The parent of the physics-enabled object
  20867. */
  20868. parent?: any;
  20869. /**
  20870. * The bounding info of the physics-enabled object
  20871. * @returns The bounding info of the physics-enabled object
  20872. */
  20873. getBoundingInfo(): BoundingInfo;
  20874. /**
  20875. * Computes the world matrix
  20876. * @param force Specifies if the world matrix should be computed by force
  20877. * @returns A world matrix
  20878. */
  20879. computeWorldMatrix(force: boolean): Matrix;
  20880. /**
  20881. * Gets the world matrix
  20882. * @returns A world matrix
  20883. */
  20884. getWorldMatrix?(): Matrix;
  20885. /**
  20886. * Gets the child meshes
  20887. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20888. * @returns An array of abstract meshes
  20889. */
  20890. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20891. /**
  20892. * Gets the vertex data
  20893. * @param kind The type of vertex data
  20894. * @returns A nullable array of numbers, or a float32 array
  20895. */
  20896. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20897. /**
  20898. * Gets the indices from the mesh
  20899. * @returns A nullable array of index arrays
  20900. */
  20901. getIndices?(): Nullable<IndicesArray>;
  20902. /**
  20903. * Gets the scene from the mesh
  20904. * @returns the indices array or null
  20905. */
  20906. getScene?(): Scene;
  20907. /**
  20908. * Gets the absolute position from the mesh
  20909. * @returns the absolute position
  20910. */
  20911. getAbsolutePosition(): Vector3;
  20912. /**
  20913. * Gets the absolute pivot point from the mesh
  20914. * @returns the absolute pivot point
  20915. */
  20916. getAbsolutePivotPoint(): Vector3;
  20917. /**
  20918. * Rotates the mesh
  20919. * @param axis The axis of rotation
  20920. * @param amount The amount of rotation
  20921. * @param space The space of the rotation
  20922. * @returns The rotation transform node
  20923. */
  20924. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20925. /**
  20926. * Translates the mesh
  20927. * @param axis The axis of translation
  20928. * @param distance The distance of translation
  20929. * @param space The space of the translation
  20930. * @returns The transform node
  20931. */
  20932. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20933. /**
  20934. * Sets the absolute position of the mesh
  20935. * @param absolutePosition The absolute position of the mesh
  20936. * @returns The transform node
  20937. */
  20938. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20939. /**
  20940. * Gets the class name of the mesh
  20941. * @returns The class name
  20942. */
  20943. getClassName(): string;
  20944. }
  20945. /**
  20946. * Represents a physics imposter
  20947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20948. */
  20949. export class PhysicsImpostor {
  20950. /**
  20951. * The physics-enabled object used as the physics imposter
  20952. */
  20953. object: IPhysicsEnabledObject;
  20954. /**
  20955. * The type of the physics imposter
  20956. */
  20957. type: number;
  20958. private _options;
  20959. private _scene?;
  20960. /**
  20961. * The default object size of the imposter
  20962. */
  20963. static DEFAULT_OBJECT_SIZE: Vector3;
  20964. /**
  20965. * The identity quaternion of the imposter
  20966. */
  20967. static IDENTITY_QUATERNION: Quaternion;
  20968. /** @hidden */
  20969. _pluginData: any;
  20970. private _physicsEngine;
  20971. private _physicsBody;
  20972. private _bodyUpdateRequired;
  20973. private _onBeforePhysicsStepCallbacks;
  20974. private _onAfterPhysicsStepCallbacks;
  20975. /** @hidden */
  20976. _onPhysicsCollideCallbacks: Array<{
  20977. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20978. otherImpostors: Array<PhysicsImpostor>;
  20979. }>;
  20980. private _deltaPosition;
  20981. private _deltaRotation;
  20982. private _deltaRotationConjugated;
  20983. /** hidden */
  20984. _isFromLine: boolean;
  20985. private _parent;
  20986. private _isDisposed;
  20987. private static _tmpVecs;
  20988. private static _tmpQuat;
  20989. /**
  20990. * Specifies if the physics imposter is disposed
  20991. */
  20992. readonly isDisposed: boolean;
  20993. /**
  20994. * Gets the mass of the physics imposter
  20995. */
  20996. mass: number;
  20997. /**
  20998. * Gets the coefficient of friction
  20999. */
  21000. /**
  21001. * Sets the coefficient of friction
  21002. */
  21003. friction: number;
  21004. /**
  21005. * Gets the coefficient of restitution
  21006. */
  21007. /**
  21008. * Sets the coefficient of restitution
  21009. */
  21010. restitution: number;
  21011. /**
  21012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21013. */
  21014. /**
  21015. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21016. */
  21017. pressure: number;
  21018. /**
  21019. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21020. */
  21021. /**
  21022. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21023. */
  21024. stiffness: number;
  21025. /**
  21026. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21027. */
  21028. /**
  21029. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21030. */
  21031. velocityIterations: number;
  21032. /**
  21033. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21034. */
  21035. /**
  21036. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21037. */
  21038. positionIterations: number;
  21039. /**
  21040. * The unique id of the physics imposter
  21041. * set by the physics engine when adding this impostor to the array
  21042. */
  21043. uniqueId: number;
  21044. /**
  21045. * @hidden
  21046. */
  21047. soft: boolean;
  21048. /**
  21049. * @hidden
  21050. */
  21051. segments: number;
  21052. private _joints;
  21053. /**
  21054. * Initializes the physics imposter
  21055. * @param object The physics-enabled object used as the physics imposter
  21056. * @param type The type of the physics imposter
  21057. * @param _options The options for the physics imposter
  21058. * @param _scene The Babylon scene
  21059. */
  21060. constructor(
  21061. /**
  21062. * The physics-enabled object used as the physics imposter
  21063. */
  21064. object: IPhysicsEnabledObject,
  21065. /**
  21066. * The type of the physics imposter
  21067. */
  21068. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21069. /**
  21070. * This function will completly initialize this impostor.
  21071. * It will create a new body - but only if this mesh has no parent.
  21072. * If it has, this impostor will not be used other than to define the impostor
  21073. * of the child mesh.
  21074. * @hidden
  21075. */
  21076. _init(): void;
  21077. private _getPhysicsParent;
  21078. /**
  21079. * Should a new body be generated.
  21080. * @returns boolean specifying if body initialization is required
  21081. */
  21082. isBodyInitRequired(): boolean;
  21083. /**
  21084. * Sets the updated scaling
  21085. * @param updated Specifies if the scaling is updated
  21086. */
  21087. setScalingUpdated(): void;
  21088. /**
  21089. * Force a regeneration of this or the parent's impostor's body.
  21090. * Use under cautious - This will remove all joints already implemented.
  21091. */
  21092. forceUpdate(): void;
  21093. /**
  21094. * Gets the body that holds this impostor. Either its own, or its parent.
  21095. */
  21096. /**
  21097. * Set the physics body. Used mainly by the physics engine/plugin
  21098. */
  21099. physicsBody: any;
  21100. /**
  21101. * Get the parent of the physics imposter
  21102. * @returns Physics imposter or null
  21103. */
  21104. /**
  21105. * Sets the parent of the physics imposter
  21106. */
  21107. parent: Nullable<PhysicsImpostor>;
  21108. /**
  21109. * Resets the update flags
  21110. */
  21111. resetUpdateFlags(): void;
  21112. /**
  21113. * Gets the object extend size
  21114. * @returns the object extend size
  21115. */
  21116. getObjectExtendSize(): Vector3;
  21117. /**
  21118. * Gets the object center
  21119. * @returns The object center
  21120. */
  21121. getObjectCenter(): Vector3;
  21122. /**
  21123. * Get a specific parametes from the options parameter
  21124. * @param paramName The object parameter name
  21125. * @returns The object parameter
  21126. */
  21127. getParam(paramName: string): any;
  21128. /**
  21129. * Sets a specific parameter in the options given to the physics plugin
  21130. * @param paramName The parameter name
  21131. * @param value The value of the parameter
  21132. */
  21133. setParam(paramName: string, value: number): void;
  21134. /**
  21135. * Specifically change the body's mass option. Won't recreate the physics body object
  21136. * @param mass The mass of the physics imposter
  21137. */
  21138. setMass(mass: number): void;
  21139. /**
  21140. * Gets the linear velocity
  21141. * @returns linear velocity or null
  21142. */
  21143. getLinearVelocity(): Nullable<Vector3>;
  21144. /**
  21145. * Sets the linear velocity
  21146. * @param velocity linear velocity or null
  21147. */
  21148. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21149. /**
  21150. * Gets the angular velocity
  21151. * @returns angular velocity or null
  21152. */
  21153. getAngularVelocity(): Nullable<Vector3>;
  21154. /**
  21155. * Sets the angular velocity
  21156. * @param velocity The velocity or null
  21157. */
  21158. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21159. /**
  21160. * Execute a function with the physics plugin native code
  21161. * Provide a function the will have two variables - the world object and the physics body object
  21162. * @param func The function to execute with the physics plugin native code
  21163. */
  21164. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21165. /**
  21166. * Register a function that will be executed before the physics world is stepping forward
  21167. * @param func The function to execute before the physics world is stepped forward
  21168. */
  21169. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21170. /**
  21171. * Unregister a function that will be executed before the physics world is stepping forward
  21172. * @param func The function to execute before the physics world is stepped forward
  21173. */
  21174. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21175. /**
  21176. * Register a function that will be executed after the physics step
  21177. * @param func The function to execute after physics step
  21178. */
  21179. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21180. /**
  21181. * Unregisters a function that will be executed after the physics step
  21182. * @param func The function to execute after physics step
  21183. */
  21184. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21185. /**
  21186. * register a function that will be executed when this impostor collides against a different body
  21187. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21188. * @param func Callback that is executed on collision
  21189. */
  21190. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21191. /**
  21192. * Unregisters the physics imposter on contact
  21193. * @param collideAgainst The physics object to collide against
  21194. * @param func Callback to execute on collision
  21195. */
  21196. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21197. private _tmpQuat;
  21198. private _tmpQuat2;
  21199. /**
  21200. * Get the parent rotation
  21201. * @returns The parent rotation
  21202. */
  21203. getParentsRotation(): Quaternion;
  21204. /**
  21205. * this function is executed by the physics engine.
  21206. */
  21207. beforeStep: () => void;
  21208. /**
  21209. * this function is executed by the physics engine
  21210. */
  21211. afterStep: () => void;
  21212. /**
  21213. * Legacy collision detection event support
  21214. */
  21215. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21216. /**
  21217. * event and body object due to cannon's event-based architecture.
  21218. */
  21219. onCollide: (e: {
  21220. body: any;
  21221. }) => void;
  21222. /**
  21223. * Apply a force
  21224. * @param force The force to apply
  21225. * @param contactPoint The contact point for the force
  21226. * @returns The physics imposter
  21227. */
  21228. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21229. /**
  21230. * Apply an impulse
  21231. * @param force The impulse force
  21232. * @param contactPoint The contact point for the impulse force
  21233. * @returns The physics imposter
  21234. */
  21235. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21236. /**
  21237. * A help function to create a joint
  21238. * @param otherImpostor A physics imposter used to create a joint
  21239. * @param jointType The type of joint
  21240. * @param jointData The data for the joint
  21241. * @returns The physics imposter
  21242. */
  21243. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21244. /**
  21245. * Add a joint to this impostor with a different impostor
  21246. * @param otherImpostor A physics imposter used to add a joint
  21247. * @param joint The joint to add
  21248. * @returns The physics imposter
  21249. */
  21250. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21251. /**
  21252. * Add an anchor to a cloth impostor
  21253. * @param otherImpostor rigid impostor to anchor to
  21254. * @param width ratio across width from 0 to 1
  21255. * @param height ratio up height from 0 to 1
  21256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21257. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21258. * @returns impostor the soft imposter
  21259. */
  21260. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21261. /**
  21262. * Add a hook to a rope impostor
  21263. * @param otherImpostor rigid impostor to anchor to
  21264. * @param length ratio across rope from 0 to 1
  21265. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21267. * @returns impostor the rope imposter
  21268. */
  21269. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21270. /**
  21271. * Will keep this body still, in a sleep mode.
  21272. * @returns the physics imposter
  21273. */
  21274. sleep(): PhysicsImpostor;
  21275. /**
  21276. * Wake the body up.
  21277. * @returns The physics imposter
  21278. */
  21279. wakeUp(): PhysicsImpostor;
  21280. /**
  21281. * Clones the physics imposter
  21282. * @param newObject The physics imposter clones to this physics-enabled object
  21283. * @returns A nullable physics imposter
  21284. */
  21285. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21286. /**
  21287. * Disposes the physics imposter
  21288. */
  21289. dispose(): void;
  21290. /**
  21291. * Sets the delta position
  21292. * @param position The delta position amount
  21293. */
  21294. setDeltaPosition(position: Vector3): void;
  21295. /**
  21296. * Sets the delta rotation
  21297. * @param rotation The delta rotation amount
  21298. */
  21299. setDeltaRotation(rotation: Quaternion): void;
  21300. /**
  21301. * Gets the box size of the physics imposter and stores the result in the input parameter
  21302. * @param result Stores the box size
  21303. * @returns The physics imposter
  21304. */
  21305. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21306. /**
  21307. * Gets the radius of the physics imposter
  21308. * @returns Radius of the physics imposter
  21309. */
  21310. getRadius(): number;
  21311. /**
  21312. * Sync a bone with this impostor
  21313. * @param bone The bone to sync to the impostor.
  21314. * @param boneMesh The mesh that the bone is influencing.
  21315. * @param jointPivot The pivot of the joint / bone in local space.
  21316. * @param distToJoint Optional distance from the impostor to the joint.
  21317. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21318. */
  21319. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21320. /**
  21321. * Sync impostor to a bone
  21322. * @param bone The bone that the impostor will be synced to.
  21323. * @param boneMesh The mesh that the bone is influencing.
  21324. * @param jointPivot The pivot of the joint / bone in local space.
  21325. * @param distToJoint Optional distance from the impostor to the joint.
  21326. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21327. * @param boneAxis Optional vector3 axis the bone is aligned with
  21328. */
  21329. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21330. /**
  21331. * No-Imposter type
  21332. */
  21333. static NoImpostor: number;
  21334. /**
  21335. * Sphere-Imposter type
  21336. */
  21337. static SphereImpostor: number;
  21338. /**
  21339. * Box-Imposter type
  21340. */
  21341. static BoxImpostor: number;
  21342. /**
  21343. * Plane-Imposter type
  21344. */
  21345. static PlaneImpostor: number;
  21346. /**
  21347. * Mesh-imposter type
  21348. */
  21349. static MeshImpostor: number;
  21350. /**
  21351. * Cylinder-Imposter type
  21352. */
  21353. static CylinderImpostor: number;
  21354. /**
  21355. * Particle-Imposter type
  21356. */
  21357. static ParticleImpostor: number;
  21358. /**
  21359. * Heightmap-Imposter type
  21360. */
  21361. static HeightmapImpostor: number;
  21362. /**
  21363. * ConvexHull-Impostor type (Ammo.js plugin only)
  21364. */
  21365. static ConvexHullImpostor: number;
  21366. /**
  21367. * Rope-Imposter type
  21368. */
  21369. static RopeImpostor: number;
  21370. /**
  21371. * Cloth-Imposter type
  21372. */
  21373. static ClothImpostor: number;
  21374. /**
  21375. * Softbody-Imposter type
  21376. */
  21377. static SoftbodyImpostor: number;
  21378. }
  21379. }
  21380. declare module "babylonjs/Meshes/mesh" {
  21381. import { Observable } from "babylonjs/Misc/observable";
  21382. import { IAnimatable } from "babylonjs/Misc/tools";
  21383. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21384. import { Camera } from "babylonjs/Cameras/camera";
  21385. import { Scene } from "babylonjs/scene";
  21386. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21387. import { Engine } from "babylonjs/Engines/engine";
  21388. import { Node } from "babylonjs/node";
  21389. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21390. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21391. import { Buffer } from "babylonjs/Meshes/buffer";
  21392. import { Geometry } from "babylonjs/Meshes/geometry";
  21393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21395. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21396. import { Effect } from "babylonjs/Materials/effect";
  21397. import { Material } from "babylonjs/Materials/material";
  21398. import { Skeleton } from "babylonjs/Bones/skeleton";
  21399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21400. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21401. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21402. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21403. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21404. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21405. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21406. /**
  21407. * @hidden
  21408. **/
  21409. export class _CreationDataStorage {
  21410. closePath?: boolean;
  21411. closeArray?: boolean;
  21412. idx: number[];
  21413. dashSize: number;
  21414. gapSize: number;
  21415. path3D: Path3D;
  21416. pathArray: Vector3[][];
  21417. arc: number;
  21418. radius: number;
  21419. cap: number;
  21420. tessellation: number;
  21421. }
  21422. /**
  21423. * @hidden
  21424. **/
  21425. class _InstanceDataStorage {
  21426. visibleInstances: any;
  21427. batchCache: _InstancesBatch;
  21428. instancesBufferSize: number;
  21429. instancesBuffer: Nullable<Buffer>;
  21430. instancesData: Float32Array;
  21431. overridenInstanceCount: number;
  21432. isFrozen: boolean;
  21433. previousBatch: _InstancesBatch;
  21434. hardwareInstancedRendering: boolean;
  21435. sideOrientation: number;
  21436. }
  21437. /**
  21438. * @hidden
  21439. **/
  21440. export class _InstancesBatch {
  21441. mustReturn: boolean;
  21442. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21443. renderSelf: boolean[];
  21444. hardwareInstancedRendering: boolean[];
  21445. }
  21446. /**
  21447. * Class used to represent renderable models
  21448. */
  21449. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21450. /**
  21451. * Mesh side orientation : usually the external or front surface
  21452. */
  21453. static readonly FRONTSIDE: number;
  21454. /**
  21455. * Mesh side orientation : usually the internal or back surface
  21456. */
  21457. static readonly BACKSIDE: number;
  21458. /**
  21459. * Mesh side orientation : both internal and external or front and back surfaces
  21460. */
  21461. static readonly DOUBLESIDE: number;
  21462. /**
  21463. * Mesh side orientation : by default, `FRONTSIDE`
  21464. */
  21465. static readonly DEFAULTSIDE: number;
  21466. /**
  21467. * Mesh cap setting : no cap
  21468. */
  21469. static readonly NO_CAP: number;
  21470. /**
  21471. * Mesh cap setting : one cap at the beginning of the mesh
  21472. */
  21473. static readonly CAP_START: number;
  21474. /**
  21475. * Mesh cap setting : one cap at the end of the mesh
  21476. */
  21477. static readonly CAP_END: number;
  21478. /**
  21479. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21480. */
  21481. static readonly CAP_ALL: number;
  21482. /**
  21483. * Gets the default side orientation.
  21484. * @param orientation the orientation to value to attempt to get
  21485. * @returns the default orientation
  21486. * @hidden
  21487. */
  21488. static _GetDefaultSideOrientation(orientation?: number): number;
  21489. private _onBeforeRenderObservable;
  21490. private _onBeforeBindObservable;
  21491. private _onAfterRenderObservable;
  21492. private _onBeforeDrawObservable;
  21493. /**
  21494. * An event triggered before rendering the mesh
  21495. */
  21496. readonly onBeforeRenderObservable: Observable<Mesh>;
  21497. /**
  21498. * An event triggered before binding the mesh
  21499. */
  21500. readonly onBeforeBindObservable: Observable<Mesh>;
  21501. /**
  21502. * An event triggered after rendering the mesh
  21503. */
  21504. readonly onAfterRenderObservable: Observable<Mesh>;
  21505. /**
  21506. * An event triggered before drawing the mesh
  21507. */
  21508. readonly onBeforeDrawObservable: Observable<Mesh>;
  21509. private _onBeforeDrawObserver;
  21510. /**
  21511. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21512. */
  21513. onBeforeDraw: () => void;
  21514. /**
  21515. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21516. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21517. */
  21518. delayLoadState: number;
  21519. /**
  21520. * Gets the list of instances created from this mesh
  21521. * it is not supposed to be modified manually.
  21522. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21523. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21524. */
  21525. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21526. /**
  21527. * Gets the file containing delay loading data for this mesh
  21528. */
  21529. delayLoadingFile: string;
  21530. /** @hidden */
  21531. _binaryInfo: any;
  21532. private _LODLevels;
  21533. /**
  21534. * User defined function used to change how LOD level selection is done
  21535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21536. */
  21537. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21538. private _morphTargetManager;
  21539. /**
  21540. * Gets or sets the morph target manager
  21541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21542. */
  21543. morphTargetManager: Nullable<MorphTargetManager>;
  21544. /** @hidden */
  21545. _creationDataStorage: Nullable<_CreationDataStorage>;
  21546. /** @hidden */
  21547. _geometry: Nullable<Geometry>;
  21548. /** @hidden */
  21549. _delayInfo: Array<string>;
  21550. /** @hidden */
  21551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21552. /** @hidden */
  21553. _instanceDataStorage: _InstanceDataStorage;
  21554. private _effectiveMaterial;
  21555. /** @hidden */
  21556. _shouldGenerateFlatShading: boolean;
  21557. private _preActivateId;
  21558. /** @hidden */
  21559. _originalBuilderSideOrientation: number;
  21560. /**
  21561. * Use this property to change the original side orientation defined at construction time
  21562. */
  21563. overrideMaterialSideOrientation: Nullable<number>;
  21564. private _areNormalsFrozen;
  21565. private _sourcePositions;
  21566. private _sourceNormals;
  21567. private _source;
  21568. private meshMap;
  21569. /**
  21570. * Gets the source mesh (the one used to clone this one from)
  21571. */
  21572. readonly source: Nullable<Mesh>;
  21573. /**
  21574. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21575. */
  21576. isUnIndexed: boolean;
  21577. /**
  21578. * @constructor
  21579. * @param name The value used by scene.getMeshByName() to do a lookup.
  21580. * @param scene The scene to add this mesh to.
  21581. * @param parent The parent of this mesh, if it has one
  21582. * @param source An optional Mesh from which geometry is shared, cloned.
  21583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21584. * When false, achieved by calling a clone(), also passing False.
  21585. * This will make creation of children, recursive.
  21586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21587. */
  21588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21589. /**
  21590. * Gets the class name
  21591. * @returns the string "Mesh".
  21592. */
  21593. getClassName(): string;
  21594. /** @hidden */
  21595. readonly _isMesh: boolean;
  21596. /**
  21597. * Returns a description of this mesh
  21598. * @param fullDetails define if full details about this mesh must be used
  21599. * @returns a descriptive string representing this mesh
  21600. */
  21601. toString(fullDetails?: boolean): string;
  21602. /** @hidden */
  21603. _unBindEffect(): void;
  21604. /**
  21605. * Gets a boolean indicating if this mesh has LOD
  21606. */
  21607. readonly hasLODLevels: boolean;
  21608. /**
  21609. * Gets the list of MeshLODLevel associated with the current mesh
  21610. * @returns an array of MeshLODLevel
  21611. */
  21612. getLODLevels(): MeshLODLevel[];
  21613. private _sortLODLevels;
  21614. /**
  21615. * Add a mesh as LOD level triggered at the given distance.
  21616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21617. * @param distance The distance from the center of the object to show this level
  21618. * @param mesh The mesh to be added as LOD level (can be null)
  21619. * @return This mesh (for chaining)
  21620. */
  21621. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21622. /**
  21623. * Returns the LOD level mesh at the passed distance or null if not found.
  21624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21625. * @param distance The distance from the center of the object to show this level
  21626. * @returns a Mesh or `null`
  21627. */
  21628. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21629. /**
  21630. * Remove a mesh from the LOD array
  21631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21632. * @param mesh defines the mesh to be removed
  21633. * @return This mesh (for chaining)
  21634. */
  21635. removeLODLevel(mesh: Mesh): Mesh;
  21636. /**
  21637. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21638. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21639. * @param camera defines the camera to use to compute distance
  21640. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21641. * @return This mesh (for chaining)
  21642. */
  21643. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21644. /**
  21645. * Gets the mesh internal Geometry object
  21646. */
  21647. readonly geometry: Nullable<Geometry>;
  21648. /**
  21649. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21650. * @returns the total number of vertices
  21651. */
  21652. getTotalVertices(): number;
  21653. /**
  21654. * Returns the content of an associated vertex buffer
  21655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21656. * - VertexBuffer.PositionKind
  21657. * - VertexBuffer.UVKind
  21658. * - VertexBuffer.UV2Kind
  21659. * - VertexBuffer.UV3Kind
  21660. * - VertexBuffer.UV4Kind
  21661. * - VertexBuffer.UV5Kind
  21662. * - VertexBuffer.UV6Kind
  21663. * - VertexBuffer.ColorKind
  21664. * - VertexBuffer.MatricesIndicesKind
  21665. * - VertexBuffer.MatricesIndicesExtraKind
  21666. * - VertexBuffer.MatricesWeightsKind
  21667. * - VertexBuffer.MatricesWeightsExtraKind
  21668. * @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
  21669. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21670. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21671. */
  21672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21673. /**
  21674. * Returns the mesh VertexBuffer object from the requested `kind`
  21675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21676. * - VertexBuffer.PositionKind
  21677. * - VertexBuffer.UVKind
  21678. * - VertexBuffer.UV2Kind
  21679. * - VertexBuffer.UV3Kind
  21680. * - VertexBuffer.UV4Kind
  21681. * - VertexBuffer.UV5Kind
  21682. * - VertexBuffer.UV6Kind
  21683. * - VertexBuffer.ColorKind
  21684. * - VertexBuffer.MatricesIndicesKind
  21685. * - VertexBuffer.MatricesIndicesExtraKind
  21686. * - VertexBuffer.MatricesWeightsKind
  21687. * - VertexBuffer.MatricesWeightsExtraKind
  21688. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21689. */
  21690. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21691. /**
  21692. * Tests if a specific vertex buffer is associated with this mesh
  21693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21694. * - VertexBuffer.PositionKind
  21695. * - VertexBuffer.UVKind
  21696. * - VertexBuffer.UV2Kind
  21697. * - VertexBuffer.UV3Kind
  21698. * - VertexBuffer.UV4Kind
  21699. * - VertexBuffer.UV5Kind
  21700. * - VertexBuffer.UV6Kind
  21701. * - VertexBuffer.ColorKind
  21702. * - VertexBuffer.MatricesIndicesKind
  21703. * - VertexBuffer.MatricesIndicesExtraKind
  21704. * - VertexBuffer.MatricesWeightsKind
  21705. * - VertexBuffer.MatricesWeightsExtraKind
  21706. * @returns a boolean
  21707. */
  21708. isVerticesDataPresent(kind: string): boolean;
  21709. /**
  21710. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21711. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21712. * - VertexBuffer.PositionKind
  21713. * - VertexBuffer.UVKind
  21714. * - VertexBuffer.UV2Kind
  21715. * - VertexBuffer.UV3Kind
  21716. * - VertexBuffer.UV4Kind
  21717. * - VertexBuffer.UV5Kind
  21718. * - VertexBuffer.UV6Kind
  21719. * - VertexBuffer.ColorKind
  21720. * - VertexBuffer.MatricesIndicesKind
  21721. * - VertexBuffer.MatricesIndicesExtraKind
  21722. * - VertexBuffer.MatricesWeightsKind
  21723. * - VertexBuffer.MatricesWeightsExtraKind
  21724. * @returns a boolean
  21725. */
  21726. isVertexBufferUpdatable(kind: string): boolean;
  21727. /**
  21728. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21730. * - VertexBuffer.PositionKind
  21731. * - VertexBuffer.UVKind
  21732. * - VertexBuffer.UV2Kind
  21733. * - VertexBuffer.UV3Kind
  21734. * - VertexBuffer.UV4Kind
  21735. * - VertexBuffer.UV5Kind
  21736. * - VertexBuffer.UV6Kind
  21737. * - VertexBuffer.ColorKind
  21738. * - VertexBuffer.MatricesIndicesKind
  21739. * - VertexBuffer.MatricesIndicesExtraKind
  21740. * - VertexBuffer.MatricesWeightsKind
  21741. * - VertexBuffer.MatricesWeightsExtraKind
  21742. * @returns an array of strings
  21743. */
  21744. getVerticesDataKinds(): string[];
  21745. /**
  21746. * Returns a positive integer : the total number of indices in this mesh geometry.
  21747. * @returns the numner of indices or zero if the mesh has no geometry.
  21748. */
  21749. getTotalIndices(): number;
  21750. /**
  21751. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21752. * @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.
  21753. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21754. * @returns the indices array or an empty array if the mesh has no geometry
  21755. */
  21756. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21757. readonly isBlocked: boolean;
  21758. /**
  21759. * Determine if the current mesh is ready to be rendered
  21760. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21761. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21762. * @returns true if all associated assets are ready (material, textures, shaders)
  21763. */
  21764. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21765. /**
  21766. * 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.
  21767. */
  21768. readonly areNormalsFrozen: boolean;
  21769. /**
  21770. * 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.
  21771. * @returns the current mesh
  21772. */
  21773. freezeNormals(): Mesh;
  21774. /**
  21775. * 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
  21776. * @returns the current mesh
  21777. */
  21778. unfreezeNormals(): Mesh;
  21779. /**
  21780. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21781. */
  21782. overridenInstanceCount: number;
  21783. /** @hidden */
  21784. _preActivate(): Mesh;
  21785. /** @hidden */
  21786. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21787. /** @hidden */
  21788. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21789. /**
  21790. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21791. * This means the mesh underlying bounding box and sphere are recomputed.
  21792. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21793. * @returns the current mesh
  21794. */
  21795. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21796. /** @hidden */
  21797. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21798. /**
  21799. * This function will subdivide the mesh into multiple submeshes
  21800. * @param count defines the expected number of submeshes
  21801. */
  21802. subdivide(count: number): void;
  21803. /**
  21804. * Copy a FloatArray into a specific associated vertex buffer
  21805. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21806. * - VertexBuffer.PositionKind
  21807. * - VertexBuffer.UVKind
  21808. * - VertexBuffer.UV2Kind
  21809. * - VertexBuffer.UV3Kind
  21810. * - VertexBuffer.UV4Kind
  21811. * - VertexBuffer.UV5Kind
  21812. * - VertexBuffer.UV6Kind
  21813. * - VertexBuffer.ColorKind
  21814. * - VertexBuffer.MatricesIndicesKind
  21815. * - VertexBuffer.MatricesIndicesExtraKind
  21816. * - VertexBuffer.MatricesWeightsKind
  21817. * - VertexBuffer.MatricesWeightsExtraKind
  21818. * @param data defines the data source
  21819. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21820. * @param stride defines the data stride size (can be null)
  21821. * @returns the current mesh
  21822. */
  21823. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21824. /**
  21825. * Flags an associated vertex buffer as updatable
  21826. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21827. * - VertexBuffer.PositionKind
  21828. * - VertexBuffer.UVKind
  21829. * - VertexBuffer.UV2Kind
  21830. * - VertexBuffer.UV3Kind
  21831. * - VertexBuffer.UV4Kind
  21832. * - VertexBuffer.UV5Kind
  21833. * - VertexBuffer.UV6Kind
  21834. * - VertexBuffer.ColorKind
  21835. * - VertexBuffer.MatricesIndicesKind
  21836. * - VertexBuffer.MatricesIndicesExtraKind
  21837. * - VertexBuffer.MatricesWeightsKind
  21838. * - VertexBuffer.MatricesWeightsExtraKind
  21839. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21840. */
  21841. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21842. /**
  21843. * Sets the mesh global Vertex Buffer
  21844. * @param buffer defines the buffer to use
  21845. * @returns the current mesh
  21846. */
  21847. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21848. /**
  21849. * Update a specific associated vertex buffer
  21850. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21851. * - VertexBuffer.PositionKind
  21852. * - VertexBuffer.UVKind
  21853. * - VertexBuffer.UV2Kind
  21854. * - VertexBuffer.UV3Kind
  21855. * - VertexBuffer.UV4Kind
  21856. * - VertexBuffer.UV5Kind
  21857. * - VertexBuffer.UV6Kind
  21858. * - VertexBuffer.ColorKind
  21859. * - VertexBuffer.MatricesIndicesKind
  21860. * - VertexBuffer.MatricesIndicesExtraKind
  21861. * - VertexBuffer.MatricesWeightsKind
  21862. * - VertexBuffer.MatricesWeightsExtraKind
  21863. * @param data defines the data source
  21864. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21865. * @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)
  21866. * @returns the current mesh
  21867. */
  21868. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21869. /**
  21870. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21871. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21872. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21873. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21874. * @returns the current mesh
  21875. */
  21876. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21877. /**
  21878. * Creates a un-shared specific occurence of the geometry for the mesh.
  21879. * @returns the current mesh
  21880. */
  21881. makeGeometryUnique(): Mesh;
  21882. /**
  21883. * Set the index buffer of this mesh
  21884. * @param indices defines the source data
  21885. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21886. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21887. * @returns the current mesh
  21888. */
  21889. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21890. /**
  21891. * Update the current index buffer
  21892. * @param indices defines the source data
  21893. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21894. * @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)
  21895. * @returns the current mesh
  21896. */
  21897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21898. /**
  21899. * Invert the geometry to move from a right handed system to a left handed one.
  21900. * @returns the current mesh
  21901. */
  21902. toLeftHanded(): Mesh;
  21903. /** @hidden */
  21904. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21905. /** @hidden */
  21906. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21907. /**
  21908. * Registers for this mesh a javascript function called just before the rendering process
  21909. * @param func defines the function to call before rendering this mesh
  21910. * @returns the current mesh
  21911. */
  21912. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21913. /**
  21914. * Disposes a previously registered javascript function called before the rendering
  21915. * @param func defines the function to remove
  21916. * @returns the current mesh
  21917. */
  21918. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21919. /**
  21920. * Registers for this mesh a javascript function called just after the rendering is complete
  21921. * @param func defines the function to call after rendering this mesh
  21922. * @returns the current mesh
  21923. */
  21924. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21925. /**
  21926. * Disposes a previously registered javascript function called after the rendering.
  21927. * @param func defines the function to remove
  21928. * @returns the current mesh
  21929. */
  21930. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21931. /** @hidden */
  21932. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21933. /** @hidden */
  21934. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21935. /** @hidden */
  21936. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21937. /** @hidden */
  21938. _freeze(): void;
  21939. /** @hidden */
  21940. _unFreeze(): void;
  21941. /**
  21942. * 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
  21943. * @param subMesh defines the subMesh to render
  21944. * @param enableAlphaMode defines if alpha mode can be changed
  21945. * @returns the current mesh
  21946. */
  21947. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21948. private _onBeforeDraw;
  21949. /**
  21950. * Renormalize the mesh and patch it up if there are no weights
  21951. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21952. * However in the case of zero weights then we set just a single influence to 1.
  21953. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21954. */
  21955. cleanMatrixWeights(): void;
  21956. private normalizeSkinFourWeights;
  21957. private normalizeSkinWeightsAndExtra;
  21958. /**
  21959. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21960. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21961. * the user know there was an issue with importing the mesh
  21962. * @returns a validation object with skinned, valid and report string
  21963. */
  21964. validateSkinning(): {
  21965. skinned: boolean;
  21966. valid: boolean;
  21967. report: string;
  21968. };
  21969. /** @hidden */
  21970. _checkDelayState(): Mesh;
  21971. private _queueLoad;
  21972. /**
  21973. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21974. * A mesh is in the frustum if its bounding box intersects the frustum
  21975. * @param frustumPlanes defines the frustum to test
  21976. * @returns true if the mesh is in the frustum planes
  21977. */
  21978. isInFrustum(frustumPlanes: Plane[]): boolean;
  21979. /**
  21980. * Sets the mesh material by the material or multiMaterial `id` property
  21981. * @param id is a string identifying the material or the multiMaterial
  21982. * @returns the current mesh
  21983. */
  21984. setMaterialByID(id: string): Mesh;
  21985. /**
  21986. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21987. * @returns an array of IAnimatable
  21988. */
  21989. getAnimatables(): IAnimatable[];
  21990. /**
  21991. * Modifies the mesh geometry according to the passed transformation matrix.
  21992. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21993. * The mesh normals are modified using the same transformation.
  21994. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21995. * @param transform defines the transform matrix to use
  21996. * @see http://doc.babylonjs.com/resources/baking_transformations
  21997. * @returns the current mesh
  21998. */
  21999. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22000. /**
  22001. * Modifies the mesh geometry according to its own current World Matrix.
  22002. * The mesh World Matrix is then reset.
  22003. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22005. * @see http://doc.babylonjs.com/resources/baking_transformations
  22006. * @returns the current mesh
  22007. */
  22008. bakeCurrentTransformIntoVertices(): Mesh;
  22009. /** @hidden */
  22010. readonly _positions: Nullable<Vector3[]>;
  22011. /** @hidden */
  22012. _resetPointsArrayCache(): Mesh;
  22013. /** @hidden */
  22014. _generatePointsArray(): boolean;
  22015. /**
  22016. * Returns a new Mesh object generated from the current mesh properties.
  22017. * This method must not get confused with createInstance()
  22018. * @param name is a string, the name given to the new mesh
  22019. * @param newParent can be any Node object (default `null`)
  22020. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22021. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22022. * @returns a new mesh
  22023. */
  22024. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22025. /**
  22026. * Releases resources associated with this mesh.
  22027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22029. */
  22030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22031. /**
  22032. * Modifies the mesh geometry according to a displacement map.
  22033. * 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.
  22034. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22035. * @param url is a string, the URL from the image file is to be downloaded.
  22036. * @param minHeight is the lower limit of the displacement.
  22037. * @param maxHeight is the upper limit of the displacement.
  22038. * @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.
  22039. * @param uvOffset is an optional vector2 used to offset UV.
  22040. * @param uvScale is an optional vector2 used to scale UV.
  22041. * @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.
  22042. * @returns the Mesh.
  22043. */
  22044. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22045. /**
  22046. * Modifies the mesh geometry according to a displacementMap buffer.
  22047. * 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.
  22048. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22049. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22050. * @param heightMapWidth is the width of the buffer image.
  22051. * @param heightMapHeight is the height of the buffer image.
  22052. * @param minHeight is the lower limit of the displacement.
  22053. * @param maxHeight is the upper limit of the displacement.
  22054. * @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.
  22055. * @param uvOffset is an optional vector2 used to offset UV.
  22056. * @param uvScale is an optional vector2 used to scale UV.
  22057. * @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.
  22058. * @returns the Mesh.
  22059. */
  22060. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22061. /**
  22062. * Modify the mesh to get a flat shading rendering.
  22063. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22064. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22065. * @returns current mesh
  22066. */
  22067. convertToFlatShadedMesh(): Mesh;
  22068. /**
  22069. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22070. * In other words, more vertices, no more indices and a single bigger VBO.
  22071. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22072. * @returns current mesh
  22073. */
  22074. convertToUnIndexedMesh(): Mesh;
  22075. /**
  22076. * Inverses facet orientations.
  22077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22078. * @param flipNormals will also inverts the normals
  22079. * @returns current mesh
  22080. */
  22081. flipFaces(flipNormals?: boolean): Mesh;
  22082. /**
  22083. * Increase the number of facets and hence vertices in a mesh
  22084. * Vertex normals are interpolated from existing vertex normals
  22085. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22086. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22087. */
  22088. increaseVertices(numberPerEdge: number): void;
  22089. /**
  22090. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22091. * This will undo any application of covertToFlatShadedMesh
  22092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22093. */
  22094. forceSharedVertices(): void;
  22095. /** @hidden */
  22096. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22097. /** @hidden */
  22098. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22099. /**
  22100. * Creates a new InstancedMesh object from the mesh model.
  22101. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22102. * @param name defines the name of the new instance
  22103. * @returns a new InstancedMesh
  22104. */
  22105. createInstance(name: string): InstancedMesh;
  22106. /**
  22107. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22108. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22109. * @returns the current mesh
  22110. */
  22111. synchronizeInstances(): Mesh;
  22112. /**
  22113. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22114. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22115. * This should be used together with the simplification to avoid disappearing triangles.
  22116. * @param successCallback an optional success callback to be called after the optimization finished.
  22117. * @returns the current mesh
  22118. */
  22119. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22120. /**
  22121. * Serialize current mesh
  22122. * @param serializationObject defines the object which will receive the serialization data
  22123. */
  22124. serialize(serializationObject: any): void;
  22125. /** @hidden */
  22126. _syncGeometryWithMorphTargetManager(): void;
  22127. /** @hidden */
  22128. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22129. /**
  22130. * Returns a new Mesh object parsed from the source provided.
  22131. * @param parsedMesh is the source
  22132. * @param scene defines the hosting scene
  22133. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22134. * @returns a new Mesh
  22135. */
  22136. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22137. /**
  22138. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22139. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22140. * @param name defines the name of the mesh to create
  22141. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22142. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22143. * @param closePath creates a seam between the first and the last points of each path of the path array
  22144. * @param offset is taken in account only if the `pathArray` is containing a single path
  22145. * @param scene defines the hosting scene
  22146. * @param updatable defines if the mesh must be flagged as updatable
  22147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22148. * @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)
  22149. * @returns a new Mesh
  22150. */
  22151. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22152. /**
  22153. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22154. * @param name defines the name of the mesh to create
  22155. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22156. * @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
  22157. * @param scene defines the hosting scene
  22158. * @param updatable defines if the mesh must be flagged as updatable
  22159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22160. * @returns a new Mesh
  22161. */
  22162. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22163. /**
  22164. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22165. * @param name defines the name of the mesh to create
  22166. * @param size sets the size (float) of each box side (default 1)
  22167. * @param scene defines the hosting scene
  22168. * @param updatable defines if the mesh must be flagged as updatable
  22169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22173. /**
  22174. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22175. * @param name defines the name of the mesh to create
  22176. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22177. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22178. * @param scene defines the hosting scene
  22179. * @param updatable defines if the mesh must be flagged as updatable
  22180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22181. * @returns a new Mesh
  22182. */
  22183. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22184. /**
  22185. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22186. * @param name defines the name of the mesh to create
  22187. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22188. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22189. * @param scene defines the hosting scene
  22190. * @returns a new Mesh
  22191. */
  22192. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22193. /**
  22194. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22195. * @param name defines the name of the mesh to create
  22196. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22197. * @param diameterTop set the top cap diameter (floats, default 1)
  22198. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22199. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22200. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22201. * @param scene defines the hosting scene
  22202. * @param updatable defines if the mesh must be flagged as updatable
  22203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22204. * @returns a new Mesh
  22205. */
  22206. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22207. /**
  22208. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22209. * @param name defines the name of the mesh to create
  22210. * @param diameter sets the diameter size (float) of the torus (default 1)
  22211. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22212. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22213. * @param scene defines the hosting scene
  22214. * @param updatable defines if the mesh must be flagged as updatable
  22215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22216. * @returns a new Mesh
  22217. */
  22218. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22219. /**
  22220. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22221. * @param name defines the name of the mesh to create
  22222. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22223. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22224. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22225. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22226. * @param p the number of windings on X axis (positive integers, default 2)
  22227. * @param q the number of windings on Y axis (positive integers, default 3)
  22228. * @param scene defines the hosting scene
  22229. * @param updatable defines if the mesh must be flagged as updatable
  22230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22231. * @returns a new Mesh
  22232. */
  22233. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22234. /**
  22235. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22236. * @param name defines the name of the mesh to create
  22237. * @param points is an array successive Vector3
  22238. * @param scene defines the hosting scene
  22239. * @param updatable defines if the mesh must be flagged as updatable
  22240. * @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).
  22241. * @returns a new Mesh
  22242. */
  22243. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22244. /**
  22245. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22246. * @param name defines the name of the mesh to create
  22247. * @param points is an array successive Vector3
  22248. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22249. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22250. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22251. * @param scene defines the hosting scene
  22252. * @param updatable defines if the mesh must be flagged as updatable
  22253. * @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)
  22254. * @returns a new Mesh
  22255. */
  22256. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22257. /**
  22258. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22259. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22260. * 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.
  22261. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22262. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22263. * Remember you can only change the shape positions, not their number when updating a polygon.
  22264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22265. * @param name defines the name of the mesh to create
  22266. * @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
  22267. * @param scene defines the hosting scene
  22268. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22269. * @param updatable defines if the mesh must be flagged as updatable
  22270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22271. * @param earcutInjection can be used to inject your own earcut reference
  22272. * @returns a new Mesh
  22273. */
  22274. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22275. /**
  22276. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22278. * @param name defines the name of the mesh to create
  22279. * @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
  22280. * @param depth defines the height of extrusion
  22281. * @param scene defines the hosting scene
  22282. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22283. * @param updatable defines if the mesh must be flagged as updatable
  22284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22285. * @param earcutInjection can be used to inject your own earcut reference
  22286. * @returns a new Mesh
  22287. */
  22288. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22289. /**
  22290. * Creates an extruded shape mesh.
  22291. * 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
  22292. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22293. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22294. * @param name defines the name of the mesh to create
  22295. * @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
  22296. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22297. * @param scale is the value to scale the shape
  22298. * @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
  22299. * @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
  22300. * @param scene defines the hosting scene
  22301. * @param updatable defines if the mesh must be flagged as updatable
  22302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22303. * @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)
  22304. * @returns a new Mesh
  22305. */
  22306. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22307. /**
  22308. * Creates an custom extruded shape mesh.
  22309. * The custom extrusion is a parametric shape.
  22310. * It has no predefined shape. Its final shape will depend on the input parameters.
  22311. * Please consider using the same method from the MeshBuilder class instead
  22312. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22313. * @param name defines the name of the mesh to create
  22314. * @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
  22315. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22316. * @param scaleFunction is a custom Javascript function called on each path point
  22317. * @param rotationFunction is a custom Javascript function called on each path point
  22318. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22319. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22320. * @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
  22321. * @param scene defines the hosting scene
  22322. * @param updatable defines if the mesh must be flagged as updatable
  22323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22324. * @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)
  22325. * @returns a new Mesh
  22326. */
  22327. 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;
  22328. /**
  22329. * Creates lathe mesh.
  22330. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22331. * Please consider using the same method from the MeshBuilder class instead
  22332. * @param name defines the name of the mesh to create
  22333. * @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
  22334. * @param radius is the radius value of the lathe
  22335. * @param tessellation is the side number of the lathe.
  22336. * @param scene defines the hosting scene
  22337. * @param updatable defines if the mesh must be flagged as updatable
  22338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22339. * @returns a new Mesh
  22340. */
  22341. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22342. /**
  22343. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22344. * @param name defines the name of the mesh to create
  22345. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22346. * @param scene defines the hosting scene
  22347. * @param updatable defines if the mesh must be flagged as updatable
  22348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22349. * @returns a new Mesh
  22350. */
  22351. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22352. /**
  22353. * Creates a ground mesh.
  22354. * Please consider using the same method from the MeshBuilder class instead
  22355. * @param name defines the name of the mesh to create
  22356. * @param width set the width of the ground
  22357. * @param height set the height of the ground
  22358. * @param subdivisions sets the number of subdivisions per side
  22359. * @param scene defines the hosting scene
  22360. * @param updatable defines if the mesh must be flagged as updatable
  22361. * @returns a new Mesh
  22362. */
  22363. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22364. /**
  22365. * Creates a tiled ground mesh.
  22366. * Please consider using the same method from the MeshBuilder class instead
  22367. * @param name defines the name of the mesh to create
  22368. * @param xmin set the ground minimum X coordinate
  22369. * @param zmin set the ground minimum Y coordinate
  22370. * @param xmax set the ground maximum X coordinate
  22371. * @param zmax set the ground maximum Z coordinate
  22372. * @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
  22373. * @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
  22374. * @param scene defines the hosting scene
  22375. * @param updatable defines if the mesh must be flagged as updatable
  22376. * @returns a new Mesh
  22377. */
  22378. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22379. w: number;
  22380. h: number;
  22381. }, precision: {
  22382. w: number;
  22383. h: number;
  22384. }, scene: Scene, updatable?: boolean): Mesh;
  22385. /**
  22386. * Creates a ground mesh from a height map.
  22387. * Please consider using the same method from the MeshBuilder class instead
  22388. * @see http://doc.babylonjs.com/babylon101/height_map
  22389. * @param name defines the name of the mesh to create
  22390. * @param url sets the URL of the height map image resource
  22391. * @param width set the ground width size
  22392. * @param height set the ground height size
  22393. * @param subdivisions sets the number of subdivision per side
  22394. * @param minHeight is the minimum altitude on the ground
  22395. * @param maxHeight is the maximum altitude on the ground
  22396. * @param scene defines the hosting scene
  22397. * @param updatable defines if the mesh must be flagged as updatable
  22398. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22399. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22400. * @returns a new Mesh
  22401. */
  22402. 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;
  22403. /**
  22404. * Creates a tube mesh.
  22405. * The tube is a parametric shape.
  22406. * It has no predefined shape. Its final shape will depend on the input parameters.
  22407. * Please consider using the same method from the MeshBuilder class instead
  22408. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22409. * @param name defines the name of the mesh to create
  22410. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22411. * @param radius sets the tube radius size
  22412. * @param tessellation is the number of sides on the tubular surface
  22413. * @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
  22414. * @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
  22415. * @param scene defines the hosting scene
  22416. * @param updatable defines if the mesh must be flagged as updatable
  22417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22418. * @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)
  22419. * @returns a new Mesh
  22420. */
  22421. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22422. (i: number, distance: number): number;
  22423. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22424. /**
  22425. * Creates a polyhedron mesh.
  22426. * Please consider using the same method from the MeshBuilder class instead.
  22427. * * 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
  22428. * * The parameter `size` (positive float, default 1) sets the polygon size
  22429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22430. * * 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`
  22431. * * 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
  22432. * * 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)`)
  22433. * * 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
  22434. * * 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
  22435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22436. * * If you create a double-sided mesh, you can choose what parts of 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
  22437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22438. * @param name defines the name of the mesh to create
  22439. * @param options defines the options used to create the mesh
  22440. * @param scene defines the hosting scene
  22441. * @returns a new Mesh
  22442. */
  22443. static CreatePolyhedron(name: string, options: {
  22444. type?: number;
  22445. size?: number;
  22446. sizeX?: number;
  22447. sizeY?: number;
  22448. sizeZ?: number;
  22449. custom?: any;
  22450. faceUV?: Vector4[];
  22451. faceColors?: Color4[];
  22452. updatable?: boolean;
  22453. sideOrientation?: number;
  22454. }, scene: Scene): Mesh;
  22455. /**
  22456. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22457. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22458. * * 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`)
  22459. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22460. * * 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
  22461. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22462. * * If you create a double-sided mesh, you can choose what parts of 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
  22463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22464. * @param name defines the name of the mesh
  22465. * @param options defines the options used to create the mesh
  22466. * @param scene defines the hosting scene
  22467. * @returns a new Mesh
  22468. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22469. */
  22470. static CreateIcoSphere(name: string, options: {
  22471. radius?: number;
  22472. flat?: boolean;
  22473. subdivisions?: number;
  22474. sideOrientation?: number;
  22475. updatable?: boolean;
  22476. }, scene: Scene): Mesh;
  22477. /**
  22478. * Creates a decal mesh.
  22479. * Please consider using the same method from the MeshBuilder class instead.
  22480. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22481. * @param name defines the name of the mesh
  22482. * @param sourceMesh defines the mesh receiving the decal
  22483. * @param position sets the position of the decal in world coordinates
  22484. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22485. * @param size sets the decal scaling
  22486. * @param angle sets the angle to rotate the decal
  22487. * @returns a new Mesh
  22488. */
  22489. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22490. /**
  22491. * Prepare internal position array for software CPU skinning
  22492. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22493. */
  22494. setPositionsForCPUSkinning(): Float32Array;
  22495. /**
  22496. * Prepare internal normal array for software CPU skinning
  22497. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22498. */
  22499. setNormalsForCPUSkinning(): Float32Array;
  22500. /**
  22501. * Updates the vertex buffer by applying transformation from the bones
  22502. * @param skeleton defines the skeleton to apply to current mesh
  22503. * @returns the current mesh
  22504. */
  22505. applySkeleton(skeleton: Skeleton): Mesh;
  22506. /**
  22507. * 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
  22508. * @param meshes defines the list of meshes to scan
  22509. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22510. */
  22511. static MinMax(meshes: AbstractMesh[]): {
  22512. min: Vector3;
  22513. max: Vector3;
  22514. };
  22515. /**
  22516. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22517. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22518. * @returns a vector3
  22519. */
  22520. static Center(meshesOrMinMaxVector: {
  22521. min: Vector3;
  22522. max: Vector3;
  22523. } | AbstractMesh[]): Vector3;
  22524. /**
  22525. * Merge the array of meshes into a single mesh for performance reasons.
  22526. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22527. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22528. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22529. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22530. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22531. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22532. * @returns a new mesh
  22533. */
  22534. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22535. /** @hidden */
  22536. addInstance(instance: InstancedMesh): void;
  22537. /** @hidden */
  22538. removeInstance(instance: InstancedMesh): void;
  22539. }
  22540. }
  22541. declare module "babylonjs/Materials/material" {
  22542. import { IAnimatable } from "babylonjs/Misc/tools";
  22543. import { SmartArray } from "babylonjs/Misc/smartArray";
  22544. import { Observable } from "babylonjs/Misc/observable";
  22545. import { Nullable } from "babylonjs/types";
  22546. import { Scene } from "babylonjs/scene";
  22547. import { Matrix } from "babylonjs/Maths/math";
  22548. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22550. import { Mesh } from "babylonjs/Meshes/mesh";
  22551. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22552. import { Effect } from "babylonjs/Materials/effect";
  22553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22554. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22555. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22556. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22557. import { Animation } from "babylonjs/Animations/animation";
  22558. /**
  22559. * Base class for the main features of a material in Babylon.js
  22560. */
  22561. export class Material implements IAnimatable {
  22562. /**
  22563. * Returns the triangle fill mode
  22564. */
  22565. static readonly TriangleFillMode: number;
  22566. /**
  22567. * Returns the wireframe mode
  22568. */
  22569. static readonly WireFrameFillMode: number;
  22570. /**
  22571. * Returns the point fill mode
  22572. */
  22573. static readonly PointFillMode: number;
  22574. /**
  22575. * Returns the point list draw mode
  22576. */
  22577. static readonly PointListDrawMode: number;
  22578. /**
  22579. * Returns the line list draw mode
  22580. */
  22581. static readonly LineListDrawMode: number;
  22582. /**
  22583. * Returns the line loop draw mode
  22584. */
  22585. static readonly LineLoopDrawMode: number;
  22586. /**
  22587. * Returns the line strip draw mode
  22588. */
  22589. static readonly LineStripDrawMode: number;
  22590. /**
  22591. * Returns the triangle strip draw mode
  22592. */
  22593. static readonly TriangleStripDrawMode: number;
  22594. /**
  22595. * Returns the triangle fan draw mode
  22596. */
  22597. static readonly TriangleFanDrawMode: number;
  22598. /**
  22599. * Stores the clock-wise side orientation
  22600. */
  22601. static readonly ClockWiseSideOrientation: number;
  22602. /**
  22603. * Stores the counter clock-wise side orientation
  22604. */
  22605. static readonly CounterClockWiseSideOrientation: number;
  22606. /**
  22607. * The dirty texture flag value
  22608. */
  22609. static readonly TextureDirtyFlag: number;
  22610. /**
  22611. * The dirty light flag value
  22612. */
  22613. static readonly LightDirtyFlag: number;
  22614. /**
  22615. * The dirty fresnel flag value
  22616. */
  22617. static readonly FresnelDirtyFlag: number;
  22618. /**
  22619. * The dirty attribute flag value
  22620. */
  22621. static readonly AttributesDirtyFlag: number;
  22622. /**
  22623. * The dirty misc flag value
  22624. */
  22625. static readonly MiscDirtyFlag: number;
  22626. /**
  22627. * The all dirty flag value
  22628. */
  22629. static readonly AllDirtyFlag: number;
  22630. /**
  22631. * The ID of the material
  22632. */
  22633. id: string;
  22634. /**
  22635. * Gets or sets the unique id of the material
  22636. */
  22637. uniqueId: number;
  22638. /**
  22639. * The name of the material
  22640. */
  22641. name: string;
  22642. /**
  22643. * Gets or sets user defined metadata
  22644. */
  22645. metadata: any;
  22646. /**
  22647. * For internal use only. Please do not use.
  22648. */
  22649. reservedDataStore: any;
  22650. /**
  22651. * Specifies if the ready state should be checked on each call
  22652. */
  22653. checkReadyOnEveryCall: boolean;
  22654. /**
  22655. * Specifies if the ready state should be checked once
  22656. */
  22657. checkReadyOnlyOnce: boolean;
  22658. /**
  22659. * The state of the material
  22660. */
  22661. state: string;
  22662. /**
  22663. * The alpha value of the material
  22664. */
  22665. protected _alpha: number;
  22666. /**
  22667. * List of inspectable custom properties (used by the Inspector)
  22668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22669. */
  22670. inspectableCustomProperties: IInspectable[];
  22671. /**
  22672. * Sets the alpha value of the material
  22673. */
  22674. /**
  22675. * Gets the alpha value of the material
  22676. */
  22677. alpha: number;
  22678. /**
  22679. * Specifies if back face culling is enabled
  22680. */
  22681. protected _backFaceCulling: boolean;
  22682. /**
  22683. * Sets the back-face culling state
  22684. */
  22685. /**
  22686. * Gets the back-face culling state
  22687. */
  22688. backFaceCulling: boolean;
  22689. /**
  22690. * Stores the value for side orientation
  22691. */
  22692. sideOrientation: number;
  22693. /**
  22694. * Callback triggered when the material is compiled
  22695. */
  22696. onCompiled: Nullable<(effect: Effect) => void>;
  22697. /**
  22698. * Callback triggered when an error occurs
  22699. */
  22700. onError: Nullable<(effect: Effect, errors: string) => void>;
  22701. /**
  22702. * Callback triggered to get the render target textures
  22703. */
  22704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22705. /**
  22706. * Gets a boolean indicating that current material needs to register RTT
  22707. */
  22708. readonly hasRenderTargetTextures: boolean;
  22709. /**
  22710. * Specifies if the material should be serialized
  22711. */
  22712. doNotSerialize: boolean;
  22713. /**
  22714. * @hidden
  22715. */
  22716. _storeEffectOnSubMeshes: boolean;
  22717. /**
  22718. * Stores the animations for the material
  22719. */
  22720. animations: Nullable<Array<Animation>>;
  22721. /**
  22722. * An event triggered when the material is disposed
  22723. */
  22724. onDisposeObservable: Observable<Material>;
  22725. /**
  22726. * An observer which watches for dispose events
  22727. */
  22728. private _onDisposeObserver;
  22729. private _onUnBindObservable;
  22730. /**
  22731. * Called during a dispose event
  22732. */
  22733. onDispose: () => void;
  22734. private _onBindObservable;
  22735. /**
  22736. * An event triggered when the material is bound
  22737. */
  22738. readonly onBindObservable: Observable<AbstractMesh>;
  22739. /**
  22740. * An observer which watches for bind events
  22741. */
  22742. private _onBindObserver;
  22743. /**
  22744. * Called during a bind event
  22745. */
  22746. onBind: (Mesh: AbstractMesh) => void;
  22747. /**
  22748. * An event triggered when the material is unbound
  22749. */
  22750. readonly onUnBindObservable: Observable<Material>;
  22751. /**
  22752. * Stores the value of the alpha mode
  22753. */
  22754. private _alphaMode;
  22755. /**
  22756. * Sets the value of the alpha mode.
  22757. *
  22758. * | Value | Type | Description |
  22759. * | --- | --- | --- |
  22760. * | 0 | ALPHA_DISABLE | |
  22761. * | 1 | ALPHA_ADD | |
  22762. * | 2 | ALPHA_COMBINE | |
  22763. * | 3 | ALPHA_SUBTRACT | |
  22764. * | 4 | ALPHA_MULTIPLY | |
  22765. * | 5 | ALPHA_MAXIMIZED | |
  22766. * | 6 | ALPHA_ONEONE | |
  22767. * | 7 | ALPHA_PREMULTIPLIED | |
  22768. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22769. * | 9 | ALPHA_INTERPOLATE | |
  22770. * | 10 | ALPHA_SCREENMODE | |
  22771. *
  22772. */
  22773. /**
  22774. * Gets the value of the alpha mode
  22775. */
  22776. alphaMode: number;
  22777. /**
  22778. * Stores the state of the need depth pre-pass value
  22779. */
  22780. private _needDepthPrePass;
  22781. /**
  22782. * Sets the need depth pre-pass value
  22783. */
  22784. /**
  22785. * Gets the depth pre-pass value
  22786. */
  22787. needDepthPrePass: boolean;
  22788. /**
  22789. * Specifies if depth writing should be disabled
  22790. */
  22791. disableDepthWrite: boolean;
  22792. /**
  22793. * Specifies if depth writing should be forced
  22794. */
  22795. forceDepthWrite: boolean;
  22796. /**
  22797. * Specifies if there should be a separate pass for culling
  22798. */
  22799. separateCullingPass: boolean;
  22800. /**
  22801. * Stores the state specifing if fog should be enabled
  22802. */
  22803. private _fogEnabled;
  22804. /**
  22805. * Sets the state for enabling fog
  22806. */
  22807. /**
  22808. * Gets the value of the fog enabled state
  22809. */
  22810. fogEnabled: boolean;
  22811. /**
  22812. * Stores the size of points
  22813. */
  22814. pointSize: number;
  22815. /**
  22816. * Stores the z offset value
  22817. */
  22818. zOffset: number;
  22819. /**
  22820. * Gets a value specifying if wireframe mode is enabled
  22821. */
  22822. /**
  22823. * Sets the state of wireframe mode
  22824. */
  22825. wireframe: boolean;
  22826. /**
  22827. * Gets the value specifying if point clouds are enabled
  22828. */
  22829. /**
  22830. * Sets the state of point cloud mode
  22831. */
  22832. pointsCloud: boolean;
  22833. /**
  22834. * Gets the material fill mode
  22835. */
  22836. /**
  22837. * Sets the material fill mode
  22838. */
  22839. fillMode: number;
  22840. /**
  22841. * @hidden
  22842. * Stores the effects for the material
  22843. */
  22844. _effect: Nullable<Effect>;
  22845. /**
  22846. * @hidden
  22847. * Specifies if the material was previously ready
  22848. */
  22849. _wasPreviouslyReady: boolean;
  22850. /**
  22851. * Specifies if uniform buffers should be used
  22852. */
  22853. private _useUBO;
  22854. /**
  22855. * Stores a reference to the scene
  22856. */
  22857. private _scene;
  22858. /**
  22859. * Stores the fill mode state
  22860. */
  22861. private _fillMode;
  22862. /**
  22863. * Specifies if the depth write state should be cached
  22864. */
  22865. private _cachedDepthWriteState;
  22866. /**
  22867. * Stores the uniform buffer
  22868. */
  22869. protected _uniformBuffer: UniformBuffer;
  22870. /** @hidden */
  22871. _indexInSceneMaterialArray: number;
  22872. /** @hidden */
  22873. meshMap: Nullable<{
  22874. [id: string]: AbstractMesh | undefined;
  22875. }>;
  22876. /**
  22877. * Creates a material instance
  22878. * @param name defines the name of the material
  22879. * @param scene defines the scene to reference
  22880. * @param doNotAdd specifies if the material should be added to the scene
  22881. */
  22882. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22883. /**
  22884. * Returns a string representation of the current material
  22885. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22886. * @returns a string with material information
  22887. */
  22888. toString(fullDetails?: boolean): string;
  22889. /**
  22890. * Gets the class name of the material
  22891. * @returns a string with the class name of the material
  22892. */
  22893. getClassName(): string;
  22894. /**
  22895. * Specifies if updates for the material been locked
  22896. */
  22897. readonly isFrozen: boolean;
  22898. /**
  22899. * Locks updates for the material
  22900. */
  22901. freeze(): void;
  22902. /**
  22903. * Unlocks updates for the material
  22904. */
  22905. unfreeze(): void;
  22906. /**
  22907. * Specifies if the material is ready to be used
  22908. * @param mesh defines the mesh to check
  22909. * @param useInstances specifies if instances should be used
  22910. * @returns a boolean indicating if the material is ready to be used
  22911. */
  22912. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22913. /**
  22914. * Specifies that the submesh is ready to be used
  22915. * @param mesh defines the mesh to check
  22916. * @param subMesh defines which submesh to check
  22917. * @param useInstances specifies that instances should be used
  22918. * @returns a boolean indicating that the submesh is ready or not
  22919. */
  22920. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22921. /**
  22922. * Returns the material effect
  22923. * @returns the effect associated with the material
  22924. */
  22925. getEffect(): Nullable<Effect>;
  22926. /**
  22927. * Returns the current scene
  22928. * @returns a Scene
  22929. */
  22930. getScene(): Scene;
  22931. /**
  22932. * Specifies if the material will require alpha blending
  22933. * @returns a boolean specifying if alpha blending is needed
  22934. */
  22935. needAlphaBlending(): boolean;
  22936. /**
  22937. * Specifies if the mesh will require alpha blending
  22938. * @param mesh defines the mesh to check
  22939. * @returns a boolean specifying if alpha blending is needed for the mesh
  22940. */
  22941. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22942. /**
  22943. * Specifies if this material should be rendered in alpha test mode
  22944. * @returns a boolean specifying if an alpha test is needed.
  22945. */
  22946. needAlphaTesting(): boolean;
  22947. /**
  22948. * Gets the texture used for the alpha test
  22949. * @returns the texture to use for alpha testing
  22950. */
  22951. getAlphaTestTexture(): Nullable<BaseTexture>;
  22952. /**
  22953. * Marks the material to indicate that it needs to be re-calculated
  22954. */
  22955. markDirty(): void;
  22956. /** @hidden */
  22957. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22958. /**
  22959. * Binds the material to the mesh
  22960. * @param world defines the world transformation matrix
  22961. * @param mesh defines the mesh to bind the material to
  22962. */
  22963. bind(world: Matrix, mesh?: Mesh): void;
  22964. /**
  22965. * Binds the submesh to the material
  22966. * @param world defines the world transformation matrix
  22967. * @param mesh defines the mesh containing the submesh
  22968. * @param subMesh defines the submesh to bind the material to
  22969. */
  22970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22971. /**
  22972. * Binds the world matrix to the material
  22973. * @param world defines the world transformation matrix
  22974. */
  22975. bindOnlyWorldMatrix(world: Matrix): void;
  22976. /**
  22977. * Binds the scene's uniform buffer to the effect.
  22978. * @param effect defines the effect to bind to the scene uniform buffer
  22979. * @param sceneUbo defines the uniform buffer storing scene data
  22980. */
  22981. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22982. /**
  22983. * Binds the view matrix to the effect
  22984. * @param effect defines the effect to bind the view matrix to
  22985. */
  22986. bindView(effect: Effect): void;
  22987. /**
  22988. * Binds the view projection matrix to the effect
  22989. * @param effect defines the effect to bind the view projection matrix to
  22990. */
  22991. bindViewProjection(effect: Effect): void;
  22992. /**
  22993. * Specifies if material alpha testing should be turned on for the mesh
  22994. * @param mesh defines the mesh to check
  22995. */
  22996. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22997. /**
  22998. * Processes to execute after binding the material to a mesh
  22999. * @param mesh defines the rendered mesh
  23000. */
  23001. protected _afterBind(mesh?: Mesh): void;
  23002. /**
  23003. * Unbinds the material from the mesh
  23004. */
  23005. unbind(): void;
  23006. /**
  23007. * Gets the active textures from the material
  23008. * @returns an array of textures
  23009. */
  23010. getActiveTextures(): BaseTexture[];
  23011. /**
  23012. * Specifies if the material uses a texture
  23013. * @param texture defines the texture to check against the material
  23014. * @returns a boolean specifying if the material uses the texture
  23015. */
  23016. hasTexture(texture: BaseTexture): boolean;
  23017. /**
  23018. * Makes a duplicate of the material, and gives it a new name
  23019. * @param name defines the new name for the duplicated material
  23020. * @returns the cloned material
  23021. */
  23022. clone(name: string): Nullable<Material>;
  23023. /**
  23024. * Gets the meshes bound to the material
  23025. * @returns an array of meshes bound to the material
  23026. */
  23027. getBindedMeshes(): AbstractMesh[];
  23028. /**
  23029. * Force shader compilation
  23030. * @param mesh defines the mesh associated with this material
  23031. * @param onCompiled defines a function to execute once the material is compiled
  23032. * @param options defines the options to configure the compilation
  23033. */
  23034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23035. clipPlane: boolean;
  23036. }>): void;
  23037. /**
  23038. * Force shader compilation
  23039. * @param mesh defines the mesh that will use this material
  23040. * @param options defines additional options for compiling the shaders
  23041. * @returns a promise that resolves when the compilation completes
  23042. */
  23043. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23044. clipPlane: boolean;
  23045. }>): Promise<void>;
  23046. private static readonly _ImageProcessingDirtyCallBack;
  23047. private static readonly _TextureDirtyCallBack;
  23048. private static readonly _FresnelDirtyCallBack;
  23049. private static readonly _MiscDirtyCallBack;
  23050. private static readonly _LightsDirtyCallBack;
  23051. private static readonly _AttributeDirtyCallBack;
  23052. private static _FresnelAndMiscDirtyCallBack;
  23053. private static _TextureAndMiscDirtyCallBack;
  23054. private static readonly _DirtyCallbackArray;
  23055. private static readonly _RunDirtyCallBacks;
  23056. /**
  23057. * Marks a define in the material to indicate that it needs to be re-computed
  23058. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23059. */
  23060. markAsDirty(flag: number): void;
  23061. /**
  23062. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23063. * @param func defines a function which checks material defines against the submeshes
  23064. */
  23065. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23066. /**
  23067. * Indicates that image processing needs to be re-calculated for all submeshes
  23068. */
  23069. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23070. /**
  23071. * Indicates that textures need to be re-calculated for all submeshes
  23072. */
  23073. protected _markAllSubMeshesAsTexturesDirty(): void;
  23074. /**
  23075. * Indicates that fresnel needs to be re-calculated for all submeshes
  23076. */
  23077. protected _markAllSubMeshesAsFresnelDirty(): void;
  23078. /**
  23079. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23080. */
  23081. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23082. /**
  23083. * Indicates that lights need to be re-calculated for all submeshes
  23084. */
  23085. protected _markAllSubMeshesAsLightsDirty(): void;
  23086. /**
  23087. * Indicates that attributes need to be re-calculated for all submeshes
  23088. */
  23089. protected _markAllSubMeshesAsAttributesDirty(): void;
  23090. /**
  23091. * Indicates that misc needs to be re-calculated for all submeshes
  23092. */
  23093. protected _markAllSubMeshesAsMiscDirty(): void;
  23094. /**
  23095. * Indicates that textures and misc need to be re-calculated for all submeshes
  23096. */
  23097. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23098. /**
  23099. * Disposes the material
  23100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23103. */
  23104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23105. /** @hidden */
  23106. private releaseVertexArrayObject;
  23107. /**
  23108. * Serializes this material
  23109. * @returns the serialized material object
  23110. */
  23111. serialize(): any;
  23112. /**
  23113. * Creates a material from parsed material data
  23114. * @param parsedMaterial defines parsed material data
  23115. * @param scene defines the hosting scene
  23116. * @param rootUrl defines the root URL to use to load textures
  23117. * @returns a new material
  23118. */
  23119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23120. }
  23121. }
  23122. declare module "babylonjs/Meshes/subMesh" {
  23123. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23124. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23125. import { Engine } from "babylonjs/Engines/engine";
  23126. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23127. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23128. import { Effect } from "babylonjs/Materials/effect";
  23129. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23130. import { Collider } from "babylonjs/Collisions/collider";
  23131. import { Material } from "babylonjs/Materials/material";
  23132. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23134. import { Mesh } from "babylonjs/Meshes/mesh";
  23135. import { Ray } from "babylonjs/Culling/ray";
  23136. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23137. /**
  23138. * Base class for submeshes
  23139. */
  23140. export class BaseSubMesh {
  23141. /** @hidden */
  23142. _materialDefines: Nullable<MaterialDefines>;
  23143. /** @hidden */
  23144. _materialEffect: Nullable<Effect>;
  23145. /**
  23146. * Gets associated effect
  23147. */
  23148. readonly effect: Nullable<Effect>;
  23149. /**
  23150. * Sets associated effect (effect used to render this submesh)
  23151. * @param effect defines the effect to associate with
  23152. * @param defines defines the set of defines used to compile this effect
  23153. */
  23154. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23155. }
  23156. /**
  23157. * Defines a subdivision inside a mesh
  23158. */
  23159. export class SubMesh extends BaseSubMesh implements ICullable {
  23160. /** the material index to use */
  23161. materialIndex: number;
  23162. /** vertex index start */
  23163. verticesStart: number;
  23164. /** vertices count */
  23165. verticesCount: number;
  23166. /** index start */
  23167. indexStart: number;
  23168. /** indices count */
  23169. indexCount: number;
  23170. /** @hidden */
  23171. _linesIndexCount: number;
  23172. private _mesh;
  23173. private _renderingMesh;
  23174. private _boundingInfo;
  23175. private _linesIndexBuffer;
  23176. /** @hidden */
  23177. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23178. /** @hidden */
  23179. _trianglePlanes: Plane[];
  23180. /** @hidden */
  23181. _lastColliderTransformMatrix: Nullable<Matrix>;
  23182. /** @hidden */
  23183. _renderId: number;
  23184. /** @hidden */
  23185. _alphaIndex: number;
  23186. /** @hidden */
  23187. _distanceToCamera: number;
  23188. /** @hidden */
  23189. _id: number;
  23190. private _currentMaterial;
  23191. /**
  23192. * Add a new submesh to a mesh
  23193. * @param materialIndex defines the material index to use
  23194. * @param verticesStart defines vertex index start
  23195. * @param verticesCount defines vertices count
  23196. * @param indexStart defines index start
  23197. * @param indexCount defines indices count
  23198. * @param mesh defines the parent mesh
  23199. * @param renderingMesh defines an optional rendering mesh
  23200. * @param createBoundingBox defines if bounding box should be created for this submesh
  23201. * @returns the new submesh
  23202. */
  23203. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23204. /**
  23205. * Creates a new submesh
  23206. * @param materialIndex defines the material index to use
  23207. * @param verticesStart defines vertex index start
  23208. * @param verticesCount defines vertices count
  23209. * @param indexStart defines index start
  23210. * @param indexCount defines indices count
  23211. * @param mesh defines the parent mesh
  23212. * @param renderingMesh defines an optional rendering mesh
  23213. * @param createBoundingBox defines if bounding box should be created for this submesh
  23214. */
  23215. constructor(
  23216. /** the material index to use */
  23217. materialIndex: number,
  23218. /** vertex index start */
  23219. verticesStart: number,
  23220. /** vertices count */
  23221. verticesCount: number,
  23222. /** index start */
  23223. indexStart: number,
  23224. /** indices count */
  23225. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23226. /**
  23227. * Returns true if this submesh covers the entire parent mesh
  23228. * @ignorenaming
  23229. */
  23230. readonly IsGlobal: boolean;
  23231. /**
  23232. * Returns the submesh BoudingInfo object
  23233. * @returns current bounding info (or mesh's one if the submesh is global)
  23234. */
  23235. getBoundingInfo(): BoundingInfo;
  23236. /**
  23237. * Sets the submesh BoundingInfo
  23238. * @param boundingInfo defines the new bounding info to use
  23239. * @returns the SubMesh
  23240. */
  23241. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23242. /**
  23243. * Returns the mesh of the current submesh
  23244. * @return the parent mesh
  23245. */
  23246. getMesh(): AbstractMesh;
  23247. /**
  23248. * Returns the rendering mesh of the submesh
  23249. * @returns the rendering mesh (could be different from parent mesh)
  23250. */
  23251. getRenderingMesh(): Mesh;
  23252. /**
  23253. * Returns the submesh material
  23254. * @returns null or the current material
  23255. */
  23256. getMaterial(): Nullable<Material>;
  23257. /**
  23258. * Sets a new updated BoundingInfo object to the submesh
  23259. * @param data defines an optional position array to use to determine the bounding info
  23260. * @returns the SubMesh
  23261. */
  23262. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23263. /** @hidden */
  23264. _checkCollision(collider: Collider): boolean;
  23265. /**
  23266. * Updates the submesh BoundingInfo
  23267. * @param world defines the world matrix to use to update the bounding info
  23268. * @returns the submesh
  23269. */
  23270. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23271. /**
  23272. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23273. * @param frustumPlanes defines the frustum planes
  23274. * @returns true if the submesh is intersecting with the frustum
  23275. */
  23276. isInFrustum(frustumPlanes: Plane[]): boolean;
  23277. /**
  23278. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23279. * @param frustumPlanes defines the frustum planes
  23280. * @returns true if the submesh is inside the frustum
  23281. */
  23282. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23283. /**
  23284. * Renders the submesh
  23285. * @param enableAlphaMode defines if alpha needs to be used
  23286. * @returns the submesh
  23287. */
  23288. render(enableAlphaMode: boolean): SubMesh;
  23289. /**
  23290. * @hidden
  23291. */
  23292. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23293. /**
  23294. * Checks if the submesh intersects with a ray
  23295. * @param ray defines the ray to test
  23296. * @returns true is the passed ray intersects the submesh bounding box
  23297. */
  23298. canIntersects(ray: Ray): boolean;
  23299. /**
  23300. * Intersects current submesh with a ray
  23301. * @param ray defines the ray to test
  23302. * @param positions defines mesh's positions array
  23303. * @param indices defines mesh's indices array
  23304. * @param fastCheck defines if only bounding info should be used
  23305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23306. * @returns intersection info or null if no intersection
  23307. */
  23308. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23309. /** @hidden */
  23310. private _intersectLines;
  23311. /** @hidden */
  23312. private _intersectTriangles;
  23313. /** @hidden */
  23314. _rebuild(): void;
  23315. /**
  23316. * Creates a new submesh from the passed mesh
  23317. * @param newMesh defines the new hosting mesh
  23318. * @param newRenderingMesh defines an optional rendering mesh
  23319. * @returns the new submesh
  23320. */
  23321. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23322. /**
  23323. * Release associated resources
  23324. */
  23325. dispose(): void;
  23326. /**
  23327. * Gets the class name
  23328. * @returns the string "SubMesh".
  23329. */
  23330. getClassName(): string;
  23331. /**
  23332. * Creates a new submesh from indices data
  23333. * @param materialIndex the index of the main mesh material
  23334. * @param startIndex the index where to start the copy in the mesh indices array
  23335. * @param indexCount the number of indices to copy then from the startIndex
  23336. * @param mesh the main mesh to create the submesh from
  23337. * @param renderingMesh the optional rendering mesh
  23338. * @returns a new submesh
  23339. */
  23340. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23341. }
  23342. }
  23343. declare module "babylonjs/Meshes/geometry" {
  23344. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23345. import { Scene } from "babylonjs/scene";
  23346. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23347. import { Engine } from "babylonjs/Engines/engine";
  23348. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23350. import { Effect } from "babylonjs/Materials/effect";
  23351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23353. import { Mesh } from "babylonjs/Meshes/mesh";
  23354. /**
  23355. * Class used to store geometry data (vertex buffers + index buffer)
  23356. */
  23357. export class Geometry implements IGetSetVerticesData {
  23358. /**
  23359. * Gets or sets the ID of the geometry
  23360. */
  23361. id: string;
  23362. /**
  23363. * Gets or sets the unique ID of the geometry
  23364. */
  23365. uniqueId: number;
  23366. /**
  23367. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23368. */
  23369. delayLoadState: number;
  23370. /**
  23371. * Gets the file containing the data to load when running in delay load state
  23372. */
  23373. delayLoadingFile: Nullable<string>;
  23374. /**
  23375. * Callback called when the geometry is updated
  23376. */
  23377. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23378. private _scene;
  23379. private _engine;
  23380. private _meshes;
  23381. private _totalVertices;
  23382. /** @hidden */
  23383. _indices: IndicesArray;
  23384. /** @hidden */
  23385. _vertexBuffers: {
  23386. [key: string]: VertexBuffer;
  23387. };
  23388. private _isDisposed;
  23389. private _extend;
  23390. private _boundingBias;
  23391. /** @hidden */
  23392. _delayInfo: Array<string>;
  23393. private _indexBuffer;
  23394. private _indexBufferIsUpdatable;
  23395. /** @hidden */
  23396. _boundingInfo: Nullable<BoundingInfo>;
  23397. /** @hidden */
  23398. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23399. /** @hidden */
  23400. _softwareSkinningFrameId: number;
  23401. private _vertexArrayObjects;
  23402. private _updatable;
  23403. /** @hidden */
  23404. _positions: Nullable<Vector3[]>;
  23405. /**
  23406. * 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
  23407. */
  23408. /**
  23409. * 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
  23410. */
  23411. boundingBias: Vector2;
  23412. /**
  23413. * Static function used to attach a new empty geometry to a mesh
  23414. * @param mesh defines the mesh to attach the geometry to
  23415. * @returns the new Geometry
  23416. */
  23417. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23418. /**
  23419. * Creates a new geometry
  23420. * @param id defines the unique ID
  23421. * @param scene defines the hosting scene
  23422. * @param vertexData defines the VertexData used to get geometry data
  23423. * @param updatable defines if geometry must be updatable (false by default)
  23424. * @param mesh defines the mesh that will be associated with the geometry
  23425. */
  23426. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23427. /**
  23428. * Gets the current extend of the geometry
  23429. */
  23430. readonly extend: {
  23431. minimum: Vector3;
  23432. maximum: Vector3;
  23433. };
  23434. /**
  23435. * Gets the hosting scene
  23436. * @returns the hosting Scene
  23437. */
  23438. getScene(): Scene;
  23439. /**
  23440. * Gets the hosting engine
  23441. * @returns the hosting Engine
  23442. */
  23443. getEngine(): Engine;
  23444. /**
  23445. * Defines if the geometry is ready to use
  23446. * @returns true if the geometry is ready to be used
  23447. */
  23448. isReady(): boolean;
  23449. /**
  23450. * Gets a value indicating that the geometry should not be serialized
  23451. */
  23452. readonly doNotSerialize: boolean;
  23453. /** @hidden */
  23454. _rebuild(): void;
  23455. /**
  23456. * Affects all geometry data in one call
  23457. * @param vertexData defines the geometry data
  23458. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23459. */
  23460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23461. /**
  23462. * Set specific vertex data
  23463. * @param kind defines the data kind (Position, normal, etc...)
  23464. * @param data defines the vertex data to use
  23465. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23466. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23467. */
  23468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23469. /**
  23470. * Removes a specific vertex data
  23471. * @param kind defines the data kind (Position, normal, etc...)
  23472. */
  23473. removeVerticesData(kind: string): void;
  23474. /**
  23475. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23476. * @param buffer defines the vertex buffer to use
  23477. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23478. */
  23479. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23480. /**
  23481. * Update a specific vertex buffer
  23482. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23483. * It will do nothing if the buffer is not updatable
  23484. * @param kind defines the data kind (Position, normal, etc...)
  23485. * @param data defines the data to use
  23486. * @param offset defines the offset in the target buffer where to store the data
  23487. * @param useBytes set to true if the offset is in bytes
  23488. */
  23489. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23490. /**
  23491. * Update a specific vertex buffer
  23492. * This function will create a new buffer if the current one is not updatable
  23493. * @param kind defines the data kind (Position, normal, etc...)
  23494. * @param data defines the data to use
  23495. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23496. */
  23497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23498. private _updateBoundingInfo;
  23499. /** @hidden */
  23500. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23501. /**
  23502. * Gets total number of vertices
  23503. * @returns the total number of vertices
  23504. */
  23505. getTotalVertices(): number;
  23506. /**
  23507. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23508. * @param kind defines the data kind (Position, normal, etc...)
  23509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23511. * @returns a float array containing vertex data
  23512. */
  23513. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23514. /**
  23515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23516. * @param kind defines the data kind (Position, normal, etc...)
  23517. * @returns true if the vertex buffer with the specified kind is updatable
  23518. */
  23519. isVertexBufferUpdatable(kind: string): boolean;
  23520. /**
  23521. * Gets a specific vertex buffer
  23522. * @param kind defines the data kind (Position, normal, etc...)
  23523. * @returns a VertexBuffer
  23524. */
  23525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23526. /**
  23527. * Returns all vertex buffers
  23528. * @return an object holding all vertex buffers indexed by kind
  23529. */
  23530. getVertexBuffers(): Nullable<{
  23531. [key: string]: VertexBuffer;
  23532. }>;
  23533. /**
  23534. * Gets a boolean indicating if specific vertex buffer is present
  23535. * @param kind defines the data kind (Position, normal, etc...)
  23536. * @returns true if data is present
  23537. */
  23538. isVerticesDataPresent(kind: string): boolean;
  23539. /**
  23540. * Gets a list of all attached data kinds (Position, normal, etc...)
  23541. * @returns a list of string containing all kinds
  23542. */
  23543. getVerticesDataKinds(): string[];
  23544. /**
  23545. * Update index buffer
  23546. * @param indices defines the indices to store in the index buffer
  23547. * @param offset defines the offset in the target buffer where to store the data
  23548. * @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)
  23549. */
  23550. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23551. /**
  23552. * Creates a new index buffer
  23553. * @param indices defines the indices to store in the index buffer
  23554. * @param totalVertices defines the total number of vertices (could be null)
  23555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23556. */
  23557. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23558. /**
  23559. * Return the total number of indices
  23560. * @returns the total number of indices
  23561. */
  23562. getTotalIndices(): number;
  23563. /**
  23564. * Gets the index buffer array
  23565. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23567. * @returns the index buffer array
  23568. */
  23569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23570. /**
  23571. * Gets the index buffer
  23572. * @return the index buffer
  23573. */
  23574. getIndexBuffer(): Nullable<DataBuffer>;
  23575. /** @hidden */
  23576. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23577. /**
  23578. * Release the associated resources for a specific mesh
  23579. * @param mesh defines the source mesh
  23580. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23581. */
  23582. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23583. /**
  23584. * Apply current geometry to a given mesh
  23585. * @param mesh defines the mesh to apply geometry to
  23586. */
  23587. applyToMesh(mesh: Mesh): void;
  23588. private _updateExtend;
  23589. private _applyToMesh;
  23590. private notifyUpdate;
  23591. /**
  23592. * Load the geometry if it was flagged as delay loaded
  23593. * @param scene defines the hosting scene
  23594. * @param onLoaded defines a callback called when the geometry is loaded
  23595. */
  23596. load(scene: Scene, onLoaded?: () => void): void;
  23597. private _queueLoad;
  23598. /**
  23599. * Invert the geometry to move from a right handed system to a left handed one.
  23600. */
  23601. toLeftHanded(): void;
  23602. /** @hidden */
  23603. _resetPointsArrayCache(): void;
  23604. /** @hidden */
  23605. _generatePointsArray(): boolean;
  23606. /**
  23607. * Gets a value indicating if the geometry is disposed
  23608. * @returns true if the geometry was disposed
  23609. */
  23610. isDisposed(): boolean;
  23611. private _disposeVertexArrayObjects;
  23612. /**
  23613. * Free all associated resources
  23614. */
  23615. dispose(): void;
  23616. /**
  23617. * Clone the current geometry into a new geometry
  23618. * @param id defines the unique ID of the new geometry
  23619. * @returns a new geometry object
  23620. */
  23621. copy(id: string): Geometry;
  23622. /**
  23623. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23624. * @return a JSON representation of the current geometry data (without the vertices data)
  23625. */
  23626. serialize(): any;
  23627. private toNumberArray;
  23628. /**
  23629. * Serialize all vertices data into a JSON oject
  23630. * @returns a JSON representation of the current geometry data
  23631. */
  23632. serializeVerticeData(): any;
  23633. /**
  23634. * Extracts a clone of a mesh geometry
  23635. * @param mesh defines the source mesh
  23636. * @param id defines the unique ID of the new geometry object
  23637. * @returns the new geometry object
  23638. */
  23639. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23640. /**
  23641. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23642. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23643. * Be aware Math.random() could cause collisions, but:
  23644. * "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"
  23645. * @returns a string containing a new GUID
  23646. */
  23647. static RandomId(): string;
  23648. /** @hidden */
  23649. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23650. private static _CleanMatricesWeights;
  23651. /**
  23652. * Create a new geometry from persisted data (Using .babylon file format)
  23653. * @param parsedVertexData defines the persisted data
  23654. * @param scene defines the hosting scene
  23655. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23656. * @returns the new geometry object
  23657. */
  23658. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23659. }
  23660. }
  23661. declare module "babylonjs/Meshes/mesh.vertexData" {
  23662. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23663. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23664. import { Geometry } from "babylonjs/Meshes/geometry";
  23665. import { Mesh } from "babylonjs/Meshes/mesh";
  23666. /**
  23667. * Define an interface for all classes that will get and set the data on vertices
  23668. */
  23669. export interface IGetSetVerticesData {
  23670. /**
  23671. * Gets a boolean indicating if specific vertex data is present
  23672. * @param kind defines the vertex data kind to use
  23673. * @returns true is data kind is present
  23674. */
  23675. isVerticesDataPresent(kind: string): boolean;
  23676. /**
  23677. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23678. * @param kind defines the data kind (Position, normal, etc...)
  23679. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23680. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23681. * @returns a float array containing vertex data
  23682. */
  23683. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23684. /**
  23685. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23686. * @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.
  23687. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23688. * @returns the indices array or an empty array if the mesh has no geometry
  23689. */
  23690. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23691. /**
  23692. * Set specific vertex data
  23693. * @param kind defines the data kind (Position, normal, etc...)
  23694. * @param data defines the vertex data to use
  23695. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23696. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23697. */
  23698. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23699. /**
  23700. * Update a specific associated vertex buffer
  23701. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23702. * - VertexBuffer.PositionKind
  23703. * - VertexBuffer.UVKind
  23704. * - VertexBuffer.UV2Kind
  23705. * - VertexBuffer.UV3Kind
  23706. * - VertexBuffer.UV4Kind
  23707. * - VertexBuffer.UV5Kind
  23708. * - VertexBuffer.UV6Kind
  23709. * - VertexBuffer.ColorKind
  23710. * - VertexBuffer.MatricesIndicesKind
  23711. * - VertexBuffer.MatricesIndicesExtraKind
  23712. * - VertexBuffer.MatricesWeightsKind
  23713. * - VertexBuffer.MatricesWeightsExtraKind
  23714. * @param data defines the data source
  23715. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23716. * @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)
  23717. */
  23718. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23719. /**
  23720. * Creates a new index buffer
  23721. * @param indices defines the indices to store in the index buffer
  23722. * @param totalVertices defines the total number of vertices (could be null)
  23723. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23724. */
  23725. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23726. }
  23727. /**
  23728. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23729. */
  23730. export class VertexData {
  23731. /**
  23732. * Mesh side orientation : usually the external or front surface
  23733. */
  23734. static readonly FRONTSIDE: number;
  23735. /**
  23736. * Mesh side orientation : usually the internal or back surface
  23737. */
  23738. static readonly BACKSIDE: number;
  23739. /**
  23740. * Mesh side orientation : both internal and external or front and back surfaces
  23741. */
  23742. static readonly DOUBLESIDE: number;
  23743. /**
  23744. * Mesh side orientation : by default, `FRONTSIDE`
  23745. */
  23746. static readonly DEFAULTSIDE: number;
  23747. /**
  23748. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23749. */
  23750. positions: Nullable<FloatArray>;
  23751. /**
  23752. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23753. */
  23754. normals: Nullable<FloatArray>;
  23755. /**
  23756. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23757. */
  23758. tangents: Nullable<FloatArray>;
  23759. /**
  23760. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23761. */
  23762. uvs: Nullable<FloatArray>;
  23763. /**
  23764. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23765. */
  23766. uvs2: Nullable<FloatArray>;
  23767. /**
  23768. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23769. */
  23770. uvs3: Nullable<FloatArray>;
  23771. /**
  23772. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23773. */
  23774. uvs4: Nullable<FloatArray>;
  23775. /**
  23776. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23777. */
  23778. uvs5: Nullable<FloatArray>;
  23779. /**
  23780. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23781. */
  23782. uvs6: Nullable<FloatArray>;
  23783. /**
  23784. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23785. */
  23786. colors: Nullable<FloatArray>;
  23787. /**
  23788. * 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).
  23789. */
  23790. matricesIndices: Nullable<FloatArray>;
  23791. /**
  23792. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23793. */
  23794. matricesWeights: Nullable<FloatArray>;
  23795. /**
  23796. * An array extending the number of possible indices
  23797. */
  23798. matricesIndicesExtra: Nullable<FloatArray>;
  23799. /**
  23800. * An array extending the number of possible weights when the number of indices is extended
  23801. */
  23802. matricesWeightsExtra: Nullable<FloatArray>;
  23803. /**
  23804. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23805. */
  23806. indices: Nullable<IndicesArray>;
  23807. /**
  23808. * Uses the passed data array to set the set the values for the specified kind of data
  23809. * @param data a linear array of floating numbers
  23810. * @param kind the type of data that is being set, eg positions, colors etc
  23811. */
  23812. set(data: FloatArray, kind: string): void;
  23813. /**
  23814. * Associates the vertexData to the passed Mesh.
  23815. * Sets it as updatable or not (default `false`)
  23816. * @param mesh the mesh the vertexData is applied to
  23817. * @param updatable when used and having the value true allows new data to update the vertexData
  23818. * @returns the VertexData
  23819. */
  23820. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23821. /**
  23822. * Associates the vertexData to the passed Geometry.
  23823. * Sets it as updatable or not (default `false`)
  23824. * @param geometry the geometry the vertexData is applied to
  23825. * @param updatable when used and having the value true allows new data to update the vertexData
  23826. * @returns VertexData
  23827. */
  23828. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23829. /**
  23830. * Updates the associated mesh
  23831. * @param mesh the mesh to be updated
  23832. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23833. * @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
  23834. * @returns VertexData
  23835. */
  23836. updateMesh(mesh: Mesh): VertexData;
  23837. /**
  23838. * Updates the associated geometry
  23839. * @param geometry the geometry to be updated
  23840. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23841. * @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
  23842. * @returns VertexData.
  23843. */
  23844. updateGeometry(geometry: Geometry): VertexData;
  23845. private _applyTo;
  23846. private _update;
  23847. /**
  23848. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23849. * @param matrix the transforming matrix
  23850. * @returns the VertexData
  23851. */
  23852. transform(matrix: Matrix): VertexData;
  23853. /**
  23854. * Merges the passed VertexData into the current one
  23855. * @param other the VertexData to be merged into the current one
  23856. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23857. * @returns the modified VertexData
  23858. */
  23859. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23860. private _mergeElement;
  23861. private _validate;
  23862. /**
  23863. * Serializes the VertexData
  23864. * @returns a serialized object
  23865. */
  23866. serialize(): any;
  23867. /**
  23868. * Extracts the vertexData from a mesh
  23869. * @param mesh the mesh from which to extract the VertexData
  23870. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23871. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23872. * @returns the object VertexData associated to the passed mesh
  23873. */
  23874. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23875. /**
  23876. * Extracts the vertexData from the geometry
  23877. * @param geometry the geometry from which to extract the VertexData
  23878. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23879. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23880. * @returns the object VertexData associated to the passed mesh
  23881. */
  23882. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23883. private static _ExtractFrom;
  23884. /**
  23885. * Creates the VertexData for a Ribbon
  23886. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23887. * * pathArray array of paths, each of which an array of successive Vector3
  23888. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23889. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23890. * * 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
  23891. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23892. * * 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)
  23893. * * 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)
  23894. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23895. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23896. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23897. * @returns the VertexData of the ribbon
  23898. */
  23899. static CreateRibbon(options: {
  23900. pathArray: Vector3[][];
  23901. closeArray?: boolean;
  23902. closePath?: boolean;
  23903. offset?: number;
  23904. sideOrientation?: number;
  23905. frontUVs?: Vector4;
  23906. backUVs?: Vector4;
  23907. invertUV?: boolean;
  23908. uvs?: Vector2[];
  23909. colors?: Color4[];
  23910. }): VertexData;
  23911. /**
  23912. * Creates the VertexData for a box
  23913. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23914. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23915. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23916. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23917. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23918. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23919. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23920. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23921. * * 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)
  23922. * * 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)
  23923. * @returns the VertexData of the box
  23924. */
  23925. static CreateBox(options: {
  23926. size?: number;
  23927. width?: number;
  23928. height?: number;
  23929. depth?: number;
  23930. faceUV?: Vector4[];
  23931. faceColors?: Color4[];
  23932. sideOrientation?: number;
  23933. frontUVs?: Vector4;
  23934. backUVs?: Vector4;
  23935. }): VertexData;
  23936. /**
  23937. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23938. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23939. * * segments sets the number of horizontal strips optional, default 32
  23940. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23941. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23942. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23943. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23944. * * 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
  23945. * * 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
  23946. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23947. * * 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)
  23948. * * 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)
  23949. * @returns the VertexData of the ellipsoid
  23950. */
  23951. static CreateSphere(options: {
  23952. segments?: number;
  23953. diameter?: number;
  23954. diameterX?: number;
  23955. diameterY?: number;
  23956. diameterZ?: number;
  23957. arc?: number;
  23958. slice?: number;
  23959. sideOrientation?: number;
  23960. frontUVs?: Vector4;
  23961. backUVs?: Vector4;
  23962. }): VertexData;
  23963. /**
  23964. * Creates the VertexData for a cylinder, cone or prism
  23965. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23966. * * height sets the height (y direction) of the cylinder, optional, default 2
  23967. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23968. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23969. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23970. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23971. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23972. * * 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
  23973. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23974. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23975. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23976. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23978. * * 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)
  23979. * * 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)
  23980. * @returns the VertexData of the cylinder, cone or prism
  23981. */
  23982. static CreateCylinder(options: {
  23983. height?: number;
  23984. diameterTop?: number;
  23985. diameterBottom?: number;
  23986. diameter?: number;
  23987. tessellation?: number;
  23988. subdivisions?: number;
  23989. arc?: number;
  23990. faceColors?: Color4[];
  23991. faceUV?: Vector4[];
  23992. hasRings?: boolean;
  23993. enclose?: boolean;
  23994. sideOrientation?: number;
  23995. frontUVs?: Vector4;
  23996. backUVs?: Vector4;
  23997. }): VertexData;
  23998. /**
  23999. * Creates the VertexData for a torus
  24000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24001. * * diameter the diameter of the torus, optional default 1
  24002. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24003. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24005. * * 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)
  24006. * * 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)
  24007. * @returns the VertexData of the torus
  24008. */
  24009. static CreateTorus(options: {
  24010. diameter?: number;
  24011. thickness?: number;
  24012. tessellation?: number;
  24013. sideOrientation?: number;
  24014. frontUVs?: Vector4;
  24015. backUVs?: Vector4;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData of the LineSystem
  24019. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24020. * - lines an array of lines, each line being an array of successive Vector3
  24021. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24022. * @returns the VertexData of the LineSystem
  24023. */
  24024. static CreateLineSystem(options: {
  24025. lines: Vector3[][];
  24026. colors?: Nullable<Color4[][]>;
  24027. }): VertexData;
  24028. /**
  24029. * Create the VertexData for a DashedLines
  24030. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24031. * - points an array successive Vector3
  24032. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24033. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24034. * - dashNb the intended total number of dashes, optional, default 200
  24035. * @returns the VertexData for the DashedLines
  24036. */
  24037. static CreateDashedLines(options: {
  24038. points: Vector3[];
  24039. dashSize?: number;
  24040. gapSize?: number;
  24041. dashNb?: number;
  24042. }): VertexData;
  24043. /**
  24044. * Creates the VertexData for a Ground
  24045. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24046. * - width the width (x direction) of the ground, optional, default 1
  24047. * - height the height (z direction) of the ground, optional, default 1
  24048. * - subdivisions the number of subdivisions per side, optional, default 1
  24049. * @returns the VertexData of the Ground
  24050. */
  24051. static CreateGround(options: {
  24052. width?: number;
  24053. height?: number;
  24054. subdivisions?: number;
  24055. subdivisionsX?: number;
  24056. subdivisionsY?: number;
  24057. }): VertexData;
  24058. /**
  24059. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24060. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24061. * * xmin the ground minimum X coordinate, optional, default -1
  24062. * * zmin the ground minimum Z coordinate, optional, default -1
  24063. * * xmax the ground maximum X coordinate, optional, default 1
  24064. * * zmax the ground maximum Z coordinate, optional, default 1
  24065. * * 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}
  24066. * * 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}
  24067. * @returns the VertexData of the TiledGround
  24068. */
  24069. static CreateTiledGround(options: {
  24070. xmin: number;
  24071. zmin: number;
  24072. xmax: number;
  24073. zmax: number;
  24074. subdivisions?: {
  24075. w: number;
  24076. h: number;
  24077. };
  24078. precision?: {
  24079. w: number;
  24080. h: number;
  24081. };
  24082. }): VertexData;
  24083. /**
  24084. * Creates the VertexData of the Ground designed from a heightmap
  24085. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24086. * * width the width (x direction) of the ground
  24087. * * height the height (z direction) of the ground
  24088. * * subdivisions the number of subdivisions per side
  24089. * * minHeight the minimum altitude on the ground, optional, default 0
  24090. * * maxHeight the maximum altitude on the ground, optional default 1
  24091. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24092. * * buffer the array holding the image color data
  24093. * * bufferWidth the width of image
  24094. * * bufferHeight the height of image
  24095. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24096. * @returns the VertexData of the Ground designed from a heightmap
  24097. */
  24098. static CreateGroundFromHeightMap(options: {
  24099. width: number;
  24100. height: number;
  24101. subdivisions: number;
  24102. minHeight: number;
  24103. maxHeight: number;
  24104. colorFilter: Color3;
  24105. buffer: Uint8Array;
  24106. bufferWidth: number;
  24107. bufferHeight: number;
  24108. alphaFilter: number;
  24109. }): VertexData;
  24110. /**
  24111. * Creates the VertexData for a Plane
  24112. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24113. * * size sets the width and height of the plane to the value of size, optional default 1
  24114. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24115. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24117. * * 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)
  24118. * * 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)
  24119. * @returns the VertexData of the box
  24120. */
  24121. static CreatePlane(options: {
  24122. size?: number;
  24123. width?: number;
  24124. height?: number;
  24125. sideOrientation?: number;
  24126. frontUVs?: Vector4;
  24127. backUVs?: Vector4;
  24128. }): VertexData;
  24129. /**
  24130. * Creates the VertexData of the Disc or regular Polygon
  24131. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24132. * * radius the radius of the disc, optional default 0.5
  24133. * * tessellation the number of polygon sides, optional, default 64
  24134. * * 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
  24135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24136. * * 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)
  24137. * * 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)
  24138. * @returns the VertexData of the box
  24139. */
  24140. static CreateDisc(options: {
  24141. radius?: number;
  24142. tessellation?: number;
  24143. arc?: number;
  24144. sideOrientation?: number;
  24145. frontUVs?: Vector4;
  24146. backUVs?: Vector4;
  24147. }): VertexData;
  24148. /**
  24149. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24150. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24151. * @param polygon a mesh built from polygonTriangulation.build()
  24152. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24153. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24154. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24155. * @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)
  24156. * @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)
  24157. * @returns the VertexData of the Polygon
  24158. */
  24159. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24160. /**
  24161. * Creates the VertexData of the IcoSphere
  24162. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24163. * * radius the radius of the IcoSphere, optional default 1
  24164. * * radiusX allows stretching in the x direction, optional, default radius
  24165. * * radiusY allows stretching in the y direction, optional, default radius
  24166. * * radiusZ allows stretching in the z direction, optional, default radius
  24167. * * flat when true creates a flat shaded mesh, optional, default true
  24168. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24170. * * 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)
  24171. * * 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)
  24172. * @returns the VertexData of the IcoSphere
  24173. */
  24174. static CreateIcoSphere(options: {
  24175. radius?: number;
  24176. radiusX?: number;
  24177. radiusY?: number;
  24178. radiusZ?: number;
  24179. flat?: boolean;
  24180. subdivisions?: number;
  24181. sideOrientation?: number;
  24182. frontUVs?: Vector4;
  24183. backUVs?: Vector4;
  24184. }): VertexData;
  24185. /**
  24186. * Creates the VertexData for a Polyhedron
  24187. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24188. * * type provided types are:
  24189. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24190. * * 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)
  24191. * * size the size of the IcoSphere, optional default 1
  24192. * * sizeX allows stretching in the x direction, optional, default size
  24193. * * sizeY allows stretching in the y direction, optional, default size
  24194. * * sizeZ allows stretching in the z direction, optional, default size
  24195. * * 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
  24196. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24197. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24198. * * flat when true creates a flat shaded mesh, optional, default true
  24199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24201. * * 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)
  24202. * * 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)
  24203. * @returns the VertexData of the Polyhedron
  24204. */
  24205. static CreatePolyhedron(options: {
  24206. type?: number;
  24207. size?: number;
  24208. sizeX?: number;
  24209. sizeY?: number;
  24210. sizeZ?: number;
  24211. custom?: any;
  24212. faceUV?: Vector4[];
  24213. faceColors?: Color4[];
  24214. flat?: boolean;
  24215. sideOrientation?: number;
  24216. frontUVs?: Vector4;
  24217. backUVs?: Vector4;
  24218. }): VertexData;
  24219. /**
  24220. * Creates the VertexData for a TorusKnot
  24221. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24222. * * radius the radius of the torus knot, optional, default 2
  24223. * * tube the thickness of the tube, optional, default 0.5
  24224. * * radialSegments the number of sides on each tube segments, optional, default 32
  24225. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24226. * * p the number of windings around the z axis, optional, default 2
  24227. * * q the number of windings around the x axis, optional, default 3
  24228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24229. * * 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)
  24230. * * 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)
  24231. * @returns the VertexData of the Torus Knot
  24232. */
  24233. static CreateTorusKnot(options: {
  24234. radius?: number;
  24235. tube?: number;
  24236. radialSegments?: number;
  24237. tubularSegments?: number;
  24238. p?: number;
  24239. q?: number;
  24240. sideOrientation?: number;
  24241. frontUVs?: Vector4;
  24242. backUVs?: Vector4;
  24243. }): VertexData;
  24244. /**
  24245. * Compute normals for given positions and indices
  24246. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24247. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24248. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24249. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24250. * * facetNormals : optional array of facet normals (vector3)
  24251. * * facetPositions : optional array of facet positions (vector3)
  24252. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24253. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24254. * * bInfo : optional bounding info, required for facetPartitioning computation
  24255. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24256. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24257. * * useRightHandedSystem: optional boolean to for right handed system computation
  24258. * * depthSort : optional boolean to enable the facet depth sort computation
  24259. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24260. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24261. */
  24262. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24263. facetNormals?: any;
  24264. facetPositions?: any;
  24265. facetPartitioning?: any;
  24266. ratio?: number;
  24267. bInfo?: any;
  24268. bbSize?: Vector3;
  24269. subDiv?: any;
  24270. useRightHandedSystem?: boolean;
  24271. depthSort?: boolean;
  24272. distanceTo?: Vector3;
  24273. depthSortedFacets?: any;
  24274. }): void;
  24275. /** @hidden */
  24276. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24277. /**
  24278. * Applies VertexData created from the imported parameters to the geometry
  24279. * @param parsedVertexData the parsed data from an imported file
  24280. * @param geometry the geometry to apply the VertexData to
  24281. */
  24282. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24283. }
  24284. }
  24285. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24286. import { Nullable } from "babylonjs/types";
  24287. import { Scene } from "babylonjs/scene";
  24288. import { Vector4 } from "babylonjs/Maths/math";
  24289. import { Mesh } from "babylonjs/Meshes/mesh";
  24290. /**
  24291. * Class containing static functions to help procedurally build meshes
  24292. */
  24293. export class DiscBuilder {
  24294. /**
  24295. * Creates a plane polygonal mesh. By default, this is a disc
  24296. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24297. * * 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
  24298. * * 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
  24299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24302. * @param name defines the name of the mesh
  24303. * @param options defines the options used to create the mesh
  24304. * @param scene defines the hosting scene
  24305. * @returns the plane polygonal mesh
  24306. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24307. */
  24308. static CreateDisc(name: string, options: {
  24309. radius?: number;
  24310. tessellation?: number;
  24311. arc?: number;
  24312. updatable?: boolean;
  24313. sideOrientation?: number;
  24314. frontUVs?: Vector4;
  24315. backUVs?: Vector4;
  24316. }, scene?: Nullable<Scene>): Mesh;
  24317. }
  24318. }
  24319. declare module "babylonjs/Particles/solidParticleSystem" {
  24320. import { Vector3 } from "babylonjs/Maths/math";
  24321. import { Mesh } from "babylonjs/Meshes/mesh";
  24322. import { Scene, IDisposable } from "babylonjs/scene";
  24323. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24324. /**
  24325. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24326. *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.
  24327. * The SPS is also a particle system. It provides some methods to manage the particles.
  24328. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24329. *
  24330. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24331. */
  24332. export class SolidParticleSystem implements IDisposable {
  24333. /**
  24334. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24335. * Example : var p = SPS.particles[i];
  24336. */
  24337. particles: SolidParticle[];
  24338. /**
  24339. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24340. */
  24341. nbParticles: number;
  24342. /**
  24343. * If the particles must ever face the camera (default false). Useful for planar particles.
  24344. */
  24345. billboard: boolean;
  24346. /**
  24347. * Recompute normals when adding a shape
  24348. */
  24349. recomputeNormals: boolean;
  24350. /**
  24351. * This a counter ofr your own usage. It's not set by any SPS functions.
  24352. */
  24353. counter: number;
  24354. /**
  24355. * The SPS name. This name is also given to the underlying mesh.
  24356. */
  24357. name: string;
  24358. /**
  24359. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24360. */
  24361. mesh: Mesh;
  24362. /**
  24363. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24364. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24365. */
  24366. vars: any;
  24367. /**
  24368. * This array is populated when the SPS is set as 'pickable'.
  24369. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24370. * Each element of this array is an object `{idx: int, faceId: int}`.
  24371. * `idx` is the picked particle index in the `SPS.particles` array
  24372. * `faceId` is the picked face index counted within this particle.
  24373. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24374. */
  24375. pickedParticles: {
  24376. idx: number;
  24377. faceId: number;
  24378. }[];
  24379. /**
  24380. * This array is populated when `enableDepthSort` is set to true.
  24381. * Each element of this array is an instance of the class DepthSortedParticle.
  24382. */
  24383. depthSortedParticles: DepthSortedParticle[];
  24384. /**
  24385. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24386. * @hidden
  24387. */
  24388. _bSphereOnly: boolean;
  24389. /**
  24390. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24391. * @hidden
  24392. */
  24393. _bSphereRadiusFactor: number;
  24394. private _scene;
  24395. private _positions;
  24396. private _indices;
  24397. private _normals;
  24398. private _colors;
  24399. private _uvs;
  24400. private _indices32;
  24401. private _positions32;
  24402. private _normals32;
  24403. private _fixedNormal32;
  24404. private _colors32;
  24405. private _uvs32;
  24406. private _index;
  24407. private _updatable;
  24408. private _pickable;
  24409. private _isVisibilityBoxLocked;
  24410. private _alwaysVisible;
  24411. private _depthSort;
  24412. private _shapeCounter;
  24413. private _copy;
  24414. private _color;
  24415. private _computeParticleColor;
  24416. private _computeParticleTexture;
  24417. private _computeParticleRotation;
  24418. private _computeParticleVertex;
  24419. private _computeBoundingBox;
  24420. private _depthSortParticles;
  24421. private _camera;
  24422. private _mustUnrotateFixedNormals;
  24423. private _particlesIntersect;
  24424. private _needs32Bits;
  24425. /**
  24426. * Creates a SPS (Solid Particle System) object.
  24427. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24428. * @param scene (Scene) is the scene in which the SPS is added.
  24429. * @param options defines the options of the sps e.g.
  24430. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24431. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24432. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24433. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24434. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24435. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24436. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24437. */
  24438. constructor(name: string, scene: Scene, options?: {
  24439. updatable?: boolean;
  24440. isPickable?: boolean;
  24441. enableDepthSort?: boolean;
  24442. particleIntersection?: boolean;
  24443. boundingSphereOnly?: boolean;
  24444. bSphereRadiusFactor?: number;
  24445. });
  24446. /**
  24447. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24448. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24449. * @returns the created mesh
  24450. */
  24451. buildMesh(): Mesh;
  24452. /**
  24453. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24454. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24455. * Thus the particles generated from `digest()` have their property `position` set yet.
  24456. * @param mesh ( Mesh ) is the mesh to be digested
  24457. * @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
  24458. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24459. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24460. * @returns the current SPS
  24461. */
  24462. digest(mesh: Mesh, options?: {
  24463. facetNb?: number;
  24464. number?: number;
  24465. delta?: number;
  24466. }): SolidParticleSystem;
  24467. private _unrotateFixedNormals;
  24468. private _resetCopy;
  24469. private _meshBuilder;
  24470. private _posToShape;
  24471. private _uvsToShapeUV;
  24472. private _addParticle;
  24473. /**
  24474. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24475. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24476. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24477. * @param nb (positive integer) the number of particles to be created from this model
  24478. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24479. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24480. * @returns the number of shapes in the system
  24481. */
  24482. addShape(mesh: Mesh, nb: number, options?: {
  24483. positionFunction?: any;
  24484. vertexFunction?: any;
  24485. }): number;
  24486. private _rebuildParticle;
  24487. /**
  24488. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24489. * @returns the SPS.
  24490. */
  24491. rebuildMesh(): SolidParticleSystem;
  24492. /**
  24493. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24494. * This method calls `updateParticle()` for each particle of the SPS.
  24495. * For an animated SPS, it is usually called within the render loop.
  24496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24499. * @returns the SPS.
  24500. */
  24501. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24502. /**
  24503. * Disposes the SPS.
  24504. */
  24505. dispose(): void;
  24506. /**
  24507. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24509. * @returns the SPS.
  24510. */
  24511. refreshVisibleSize(): SolidParticleSystem;
  24512. /**
  24513. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24514. * @param size the size (float) of the visibility box
  24515. * note : this doesn't lock the SPS mesh bounding box.
  24516. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24517. */
  24518. setVisibilityBox(size: number): void;
  24519. /**
  24520. * Gets whether the SPS as always visible or not
  24521. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24522. */
  24523. /**
  24524. * Sets the SPS as always visible or not
  24525. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24526. */
  24527. isAlwaysVisible: boolean;
  24528. /**
  24529. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24530. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24531. */
  24532. /**
  24533. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24534. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24535. */
  24536. isVisibilityBoxLocked: boolean;
  24537. /**
  24538. * Tells to `setParticles()` to compute the particle rotations or not.
  24539. * Default value : true. The SPS is faster when it's set to false.
  24540. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24541. */
  24542. /**
  24543. * Gets if `setParticles()` computes the particle rotations or not.
  24544. * Default value : true. The SPS is faster when it's set to false.
  24545. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24546. */
  24547. computeParticleRotation: boolean;
  24548. /**
  24549. * Tells to `setParticles()` to compute the particle colors or not.
  24550. * Default value : true. The SPS is faster when it's set to false.
  24551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24552. */
  24553. /**
  24554. * Gets if `setParticles()` computes the particle colors or not.
  24555. * Default value : true. The SPS is faster when it's set to false.
  24556. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24557. */
  24558. computeParticleColor: boolean;
  24559. /**
  24560. * Gets if `setParticles()` computes the particle textures or not.
  24561. * Default value : true. The SPS is faster when it's set to false.
  24562. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24563. */
  24564. computeParticleTexture: boolean;
  24565. /**
  24566. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24567. * Default value : false. The SPS is faster when it's set to false.
  24568. * Note : the particle custom vertex positions aren't stored values.
  24569. */
  24570. /**
  24571. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24572. * Default value : false. The SPS is faster when it's set to false.
  24573. * Note : the particle custom vertex positions aren't stored values.
  24574. */
  24575. computeParticleVertex: boolean;
  24576. /**
  24577. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24578. */
  24579. /**
  24580. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24581. */
  24582. computeBoundingBox: boolean;
  24583. /**
  24584. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24585. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24586. * Default : `true`
  24587. */
  24588. /**
  24589. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24590. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24591. * Default : `true`
  24592. */
  24593. depthSortParticles: boolean;
  24594. /**
  24595. * This function does nothing. It may be overwritten to set all the particle first values.
  24596. * The SPS doesn't call this function, you may have to call it by your own.
  24597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24598. */
  24599. initParticles(): void;
  24600. /**
  24601. * This function does nothing. It may be overwritten to recycle a particle.
  24602. * The SPS doesn't call this function, you may have to call it by your own.
  24603. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24604. * @param particle The particle to recycle
  24605. * @returns the recycled particle
  24606. */
  24607. recycleParticle(particle: SolidParticle): SolidParticle;
  24608. /**
  24609. * Updates a particle : this function should be overwritten by the user.
  24610. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24611. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24612. * @example : just set a particle position or velocity and recycle conditions
  24613. * @param particle The particle to update
  24614. * @returns the updated particle
  24615. */
  24616. updateParticle(particle: SolidParticle): SolidParticle;
  24617. /**
  24618. * Updates a vertex of a particle : it can be overwritten by the user.
  24619. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24620. * @param particle the current particle
  24621. * @param vertex the current index of the current particle
  24622. * @param pt the index of the current vertex in the particle shape
  24623. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24624. * @example : just set a vertex particle position
  24625. * @returns the updated vertex
  24626. */
  24627. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24628. /**
  24629. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24630. * This does nothing and may be overwritten by the user.
  24631. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24632. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24633. * @param update the boolean update value actually passed to setParticles()
  24634. */
  24635. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24636. /**
  24637. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24638. * This will be passed three parameters.
  24639. * This does nothing and may be overwritten by the user.
  24640. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24641. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24642. * @param update the boolean update value actually passed to setParticles()
  24643. */
  24644. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24645. }
  24646. }
  24647. declare module "babylonjs/Particles/solidParticle" {
  24648. import { Nullable } from "babylonjs/types";
  24649. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24650. import { Mesh } from "babylonjs/Meshes/mesh";
  24651. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24652. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24653. /**
  24654. * Represents one particle of a solid particle system.
  24655. */
  24656. export class SolidParticle {
  24657. /**
  24658. * particle global index
  24659. */
  24660. idx: number;
  24661. /**
  24662. * The color of the particle
  24663. */
  24664. color: Nullable<Color4>;
  24665. /**
  24666. * The world space position of the particle.
  24667. */
  24668. position: Vector3;
  24669. /**
  24670. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24671. */
  24672. rotation: Vector3;
  24673. /**
  24674. * The world space rotation quaternion of the particle.
  24675. */
  24676. rotationQuaternion: Nullable<Quaternion>;
  24677. /**
  24678. * The scaling of the particle.
  24679. */
  24680. scaling: Vector3;
  24681. /**
  24682. * The uvs of the particle.
  24683. */
  24684. uvs: Vector4;
  24685. /**
  24686. * The current speed of the particle.
  24687. */
  24688. velocity: Vector3;
  24689. /**
  24690. * The pivot point in the particle local space.
  24691. */
  24692. pivot: Vector3;
  24693. /**
  24694. * Must the particle be translated from its pivot point in its local space ?
  24695. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24696. * Default : false
  24697. */
  24698. translateFromPivot: boolean;
  24699. /**
  24700. * Is the particle active or not ?
  24701. */
  24702. alive: boolean;
  24703. /**
  24704. * Is the particle visible or not ?
  24705. */
  24706. isVisible: boolean;
  24707. /**
  24708. * Index of this particle in the global "positions" array (Internal use)
  24709. * @hidden
  24710. */
  24711. _pos: number;
  24712. /**
  24713. * @hidden Index of this particle in the global "indices" array (Internal use)
  24714. */
  24715. _ind: number;
  24716. /**
  24717. * @hidden ModelShape of this particle (Internal use)
  24718. */
  24719. _model: ModelShape;
  24720. /**
  24721. * ModelShape id of this particle
  24722. */
  24723. shapeId: number;
  24724. /**
  24725. * Index of the particle in its shape id (Internal use)
  24726. */
  24727. idxInShape: number;
  24728. /**
  24729. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24730. */
  24731. _modelBoundingInfo: BoundingInfo;
  24732. /**
  24733. * @hidden Particle BoundingInfo object (Internal use)
  24734. */
  24735. _boundingInfo: BoundingInfo;
  24736. /**
  24737. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24738. */
  24739. _sps: SolidParticleSystem;
  24740. /**
  24741. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24742. */
  24743. _stillInvisible: boolean;
  24744. /**
  24745. * @hidden Last computed particle rotation matrix
  24746. */
  24747. _rotationMatrix: number[];
  24748. /**
  24749. * Parent particle Id, if any.
  24750. * Default null.
  24751. */
  24752. parentId: Nullable<number>;
  24753. /**
  24754. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24755. * The possible values are :
  24756. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24757. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24759. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24760. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24761. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24762. * */
  24763. cullingStrategy: number;
  24764. /**
  24765. * @hidden Internal global position in the SPS.
  24766. */
  24767. _globalPosition: Vector3;
  24768. /**
  24769. * Creates a Solid Particle object.
  24770. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24771. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24772. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24773. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24774. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24775. * @param shapeId (integer) is the model shape identifier in the SPS.
  24776. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24777. * @param sps defines the sps it is associated to
  24778. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24779. */
  24780. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24781. /**
  24782. * Legacy support, changed scale to scaling
  24783. */
  24784. /**
  24785. * Legacy support, changed scale to scaling
  24786. */
  24787. scale: Vector3;
  24788. /**
  24789. * Legacy support, changed quaternion to rotationQuaternion
  24790. */
  24791. /**
  24792. * Legacy support, changed quaternion to rotationQuaternion
  24793. */
  24794. quaternion: Nullable<Quaternion>;
  24795. /**
  24796. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24797. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24798. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24799. * @returns true if it intersects
  24800. */
  24801. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24802. /**
  24803. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24804. * A particle is in the frustum if its bounding box intersects the frustum
  24805. * @param frustumPlanes defines the frustum to test
  24806. * @returns true if the particle is in the frustum planes
  24807. */
  24808. isInFrustum(frustumPlanes: Plane[]): boolean;
  24809. /**
  24810. * get the rotation matrix of the particle
  24811. * @hidden
  24812. */
  24813. getRotationMatrix(m: Matrix): void;
  24814. }
  24815. /**
  24816. * Represents the shape of the model used by one particle of a solid particle system.
  24817. * SPS internal tool, don't use it manually.
  24818. */
  24819. export class ModelShape {
  24820. /**
  24821. * The shape id
  24822. * @hidden
  24823. */
  24824. shapeID: number;
  24825. /**
  24826. * flat array of model positions (internal use)
  24827. * @hidden
  24828. */
  24829. _shape: Vector3[];
  24830. /**
  24831. * flat array of model UVs (internal use)
  24832. * @hidden
  24833. */
  24834. _shapeUV: number[];
  24835. /**
  24836. * length of the shape in the model indices array (internal use)
  24837. * @hidden
  24838. */
  24839. _indicesLength: number;
  24840. /**
  24841. * Custom position function (internal use)
  24842. * @hidden
  24843. */
  24844. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24845. /**
  24846. * Custom vertex function (internal use)
  24847. * @hidden
  24848. */
  24849. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24850. /**
  24851. * 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.
  24852. * SPS internal tool, don't use it manually.
  24853. * @hidden
  24854. */
  24855. 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>);
  24856. }
  24857. /**
  24858. * Represents a Depth Sorted Particle in the solid particle system.
  24859. */
  24860. export class DepthSortedParticle {
  24861. /**
  24862. * Index of the particle in the "indices" array
  24863. */
  24864. ind: number;
  24865. /**
  24866. * Length of the particle shape in the "indices" array
  24867. */
  24868. indicesLength: number;
  24869. /**
  24870. * Squared distance from the particle to the camera
  24871. */
  24872. sqDistance: number;
  24873. }
  24874. }
  24875. declare module "babylonjs/Meshes/abstractMesh" {
  24876. import { Observable } from "babylonjs/Misc/observable";
  24877. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24878. import { Camera } from "babylonjs/Cameras/camera";
  24879. import { Scene, IDisposable } from "babylonjs/scene";
  24880. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24881. import { Node } from "babylonjs/node";
  24882. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24883. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24885. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24886. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24887. import { Material } from "babylonjs/Materials/material";
  24888. import { Light } from "babylonjs/Lights/light";
  24889. import { Skeleton } from "babylonjs/Bones/skeleton";
  24890. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24891. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24892. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24893. import { Ray } from "babylonjs/Culling/ray";
  24894. import { Collider } from "babylonjs/Collisions/collider";
  24895. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24896. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24897. /**
  24898. * Class used to store all common mesh properties
  24899. */
  24900. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24901. /** No occlusion */
  24902. static OCCLUSION_TYPE_NONE: number;
  24903. /** Occlusion set to optimisitic */
  24904. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24905. /** Occlusion set to strict */
  24906. static OCCLUSION_TYPE_STRICT: number;
  24907. /** Use an accurante occlusion algorithm */
  24908. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24909. /** Use a conservative occlusion algorithm */
  24910. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24911. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24912. * Test order :
  24913. * Is the bounding sphere outside the frustum ?
  24914. * If not, are the bounding box vertices outside the frustum ?
  24915. * It not, then the cullable object is in the frustum.
  24916. */
  24917. static readonly CULLINGSTRATEGY_STANDARD: number;
  24918. /** Culling strategy : Bounding Sphere Only.
  24919. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24920. * It's also less accurate than the standard because some not visible objects can still be selected.
  24921. * Test : is the bounding sphere outside the frustum ?
  24922. * If not, then the cullable object is in the frustum.
  24923. */
  24924. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24925. /** Culling strategy : Optimistic Inclusion.
  24926. * This in an inclusion test first, then the standard exclusion test.
  24927. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24928. * 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.
  24929. * Anyway, it's as accurate as the standard strategy.
  24930. * Test :
  24931. * Is the cullable object bounding sphere center in the frustum ?
  24932. * If not, apply the default culling strategy.
  24933. */
  24934. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24935. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24936. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24937. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24938. * 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.
  24939. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24940. * Test :
  24941. * Is the cullable object bounding sphere center in the frustum ?
  24942. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24943. */
  24944. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24945. /**
  24946. * No billboard
  24947. */
  24948. static readonly BILLBOARDMODE_NONE: number;
  24949. /** Billboard on X axis */
  24950. static readonly BILLBOARDMODE_X: number;
  24951. /** Billboard on Y axis */
  24952. static readonly BILLBOARDMODE_Y: number;
  24953. /** Billboard on Z axis */
  24954. static readonly BILLBOARDMODE_Z: number;
  24955. /** Billboard on all axes */
  24956. static readonly BILLBOARDMODE_ALL: number;
  24957. private _facetData;
  24958. /**
  24959. * The culling strategy to use to check whether the mesh must be rendered or not.
  24960. * This value can be changed at any time and will be used on the next render mesh selection.
  24961. * The possible values are :
  24962. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24963. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24966. * Please read each static variable documentation to get details about the culling process.
  24967. * */
  24968. cullingStrategy: number;
  24969. /**
  24970. * Gets the number of facets in the mesh
  24971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24972. */
  24973. readonly facetNb: number;
  24974. /**
  24975. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24977. */
  24978. partitioningSubdivisions: number;
  24979. /**
  24980. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24981. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24983. */
  24984. partitioningBBoxRatio: number;
  24985. /**
  24986. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24987. * Works only for updatable meshes.
  24988. * Doesn't work with multi-materials
  24989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24990. */
  24991. mustDepthSortFacets: boolean;
  24992. /**
  24993. * The location (Vector3) where the facet depth sort must be computed from.
  24994. * By default, the active camera position.
  24995. * Used only when facet depth sort is enabled
  24996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24997. */
  24998. facetDepthSortFrom: Vector3;
  24999. /**
  25000. * gets a boolean indicating if facetData is enabled
  25001. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25002. */
  25003. readonly isFacetDataEnabled: boolean;
  25004. /** @hidden */
  25005. _updateNonUniformScalingState(value: boolean): boolean;
  25006. /**
  25007. * An event triggered when this mesh collides with another one
  25008. */
  25009. onCollideObservable: Observable<AbstractMesh>;
  25010. private _onCollideObserver;
  25011. /** Set a function to call when this mesh collides with another one */
  25012. onCollide: () => void;
  25013. /**
  25014. * An event triggered when the collision's position changes
  25015. */
  25016. onCollisionPositionChangeObservable: Observable<Vector3>;
  25017. private _onCollisionPositionChangeObserver;
  25018. /** Set a function to call when the collision's position changes */
  25019. onCollisionPositionChange: () => void;
  25020. /**
  25021. * An event triggered when material is changed
  25022. */
  25023. onMaterialChangedObservable: Observable<AbstractMesh>;
  25024. /**
  25025. * Gets or sets the orientation for POV movement & rotation
  25026. */
  25027. definedFacingForward: boolean;
  25028. /** @hidden */
  25029. _occlusionQuery: Nullable<WebGLQuery>;
  25030. private _visibility;
  25031. /** @hidden */
  25032. _isActive: boolean;
  25033. /** @hidden */
  25034. _onlyForInstances: boolean;
  25035. /** @hidden */
  25036. _renderingGroup: Nullable<RenderingGroup>;
  25037. /**
  25038. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25039. */
  25040. /**
  25041. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25042. */
  25043. visibility: number;
  25044. /** Gets or sets the alpha index used to sort transparent meshes
  25045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25046. */
  25047. alphaIndex: number;
  25048. /**
  25049. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25050. */
  25051. isVisible: boolean;
  25052. /**
  25053. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25054. */
  25055. isPickable: boolean;
  25056. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25057. showSubMeshesBoundingBox: boolean;
  25058. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25060. */
  25061. isBlocker: boolean;
  25062. /**
  25063. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25064. */
  25065. enablePointerMoveEvents: boolean;
  25066. /**
  25067. * Specifies the rendering group id for this mesh (0 by default)
  25068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25069. */
  25070. renderingGroupId: number;
  25071. private _material;
  25072. /** Gets or sets current material */
  25073. material: Nullable<Material>;
  25074. private _receiveShadows;
  25075. /**
  25076. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25077. * @see http://doc.babylonjs.com/babylon101/shadows
  25078. */
  25079. receiveShadows: boolean;
  25080. /** Defines color to use when rendering outline */
  25081. outlineColor: Color3;
  25082. /** Define width to use when rendering outline */
  25083. outlineWidth: number;
  25084. /** Defines color to use when rendering overlay */
  25085. overlayColor: Color3;
  25086. /** Defines alpha to use when rendering overlay */
  25087. overlayAlpha: number;
  25088. private _hasVertexAlpha;
  25089. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25090. hasVertexAlpha: boolean;
  25091. private _useVertexColors;
  25092. /** 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) */
  25093. useVertexColors: boolean;
  25094. private _computeBonesUsingShaders;
  25095. /**
  25096. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25097. */
  25098. computeBonesUsingShaders: boolean;
  25099. private _numBoneInfluencers;
  25100. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25101. numBoneInfluencers: number;
  25102. private _applyFog;
  25103. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25104. applyFog: boolean;
  25105. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25106. useOctreeForRenderingSelection: boolean;
  25107. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25108. useOctreeForPicking: boolean;
  25109. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25110. useOctreeForCollisions: boolean;
  25111. private _layerMask;
  25112. /**
  25113. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25114. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25115. */
  25116. layerMask: number;
  25117. /**
  25118. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25119. */
  25120. alwaysSelectAsActiveMesh: boolean;
  25121. /**
  25122. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25123. */
  25124. doNotSyncBoundingInfo: boolean;
  25125. /**
  25126. * Gets or sets the current action manager
  25127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25128. */
  25129. actionManager: Nullable<AbstractActionManager>;
  25130. private _checkCollisions;
  25131. private _collisionMask;
  25132. private _collisionGroup;
  25133. /**
  25134. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25136. */
  25137. ellipsoid: Vector3;
  25138. /**
  25139. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25141. */
  25142. ellipsoidOffset: Vector3;
  25143. private _collider;
  25144. private _oldPositionForCollisions;
  25145. private _diffPositionForCollisions;
  25146. /**
  25147. * Gets or sets a collision mask used to mask collisions (default is -1).
  25148. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25149. */
  25150. collisionMask: number;
  25151. /**
  25152. * Gets or sets the current collision group mask (-1 by default).
  25153. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25154. */
  25155. collisionGroup: number;
  25156. /**
  25157. * Defines edge width used when edgesRenderer is enabled
  25158. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25159. */
  25160. edgesWidth: number;
  25161. /**
  25162. * Defines edge color used when edgesRenderer is enabled
  25163. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25164. */
  25165. edgesColor: Color4;
  25166. /** @hidden */
  25167. _edgesRenderer: Nullable<IEdgesRenderer>;
  25168. /** @hidden */
  25169. _masterMesh: Nullable<AbstractMesh>;
  25170. /** @hidden */
  25171. _boundingInfo: Nullable<BoundingInfo>;
  25172. /** @hidden */
  25173. _renderId: number;
  25174. /**
  25175. * Gets or sets the list of subMeshes
  25176. * @see http://doc.babylonjs.com/how_to/multi_materials
  25177. */
  25178. subMeshes: SubMesh[];
  25179. /** @hidden */
  25180. _intersectionsInProgress: AbstractMesh[];
  25181. /** @hidden */
  25182. _unIndexed: boolean;
  25183. /** @hidden */
  25184. _lightSources: Light[];
  25185. /** Gets the list of lights affecting that mesh */
  25186. readonly lightSources: Light[];
  25187. /** @hidden */
  25188. readonly _positions: Nullable<Vector3[]>;
  25189. /** @hidden */
  25190. _waitingData: {
  25191. lods: Nullable<any>;
  25192. actions: Nullable<any>;
  25193. freezeWorldMatrix: Nullable<boolean>;
  25194. };
  25195. private _skeleton;
  25196. /** @hidden */
  25197. _bonesTransformMatrices: Nullable<Float32Array>;
  25198. /**
  25199. * Gets or sets a skeleton to apply skining transformations
  25200. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25201. */
  25202. skeleton: Nullable<Skeleton>;
  25203. /**
  25204. * An event triggered when the mesh is rebuilt.
  25205. */
  25206. onRebuildObservable: Observable<AbstractMesh>;
  25207. /**
  25208. * Creates a new AbstractMesh
  25209. * @param name defines the name of the mesh
  25210. * @param scene defines the hosting scene
  25211. */
  25212. constructor(name: string, scene?: Nullable<Scene>);
  25213. /**
  25214. * Returns the string "AbstractMesh"
  25215. * @returns "AbstractMesh"
  25216. */
  25217. getClassName(): string;
  25218. /**
  25219. * Gets a string representation of the current mesh
  25220. * @param fullDetails defines a boolean indicating if full details must be included
  25221. * @returns a string representation of the current mesh
  25222. */
  25223. toString(fullDetails?: boolean): string;
  25224. /**
  25225. * @hidden
  25226. */
  25227. protected _getEffectiveParent(): Nullable<Node>;
  25228. /** @hidden */
  25229. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25230. /** @hidden */
  25231. _rebuild(): void;
  25232. /** @hidden */
  25233. _resyncLightSources(): void;
  25234. /** @hidden */
  25235. _resyncLighSource(light: Light): void;
  25236. /** @hidden */
  25237. _unBindEffect(): void;
  25238. /** @hidden */
  25239. _removeLightSource(light: Light): void;
  25240. private _markSubMeshesAsDirty;
  25241. /** @hidden */
  25242. _markSubMeshesAsLightDirty(): void;
  25243. /** @hidden */
  25244. _markSubMeshesAsAttributesDirty(): void;
  25245. /** @hidden */
  25246. _markSubMeshesAsMiscDirty(): void;
  25247. /**
  25248. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25249. */
  25250. scaling: Vector3;
  25251. /**
  25252. * Returns true if the mesh is blocked. Implemented by child classes
  25253. */
  25254. readonly isBlocked: boolean;
  25255. /**
  25256. * Returns the mesh itself by default. Implemented by child classes
  25257. * @param camera defines the camera to use to pick the right LOD level
  25258. * @returns the currentAbstractMesh
  25259. */
  25260. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25261. /**
  25262. * Returns 0 by default. Implemented by child classes
  25263. * @returns an integer
  25264. */
  25265. getTotalVertices(): number;
  25266. /**
  25267. * Returns a positive integer : the total number of indices in this mesh geometry.
  25268. * @returns the numner of indices or zero if the mesh has no geometry.
  25269. */
  25270. getTotalIndices(): number;
  25271. /**
  25272. * Returns null by default. Implemented by child classes
  25273. * @returns null
  25274. */
  25275. getIndices(): Nullable<IndicesArray>;
  25276. /**
  25277. * Returns the array of the requested vertex data kind. Implemented by child classes
  25278. * @param kind defines the vertex data kind to use
  25279. * @returns null
  25280. */
  25281. getVerticesData(kind: string): Nullable<FloatArray>;
  25282. /**
  25283. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25284. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25285. * Note that a new underlying VertexBuffer object is created each call.
  25286. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25287. * @param kind defines vertex data kind:
  25288. * * VertexBuffer.PositionKind
  25289. * * VertexBuffer.UVKind
  25290. * * VertexBuffer.UV2Kind
  25291. * * VertexBuffer.UV3Kind
  25292. * * VertexBuffer.UV4Kind
  25293. * * VertexBuffer.UV5Kind
  25294. * * VertexBuffer.UV6Kind
  25295. * * VertexBuffer.ColorKind
  25296. * * VertexBuffer.MatricesIndicesKind
  25297. * * VertexBuffer.MatricesIndicesExtraKind
  25298. * * VertexBuffer.MatricesWeightsKind
  25299. * * VertexBuffer.MatricesWeightsExtraKind
  25300. * @param data defines the data source
  25301. * @param updatable defines if the data must be flagged as updatable (or static)
  25302. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  25303. * @returns the current mesh
  25304. */
  25305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25306. /**
  25307. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25308. * If the mesh has no geometry, it is simply returned as it is.
  25309. * @param kind defines vertex data kind:
  25310. * * VertexBuffer.PositionKind
  25311. * * VertexBuffer.UVKind
  25312. * * VertexBuffer.UV2Kind
  25313. * * VertexBuffer.UV3Kind
  25314. * * VertexBuffer.UV4Kind
  25315. * * VertexBuffer.UV5Kind
  25316. * * VertexBuffer.UV6Kind
  25317. * * VertexBuffer.ColorKind
  25318. * * VertexBuffer.MatricesIndicesKind
  25319. * * VertexBuffer.MatricesIndicesExtraKind
  25320. * * VertexBuffer.MatricesWeightsKind
  25321. * * VertexBuffer.MatricesWeightsExtraKind
  25322. * @param data defines the data source
  25323. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  25324. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25325. * @returns the current mesh
  25326. */
  25327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25328. /**
  25329. * Sets the mesh indices,
  25330. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25331. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25332. * @param totalVertices Defines the total number of vertices
  25333. * @returns the current mesh
  25334. */
  25335. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25336. /**
  25337. * Gets a boolean indicating if specific vertex data is present
  25338. * @param kind defines the vertex data kind to use
  25339. * @returns true is data kind is present
  25340. */
  25341. isVerticesDataPresent(kind: string): boolean;
  25342. /**
  25343. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25344. * @returns a BoundingInfo
  25345. */
  25346. getBoundingInfo(): BoundingInfo;
  25347. /**
  25348. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25349. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25350. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25351. * @returns the current mesh
  25352. */
  25353. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25354. /**
  25355. * Overwrite the current bounding info
  25356. * @param boundingInfo defines the new bounding info
  25357. * @returns the current mesh
  25358. */
  25359. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25360. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25361. readonly useBones: boolean;
  25362. /** @hidden */
  25363. _preActivate(): void;
  25364. /** @hidden */
  25365. _preActivateForIntermediateRendering(renderId: number): void;
  25366. /** @hidden */
  25367. _activate(renderId: number): boolean;
  25368. /** @hidden */
  25369. _postActivate(): void;
  25370. /** @hidden */
  25371. _freeze(): void;
  25372. /** @hidden */
  25373. _unFreeze(): void;
  25374. /**
  25375. * Gets the current world matrix
  25376. * @returns a Matrix
  25377. */
  25378. getWorldMatrix(): Matrix;
  25379. /** @hidden */
  25380. _getWorldMatrixDeterminant(): number;
  25381. /**
  25382. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25383. */
  25384. readonly isAnInstance: boolean;
  25385. /**
  25386. * Perform relative position change from the point of view of behind the front of the mesh.
  25387. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25388. * Supports definition of mesh facing forward or backward
  25389. * @param amountRight defines the distance on the right axis
  25390. * @param amountUp defines the distance on the up axis
  25391. * @param amountForward defines the distance on the forward axis
  25392. * @returns the current mesh
  25393. */
  25394. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25395. /**
  25396. * Calculate relative position change from the point of view of behind the front of the mesh.
  25397. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25398. * Supports definition of mesh facing forward or backward
  25399. * @param amountRight defines the distance on the right axis
  25400. * @param amountUp defines the distance on the up axis
  25401. * @param amountForward defines the distance on the forward axis
  25402. * @returns the new displacement vector
  25403. */
  25404. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25405. /**
  25406. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25407. * Supports definition of mesh facing forward or backward
  25408. * @param flipBack defines the flip
  25409. * @param twirlClockwise defines the twirl
  25410. * @param tiltRight defines the tilt
  25411. * @returns the current mesh
  25412. */
  25413. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25414. /**
  25415. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25416. * Supports definition of mesh facing forward or backward.
  25417. * @param flipBack defines the flip
  25418. * @param twirlClockwise defines the twirl
  25419. * @param tiltRight defines the tilt
  25420. * @returns the new rotation vector
  25421. */
  25422. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25423. /**
  25424. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25425. * This means the mesh underlying bounding box and sphere are recomputed.
  25426. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25427. * @returns the current mesh
  25428. */
  25429. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25430. /** @hidden */
  25431. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25432. /** @hidden */
  25433. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25434. /** @hidden */
  25435. _updateBoundingInfo(): AbstractMesh;
  25436. /** @hidden */
  25437. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25438. /** @hidden */
  25439. protected _afterComputeWorldMatrix(): void;
  25440. /** @hidden */
  25441. readonly _effectiveMesh: AbstractMesh;
  25442. /**
  25443. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25444. * A mesh is in the frustum if its bounding box intersects the frustum
  25445. * @param frustumPlanes defines the frustum to test
  25446. * @returns true if the mesh is in the frustum planes
  25447. */
  25448. isInFrustum(frustumPlanes: Plane[]): boolean;
  25449. /**
  25450. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25451. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25452. * @param frustumPlanes defines the frustum to test
  25453. * @returns true if the mesh is completely in the frustum planes
  25454. */
  25455. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25456. /**
  25457. * True if the mesh intersects another mesh or a SolidParticle object
  25458. * @param mesh defines a target mesh or SolidParticle to test
  25459. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  25460. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25461. * @returns true if there is an intersection
  25462. */
  25463. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25464. /**
  25465. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25466. * @param point defines the point to test
  25467. * @returns true if there is an intersection
  25468. */
  25469. intersectsPoint(point: Vector3): boolean;
  25470. /**
  25471. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25473. */
  25474. checkCollisions: boolean;
  25475. /**
  25476. * Gets Collider object used to compute collisions (not physics)
  25477. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25478. */
  25479. readonly collider: Nullable<Collider>;
  25480. /**
  25481. * Move the mesh using collision engine
  25482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25483. * @param displacement defines the requested displacement vector
  25484. * @returns the current mesh
  25485. */
  25486. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25487. private _onCollisionPositionChange;
  25488. /** @hidden */
  25489. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25490. /** @hidden */
  25491. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25492. /** @hidden */
  25493. _checkCollision(collider: Collider): AbstractMesh;
  25494. /** @hidden */
  25495. _generatePointsArray(): boolean;
  25496. /**
  25497. * Checks if the passed Ray intersects with the mesh
  25498. * @param ray defines the ray to use
  25499. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25501. * @returns the picking info
  25502. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25503. */
  25504. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25505. /**
  25506. * Clones the current mesh
  25507. * @param name defines the mesh name
  25508. * @param newParent defines the new mesh parent
  25509. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25510. * @returns the new mesh
  25511. */
  25512. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25513. /**
  25514. * Disposes all the submeshes of the current meshnp
  25515. * @returns the current mesh
  25516. */
  25517. releaseSubMeshes(): AbstractMesh;
  25518. /**
  25519. * Releases resources associated with this abstract mesh.
  25520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25522. */
  25523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25524. /**
  25525. * Adds the passed mesh as a child to the current mesh
  25526. * @param mesh defines the child mesh
  25527. * @returns the current mesh
  25528. */
  25529. addChild(mesh: AbstractMesh): AbstractMesh;
  25530. /**
  25531. * Removes the passed mesh from the current mesh children list
  25532. * @param mesh defines the child mesh
  25533. * @returns the current mesh
  25534. */
  25535. removeChild(mesh: AbstractMesh): AbstractMesh;
  25536. /** @hidden */
  25537. private _initFacetData;
  25538. /**
  25539. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25540. * This method can be called within the render loop.
  25541. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  25542. * @returns the current mesh
  25543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25544. */
  25545. updateFacetData(): AbstractMesh;
  25546. /**
  25547. * Returns the facetLocalNormals array.
  25548. * The normals are expressed in the mesh local spac
  25549. * @returns an array of Vector3
  25550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25551. */
  25552. getFacetLocalNormals(): Vector3[];
  25553. /**
  25554. * Returns the facetLocalPositions array.
  25555. * The facet positions are expressed in the mesh local space
  25556. * @returns an array of Vector3
  25557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25558. */
  25559. getFacetLocalPositions(): Vector3[];
  25560. /**
  25561. * Returns the facetLocalPartioning array
  25562. * @returns an array of array of numbers
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25564. */
  25565. getFacetLocalPartitioning(): number[][];
  25566. /**
  25567. * Returns the i-th facet position in the world system.
  25568. * This method allocates a new Vector3 per call
  25569. * @param i defines the facet index
  25570. * @returns a new Vector3
  25571. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25572. */
  25573. getFacetPosition(i: number): Vector3;
  25574. /**
  25575. * Sets the reference Vector3 with the i-th facet position in the world system
  25576. * @param i defines the facet index
  25577. * @param ref defines the target vector
  25578. * @returns the current mesh
  25579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25580. */
  25581. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25582. /**
  25583. * Returns the i-th facet normal in the world system.
  25584. * This method allocates a new Vector3 per call
  25585. * @param i defines the facet index
  25586. * @returns a new Vector3
  25587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25588. */
  25589. getFacetNormal(i: number): Vector3;
  25590. /**
  25591. * Sets the reference Vector3 with the i-th facet normal in the world system
  25592. * @param i defines the facet index
  25593. * @param ref defines the target vector
  25594. * @returns the current mesh
  25595. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25596. */
  25597. getFacetNormalToRef(i: number, ref: Vector3): this;
  25598. /**
  25599. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  25600. * @param x defines x coordinate
  25601. * @param y defines y coordinate
  25602. * @param z defines z coordinate
  25603. * @returns the array of facet indexes
  25604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25605. */
  25606. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25607. /**
  25608. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25609. * @param projected sets as the (x,y,z) world projection on the facet
  25610. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  25611. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  25612. * @param x defines x coordinate
  25613. * @param y defines y coordinate
  25614. * @param z defines z coordinate
  25615. * @returns the face index if found (or null instead)
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25619. /**
  25620. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25621. * @param projected sets as the (x,y,z) local projection on the facet
  25622. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  25623. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  25624. * @param x defines x coordinate
  25625. * @param y defines y coordinate
  25626. * @param z defines z coordinate
  25627. * @returns the face index if found (or null instead)
  25628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25629. */
  25630. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25631. /**
  25632. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25633. * @returns the parameters
  25634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25635. */
  25636. getFacetDataParameters(): any;
  25637. /**
  25638. * Disables the feature FacetData and frees the related memory
  25639. * @returns the current mesh
  25640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25641. */
  25642. disableFacetData(): AbstractMesh;
  25643. /**
  25644. * Updates the AbstractMesh indices array
  25645. * @param indices defines the data source
  25646. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25647. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25648. * @returns the current mesh
  25649. */
  25650. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25651. /**
  25652. * Creates new normals data for the mesh
  25653. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25654. * @returns the current mesh
  25655. */
  25656. createNormals(updatable: boolean): AbstractMesh;
  25657. /**
  25658. * Align the mesh with a normal
  25659. * @param normal defines the normal to use
  25660. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25661. * @returns the current mesh
  25662. */
  25663. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25664. /** @hidden */
  25665. _checkOcclusionQuery(): boolean;
  25666. }
  25667. }
  25668. declare module "babylonjs/Actions/actionEvent" {
  25669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25670. import { Nullable } from "babylonjs/types";
  25671. import { Sprite } from "babylonjs/Sprites/sprite";
  25672. import { Scene } from "babylonjs/scene";
  25673. import { Vector2 } from "babylonjs/Maths/math";
  25674. /**
  25675. * Interface used to define ActionEvent
  25676. */
  25677. export interface IActionEvent {
  25678. /** The mesh or sprite that triggered the action */
  25679. source: any;
  25680. /** The X mouse cursor position at the time of the event */
  25681. pointerX: number;
  25682. /** The Y mouse cursor position at the time of the event */
  25683. pointerY: number;
  25684. /** The mesh that is currently pointed at (can be null) */
  25685. meshUnderPointer: Nullable<AbstractMesh>;
  25686. /** the original (browser) event that triggered the ActionEvent */
  25687. sourceEvent?: any;
  25688. /** additional data for the event */
  25689. additionalData?: any;
  25690. }
  25691. /**
  25692. * ActionEvent is the event being sent when an action is triggered.
  25693. */
  25694. export class ActionEvent implements IActionEvent {
  25695. /** The mesh or sprite that triggered the action */
  25696. source: any;
  25697. /** The X mouse cursor position at the time of the event */
  25698. pointerX: number;
  25699. /** The Y mouse cursor position at the time of the event */
  25700. pointerY: number;
  25701. /** The mesh that is currently pointed at (can be null) */
  25702. meshUnderPointer: Nullable<AbstractMesh>;
  25703. /** the original (browser) event that triggered the ActionEvent */
  25704. sourceEvent?: any;
  25705. /** additional data for the event */
  25706. additionalData?: any;
  25707. /**
  25708. * Creates a new ActionEvent
  25709. * @param source The mesh or sprite that triggered the action
  25710. * @param pointerX The X mouse cursor position at the time of the event
  25711. * @param pointerY The Y mouse cursor position at the time of the event
  25712. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25713. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25714. * @param additionalData additional data for the event
  25715. */
  25716. constructor(
  25717. /** The mesh or sprite that triggered the action */
  25718. source: any,
  25719. /** The X mouse cursor position at the time of the event */
  25720. pointerX: number,
  25721. /** The Y mouse cursor position at the time of the event */
  25722. pointerY: number,
  25723. /** The mesh that is currently pointed at (can be null) */
  25724. meshUnderPointer: Nullable<AbstractMesh>,
  25725. /** the original (browser) event that triggered the ActionEvent */
  25726. sourceEvent?: any,
  25727. /** additional data for the event */
  25728. additionalData?: any);
  25729. /**
  25730. * Helper function to auto-create an ActionEvent from a source mesh.
  25731. * @param source The source mesh that triggered the event
  25732. * @param evt The original (browser) event
  25733. * @param additionalData additional data for the event
  25734. * @returns the new ActionEvent
  25735. */
  25736. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25737. /**
  25738. * Helper function to auto-create an ActionEvent from a source sprite
  25739. * @param source The source sprite that triggered the event
  25740. * @param scene Scene associated with the sprite
  25741. * @param evt The original (browser) event
  25742. * @param additionalData additional data for the event
  25743. * @returns the new ActionEvent
  25744. */
  25745. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25746. /**
  25747. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25748. * @param scene the scene where the event occurred
  25749. * @param evt The original (browser) event
  25750. * @returns the new ActionEvent
  25751. */
  25752. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25753. /**
  25754. * Helper function to auto-create an ActionEvent from a primitive
  25755. * @param prim defines the target primitive
  25756. * @param pointerPos defines the pointer position
  25757. * @param evt The original (browser) event
  25758. * @param additionalData additional data for the event
  25759. * @returns the new ActionEvent
  25760. */
  25761. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25762. }
  25763. }
  25764. declare module "babylonjs/Actions/abstractActionManager" {
  25765. import { IDisposable } from "babylonjs/scene";
  25766. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25767. import { IAction } from "babylonjs/Actions/action";
  25768. import { Nullable } from "babylonjs/types";
  25769. /**
  25770. * Abstract class used to decouple action Manager from scene and meshes.
  25771. * Do not instantiate.
  25772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25773. */
  25774. export abstract class AbstractActionManager implements IDisposable {
  25775. /** Gets the list of active triggers */
  25776. static Triggers: {
  25777. [key: string]: number;
  25778. };
  25779. /** Gets the cursor to use when hovering items */
  25780. hoverCursor: string;
  25781. /** Gets the list of actions */
  25782. actions: IAction[];
  25783. /**
  25784. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25785. */
  25786. isRecursive: boolean;
  25787. /**
  25788. * Releases all associated resources
  25789. */
  25790. abstract dispose(): void;
  25791. /**
  25792. * Does this action manager has pointer triggers
  25793. */
  25794. abstract readonly hasPointerTriggers: boolean;
  25795. /**
  25796. * Does this action manager has pick triggers
  25797. */
  25798. abstract readonly hasPickTriggers: boolean;
  25799. /**
  25800. * Process a specific trigger
  25801. * @param trigger defines the trigger to process
  25802. * @param evt defines the event details to be processed
  25803. */
  25804. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25805. /**
  25806. * Does this action manager handles actions of any of the given triggers
  25807. * @param triggers defines the triggers to be tested
  25808. * @return a boolean indicating whether one (or more) of the triggers is handled
  25809. */
  25810. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25811. /**
  25812. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25813. * speed.
  25814. * @param triggerA defines the trigger to be tested
  25815. * @param triggerB defines the trigger to be tested
  25816. * @return a boolean indicating whether one (or more) of the triggers is handled
  25817. */
  25818. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25819. /**
  25820. * Does this action manager handles actions of a given trigger
  25821. * @param trigger defines the trigger to be tested
  25822. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25823. * @return whether the trigger is handled
  25824. */
  25825. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25826. /**
  25827. * Serialize this manager to a JSON object
  25828. * @param name defines the property name to store this manager
  25829. * @returns a JSON representation of this manager
  25830. */
  25831. abstract serialize(name: string): any;
  25832. /**
  25833. * Registers an action to this action manager
  25834. * @param action defines the action to be registered
  25835. * @return the action amended (prepared) after registration
  25836. */
  25837. abstract registerAction(action: IAction): Nullable<IAction>;
  25838. /**
  25839. * Unregisters an action to this action manager
  25840. * @param action defines the action to be unregistered
  25841. * @return a boolean indicating whether the action has been unregistered
  25842. */
  25843. abstract unregisterAction(action: IAction): Boolean;
  25844. /**
  25845. * Does exist one action manager with at least one trigger
  25846. **/
  25847. static readonly HasTriggers: boolean;
  25848. /**
  25849. * Does exist one action manager with at least one pick trigger
  25850. **/
  25851. static readonly HasPickTriggers: boolean;
  25852. /**
  25853. * Does exist one action manager that handles actions of a given trigger
  25854. * @param trigger defines the trigger to be tested
  25855. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25856. **/
  25857. static HasSpecificTrigger(trigger: number): boolean;
  25858. }
  25859. }
  25860. declare module "babylonjs/node" {
  25861. import { Scene } from "babylonjs/scene";
  25862. import { Nullable } from "babylonjs/types";
  25863. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25864. import { Engine } from "babylonjs/Engines/engine";
  25865. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25866. import { Observable } from "babylonjs/Misc/observable";
  25867. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25868. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25869. import { Animatable } from "babylonjs/Animations/animatable";
  25870. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25871. import { Animation } from "babylonjs/Animations/animation";
  25872. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25874. /**
  25875. * Defines how a node can be built from a string name.
  25876. */
  25877. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25878. /**
  25879. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25880. */
  25881. export class Node implements IBehaviorAware<Node> {
  25882. /** @hidden */
  25883. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25884. private static _NodeConstructors;
  25885. /**
  25886. * Add a new node constructor
  25887. * @param type defines the type name of the node to construct
  25888. * @param constructorFunc defines the constructor function
  25889. */
  25890. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25891. /**
  25892. * Returns a node constructor based on type name
  25893. * @param type defines the type name
  25894. * @param name defines the new node name
  25895. * @param scene defines the hosting scene
  25896. * @param options defines optional options to transmit to constructors
  25897. * @returns the new constructor or null
  25898. */
  25899. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25900. /**
  25901. * Gets or sets the name of the node
  25902. */
  25903. name: string;
  25904. /**
  25905. * Gets or sets the id of the node
  25906. */
  25907. id: string;
  25908. /**
  25909. * Gets or sets the unique id of the node
  25910. */
  25911. uniqueId: number;
  25912. /**
  25913. * Gets or sets a string used to store user defined state for the node
  25914. */
  25915. state: string;
  25916. /**
  25917. * Gets or sets an object used to store user defined information for the node
  25918. */
  25919. metadata: any;
  25920. /**
  25921. * For internal use only. Please do not use.
  25922. */
  25923. reservedDataStore: any;
  25924. /**
  25925. * List of inspectable custom properties (used by the Inspector)
  25926. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25927. */
  25928. inspectableCustomProperties: IInspectable[];
  25929. /**
  25930. * Gets or sets a boolean used to define if the node must be serialized
  25931. */
  25932. doNotSerialize: boolean;
  25933. /** @hidden */
  25934. _isDisposed: boolean;
  25935. /**
  25936. * Gets a list of Animations associated with the node
  25937. */
  25938. animations: import("babylonjs/Animations/animation").Animation[];
  25939. protected _ranges: {
  25940. [name: string]: Nullable<AnimationRange>;
  25941. };
  25942. /**
  25943. * Callback raised when the node is ready to be used
  25944. */
  25945. onReady: Nullable<(node: Node) => void>;
  25946. private _isEnabled;
  25947. private _isParentEnabled;
  25948. private _isReady;
  25949. /** @hidden */
  25950. _currentRenderId: number;
  25951. private _parentUpdateId;
  25952. /** @hidden */
  25953. _childUpdateId: number;
  25954. /** @hidden */
  25955. _waitingParentId: Nullable<string>;
  25956. /** @hidden */
  25957. _scene: Scene;
  25958. /** @hidden */
  25959. _cache: any;
  25960. private _parentNode;
  25961. private _children;
  25962. /** @hidden */
  25963. _worldMatrix: Matrix;
  25964. /** @hidden */
  25965. _worldMatrixDeterminant: number;
  25966. /** @hidden */
  25967. _worldMatrixDeterminantIsDirty: boolean;
  25968. /** @hidden */
  25969. private _sceneRootNodesIndex;
  25970. /**
  25971. * Gets a boolean indicating if the node has been disposed
  25972. * @returns true if the node was disposed
  25973. */
  25974. isDisposed(): boolean;
  25975. /**
  25976. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25977. * @see https://doc.babylonjs.com/how_to/parenting
  25978. */
  25979. parent: Nullable<Node>;
  25980. private addToSceneRootNodes;
  25981. private removeFromSceneRootNodes;
  25982. private _animationPropertiesOverride;
  25983. /**
  25984. * Gets or sets the animation properties override
  25985. */
  25986. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25987. /**
  25988. * Gets a string idenfifying the name of the class
  25989. * @returns "Node" string
  25990. */
  25991. getClassName(): string;
  25992. /** @hidden */
  25993. readonly _isNode: boolean;
  25994. /**
  25995. * An event triggered when the mesh is disposed
  25996. */
  25997. onDisposeObservable: Observable<Node>;
  25998. private _onDisposeObserver;
  25999. /**
  26000. * Sets a callback that will be raised when the node will be disposed
  26001. */
  26002. onDispose: () => void;
  26003. /**
  26004. * Creates a new Node
  26005. * @param name the name and id to be given to this node
  26006. * @param scene the scene this node will be added to
  26007. * @param addToRootNodes the node will be added to scene.rootNodes
  26008. */
  26009. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26010. /**
  26011. * Gets the scene of the node
  26012. * @returns a scene
  26013. */
  26014. getScene(): Scene;
  26015. /**
  26016. * Gets the engine of the node
  26017. * @returns a Engine
  26018. */
  26019. getEngine(): Engine;
  26020. private _behaviors;
  26021. /**
  26022. * Attach a behavior to the node
  26023. * @see http://doc.babylonjs.com/features/behaviour
  26024. * @param behavior defines the behavior to attach
  26025. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26026. * @returns the current Node
  26027. */
  26028. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26029. /**
  26030. * Remove an attached behavior
  26031. * @see http://doc.babylonjs.com/features/behaviour
  26032. * @param behavior defines the behavior to attach
  26033. * @returns the current Node
  26034. */
  26035. removeBehavior(behavior: Behavior<Node>): Node;
  26036. /**
  26037. * Gets the list of attached behaviors
  26038. * @see http://doc.babylonjs.com/features/behaviour
  26039. */
  26040. readonly behaviors: Behavior<Node>[];
  26041. /**
  26042. * Gets an attached behavior by name
  26043. * @param name defines the name of the behavior to look for
  26044. * @see http://doc.babylonjs.com/features/behaviour
  26045. * @returns null if behavior was not found else the requested behavior
  26046. */
  26047. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26048. /**
  26049. * Returns the latest update of the World matrix
  26050. * @returns a Matrix
  26051. */
  26052. getWorldMatrix(): Matrix;
  26053. /** @hidden */
  26054. _getWorldMatrixDeterminant(): number;
  26055. /**
  26056. * Returns directly the latest state of the mesh World matrix.
  26057. * A Matrix is returned.
  26058. */
  26059. readonly worldMatrixFromCache: Matrix;
  26060. /** @hidden */
  26061. _initCache(): void;
  26062. /** @hidden */
  26063. updateCache(force?: boolean): void;
  26064. /** @hidden */
  26065. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26066. /** @hidden */
  26067. _updateCache(ignoreParentClass?: boolean): void;
  26068. /** @hidden */
  26069. _isSynchronized(): boolean;
  26070. /** @hidden */
  26071. _markSyncedWithParent(): void;
  26072. /** @hidden */
  26073. isSynchronizedWithParent(): boolean;
  26074. /** @hidden */
  26075. isSynchronized(): boolean;
  26076. /**
  26077. * Is this node ready to be used/rendered
  26078. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26079. * @return true if the node is ready
  26080. */
  26081. isReady(completeCheck?: boolean): boolean;
  26082. /**
  26083. * Is this node enabled?
  26084. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  26085. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  26086. * @return whether this node (and its parent) is enabled
  26087. */
  26088. isEnabled(checkAncestors?: boolean): boolean;
  26089. /** @hidden */
  26090. protected _syncParentEnabledState(): void;
  26091. /**
  26092. * Set the enabled state of this node
  26093. * @param value defines the new enabled state
  26094. */
  26095. setEnabled(value: boolean): void;
  26096. /**
  26097. * Is this node a descendant of the given node?
  26098. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26099. * @param ancestor defines the parent node to inspect
  26100. * @returns a boolean indicating if this node is a descendant of the given node
  26101. */
  26102. isDescendantOf(ancestor: Node): boolean;
  26103. /** @hidden */
  26104. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26105. /**
  26106. * Will return all nodes that have this node as ascendant
  26107. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  26108. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26109. * @return all children nodes of all types
  26110. */
  26111. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26112. /**
  26113. * Get all child-meshes of this node
  26114. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26115. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26116. * @returns an array of AbstractMesh
  26117. */
  26118. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26119. /**
  26120. * Get all direct children of this node
  26121. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26122. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  26123. * @returns an array of Node
  26124. */
  26125. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26126. /** @hidden */
  26127. _setReady(state: boolean): void;
  26128. /**
  26129. * Get an animation by name
  26130. * @param name defines the name of the animation to look for
  26131. * @returns null if not found else the requested animation
  26132. */
  26133. getAnimationByName(name: string): Nullable<Animation>;
  26134. /**
  26135. * Creates an animation range for this node
  26136. * @param name defines the name of the range
  26137. * @param from defines the starting key
  26138. * @param to defines the end key
  26139. */
  26140. createAnimationRange(name: string, from: number, to: number): void;
  26141. /**
  26142. * Delete a specific animation range
  26143. * @param name defines the name of the range to delete
  26144. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26145. */
  26146. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26147. /**
  26148. * Get an animation range by name
  26149. * @param name defines the name of the animation range to look for
  26150. * @returns null if not found else the requested animation range
  26151. */
  26152. getAnimationRange(name: string): Nullable<AnimationRange>;
  26153. /**
  26154. * Gets the list of all animation ranges defined on this node
  26155. * @returns an array
  26156. */
  26157. getAnimationRanges(): Nullable<AnimationRange>[];
  26158. /**
  26159. * Will start the animation sequence
  26160. * @param name defines the range frames for animation sequence
  26161. * @param loop defines if the animation should loop (false by default)
  26162. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26163. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26164. * @returns the object created for this animation. If range does not exist, it will return null
  26165. */
  26166. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26167. /**
  26168. * Serialize animation ranges into a JSON compatible object
  26169. * @returns serialization object
  26170. */
  26171. serializeAnimationRanges(): any;
  26172. /**
  26173. * Computes the world matrix of the node
  26174. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26175. * @returns the world matrix
  26176. */
  26177. computeWorldMatrix(force?: boolean): Matrix;
  26178. /**
  26179. * Releases resources associated with this node.
  26180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26182. */
  26183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26184. /**
  26185. * Parse animation range data from a serialization object and store them into a given node
  26186. * @param node defines where to store the animation ranges
  26187. * @param parsedNode defines the serialization object to read data from
  26188. * @param scene defines the hosting scene
  26189. */
  26190. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26191. /**
  26192. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26193. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26194. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  26195. * @returns the new bounding vectors
  26196. */
  26197. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26198. min: Vector3;
  26199. max: Vector3;
  26200. };
  26201. }
  26202. }
  26203. declare module "babylonjs/Animations/animation" {
  26204. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26205. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26206. import { Nullable } from "babylonjs/types";
  26207. import { Scene } from "babylonjs/scene";
  26208. import { IAnimatable } from "babylonjs/Misc/tools";
  26209. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26210. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26211. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26212. import { Node } from "babylonjs/node";
  26213. import { Animatable } from "babylonjs/Animations/animatable";
  26214. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26215. /**
  26216. * @hidden
  26217. */
  26218. export class _IAnimationState {
  26219. key: number;
  26220. repeatCount: number;
  26221. workValue?: any;
  26222. loopMode?: number;
  26223. offsetValue?: any;
  26224. highLimitValue?: any;
  26225. }
  26226. /**
  26227. * Class used to store any kind of animation
  26228. */
  26229. export class Animation {
  26230. /**Name of the animation */
  26231. name: string;
  26232. /**Property to animate */
  26233. targetProperty: string;
  26234. /**The frames per second of the animation */
  26235. framePerSecond: number;
  26236. /**The data type of the animation */
  26237. dataType: number;
  26238. /**The loop mode of the animation */
  26239. loopMode?: number | undefined;
  26240. /**Specifies if blending should be enabled */
  26241. enableBlending?: boolean | undefined;
  26242. /**
  26243. * Use matrix interpolation instead of using direct key value when animating matrices
  26244. */
  26245. static AllowMatricesInterpolation: boolean;
  26246. /**
  26247. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26248. */
  26249. static AllowMatrixDecomposeForInterpolation: boolean;
  26250. /**
  26251. * Stores the key frames of the animation
  26252. */
  26253. private _keys;
  26254. /**
  26255. * Stores the easing function of the animation
  26256. */
  26257. private _easingFunction;
  26258. /**
  26259. * @hidden Internal use only
  26260. */
  26261. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26262. /**
  26263. * The set of event that will be linked to this animation
  26264. */
  26265. private _events;
  26266. /**
  26267. * Stores an array of target property paths
  26268. */
  26269. targetPropertyPath: string[];
  26270. /**
  26271. * Stores the blending speed of the animation
  26272. */
  26273. blendingSpeed: number;
  26274. /**
  26275. * Stores the animation ranges for the animation
  26276. */
  26277. private _ranges;
  26278. /**
  26279. * @hidden Internal use
  26280. */
  26281. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26282. /**
  26283. * Sets up an animation
  26284. * @param property The property to animate
  26285. * @param animationType The animation type to apply
  26286. * @param framePerSecond The frames per second of the animation
  26287. * @param easingFunction The easing function used in the animation
  26288. * @returns The created animation
  26289. */
  26290. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26291. /**
  26292. * Create and start an animation on a node
  26293. * @param name defines the name of the global animation that will be run on all nodes
  26294. * @param node defines the root node where the animation will take place
  26295. * @param targetProperty defines property to animate
  26296. * @param framePerSecond defines the number of frame per second yo use
  26297. * @param totalFrame defines the number of frames in total
  26298. * @param from defines the initial value
  26299. * @param to defines the final value
  26300. * @param loopMode defines which loop mode you want to use (off by default)
  26301. * @param easingFunction defines the easing function to use (linear by default)
  26302. * @param onAnimationEnd defines the callback to call when animation end
  26303. * @returns the animatable created for this animation
  26304. */
  26305. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26306. /**
  26307. * Create and start an animation on a node and its descendants
  26308. * @param name defines the name of the global animation that will be run on all nodes
  26309. * @param node defines the root node where the animation will take place
  26310. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  26311. * @param targetProperty defines property to animate
  26312. * @param framePerSecond defines the number of frame per second to use
  26313. * @param totalFrame defines the number of frames in total
  26314. * @param from defines the initial value
  26315. * @param to defines the final value
  26316. * @param loopMode defines which loop mode you want to use (off by default)
  26317. * @param easingFunction defines the easing function to use (linear by default)
  26318. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26319. * @returns the list of animatables created for all nodes
  26320. * @example https://www.babylonjs-playground.com/#MH0VLI
  26321. */
  26322. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  26323. /**
  26324. * Creates a new animation, merges it with the existing animations and starts it
  26325. * @param name Name of the animation
  26326. * @param node Node which contains the scene that begins the animations
  26327. * @param targetProperty Specifies which property to animate
  26328. * @param framePerSecond The frames per second of the animation
  26329. * @param totalFrame The total number of frames
  26330. * @param from The frame at the beginning of the animation
  26331. * @param to The frame at the end of the animation
  26332. * @param loopMode Specifies the loop mode of the animation
  26333. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26334. * @param onAnimationEnd Callback to run once the animation is complete
  26335. * @returns Nullable animation
  26336. */
  26337. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26338. /**
  26339. * Transition property of an host to the target Value
  26340. * @param property The property to transition
  26341. * @param targetValue The target Value of the property
  26342. * @param host The object where the property to animate belongs
  26343. * @param scene Scene used to run the animation
  26344. * @param frameRate Framerate (in frame/s) to use
  26345. * @param transition The transition type we want to use
  26346. * @param duration The duration of the animation, in milliseconds
  26347. * @param onAnimationEnd Callback trigger at the end of the animation
  26348. * @returns Nullable animation
  26349. */
  26350. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26351. /**
  26352. * Return the array of runtime animations currently using this animation
  26353. */
  26354. readonly runtimeAnimations: RuntimeAnimation[];
  26355. /**
  26356. * Specifies if any of the runtime animations are currently running
  26357. */
  26358. readonly hasRunningRuntimeAnimations: boolean;
  26359. /**
  26360. * Initializes the animation
  26361. * @param name Name of the animation
  26362. * @param targetProperty Property to animate
  26363. * @param framePerSecond The frames per second of the animation
  26364. * @param dataType The data type of the animation
  26365. * @param loopMode The loop mode of the animation
  26366. * @param enableBlending Specifies if blending should be enabled
  26367. */
  26368. constructor(
  26369. /**Name of the animation */
  26370. name: string,
  26371. /**Property to animate */
  26372. targetProperty: string,
  26373. /**The frames per second of the animation */
  26374. framePerSecond: number,
  26375. /**The data type of the animation */
  26376. dataType: number,
  26377. /**The loop mode of the animation */
  26378. loopMode?: number | undefined,
  26379. /**Specifies if blending should be enabled */
  26380. enableBlending?: boolean | undefined);
  26381. /**
  26382. * Converts the animation to a string
  26383. * @param fullDetails support for multiple levels of logging within scene loading
  26384. * @returns String form of the animation
  26385. */
  26386. toString(fullDetails?: boolean): string;
  26387. /**
  26388. * Add an event to this animation
  26389. * @param event Event to add
  26390. */
  26391. addEvent(event: AnimationEvent): void;
  26392. /**
  26393. * Remove all events found at the given frame
  26394. * @param frame The frame to remove events from
  26395. */
  26396. removeEvents(frame: number): void;
  26397. /**
  26398. * Retrieves all the events from the animation
  26399. * @returns Events from the animation
  26400. */
  26401. getEvents(): AnimationEvent[];
  26402. /**
  26403. * Creates an animation range
  26404. * @param name Name of the animation range
  26405. * @param from Starting frame of the animation range
  26406. * @param to Ending frame of the animation
  26407. */
  26408. createRange(name: string, from: number, to: number): void;
  26409. /**
  26410. * Deletes an animation range by name
  26411. * @param name Name of the animation range to delete
  26412. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26413. */
  26414. deleteRange(name: string, deleteFrames?: boolean): void;
  26415. /**
  26416. * Gets the animation range by name, or null if not defined
  26417. * @param name Name of the animation range
  26418. * @returns Nullable animation range
  26419. */
  26420. getRange(name: string): Nullable<AnimationRange>;
  26421. /**
  26422. * Gets the key frames from the animation
  26423. * @returns The key frames of the animation
  26424. */
  26425. getKeys(): Array<IAnimationKey>;
  26426. /**
  26427. * Gets the highest frame rate of the animation
  26428. * @returns Highest frame rate of the animation
  26429. */
  26430. getHighestFrame(): number;
  26431. /**
  26432. * Gets the easing function of the animation
  26433. * @returns Easing function of the animation
  26434. */
  26435. getEasingFunction(): IEasingFunction;
  26436. /**
  26437. * Sets the easing function of the animation
  26438. * @param easingFunction A custom mathematical formula for animation
  26439. */
  26440. setEasingFunction(easingFunction: EasingFunction): void;
  26441. /**
  26442. * Interpolates a scalar linearly
  26443. * @param startValue Start value of the animation curve
  26444. * @param endValue End value of the animation curve
  26445. * @param gradient Scalar amount to interpolate
  26446. * @returns Interpolated scalar value
  26447. */
  26448. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26449. /**
  26450. * Interpolates a scalar cubically
  26451. * @param startValue Start value of the animation curve
  26452. * @param outTangent End tangent of the animation
  26453. * @param endValue End value of the animation curve
  26454. * @param inTangent Start tangent of the animation curve
  26455. * @param gradient Scalar amount to interpolate
  26456. * @returns Interpolated scalar value
  26457. */
  26458. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26459. /**
  26460. * Interpolates a quaternion using a spherical linear interpolation
  26461. * @param startValue Start value of the animation curve
  26462. * @param endValue End value of the animation curve
  26463. * @param gradient Scalar amount to interpolate
  26464. * @returns Interpolated quaternion value
  26465. */
  26466. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26467. /**
  26468. * Interpolates a quaternion cubically
  26469. * @param startValue Start value of the animation curve
  26470. * @param outTangent End tangent of the animation curve
  26471. * @param endValue End value of the animation curve
  26472. * @param inTangent Start tangent of the animation curve
  26473. * @param gradient Scalar amount to interpolate
  26474. * @returns Interpolated quaternion value
  26475. */
  26476. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26477. /**
  26478. * Interpolates a Vector3 linearl
  26479. * @param startValue Start value of the animation curve
  26480. * @param endValue End value of the animation curve
  26481. * @param gradient Scalar amount to interpolate
  26482. * @returns Interpolated scalar value
  26483. */
  26484. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26485. /**
  26486. * Interpolates a Vector3 cubically
  26487. * @param startValue Start value of the animation curve
  26488. * @param outTangent End tangent of the animation
  26489. * @param endValue End value of the animation curve
  26490. * @param inTangent Start tangent of the animation curve
  26491. * @param gradient Scalar amount to interpolate
  26492. * @returns InterpolatedVector3 value
  26493. */
  26494. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26495. /**
  26496. * Interpolates a Vector2 linearly
  26497. * @param startValue Start value of the animation curve
  26498. * @param endValue End value of the animation curve
  26499. * @param gradient Scalar amount to interpolate
  26500. * @returns Interpolated Vector2 value
  26501. */
  26502. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26503. /**
  26504. * Interpolates a Vector2 cubically
  26505. * @param startValue Start value of the animation curve
  26506. * @param outTangent End tangent of the animation
  26507. * @param endValue End value of the animation curve
  26508. * @param inTangent Start tangent of the animation curve
  26509. * @param gradient Scalar amount to interpolate
  26510. * @returns Interpolated Vector2 value
  26511. */
  26512. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26513. /**
  26514. * Interpolates a size linearly
  26515. * @param startValue Start value of the animation curve
  26516. * @param endValue End value of the animation curve
  26517. * @param gradient Scalar amount to interpolate
  26518. * @returns Interpolated Size value
  26519. */
  26520. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26521. /**
  26522. * Interpolates a Color3 linearly
  26523. * @param startValue Start value of the animation curve
  26524. * @param endValue End value of the animation curve
  26525. * @param gradient Scalar amount to interpolate
  26526. * @returns Interpolated Color3 value
  26527. */
  26528. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26529. /**
  26530. * @hidden Internal use only
  26531. */
  26532. _getKeyValue(value: any): any;
  26533. /**
  26534. * @hidden Internal use only
  26535. */
  26536. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26537. /**
  26538. * Defines the function to use to interpolate matrices
  26539. * @param startValue defines the start matrix
  26540. * @param endValue defines the end matrix
  26541. * @param gradient defines the gradient between both matrices
  26542. * @param result defines an optional target matrix where to store the interpolation
  26543. * @returns the interpolated matrix
  26544. */
  26545. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26546. /**
  26547. * Makes a copy of the animation
  26548. * @returns Cloned animation
  26549. */
  26550. clone(): Animation;
  26551. /**
  26552. * Sets the key frames of the animation
  26553. * @param values The animation key frames to set
  26554. */
  26555. setKeys(values: Array<IAnimationKey>): void;
  26556. /**
  26557. * Serializes the animation to an object
  26558. * @returns Serialized object
  26559. */
  26560. serialize(): any;
  26561. /**
  26562. * Float animation type
  26563. */
  26564. private static _ANIMATIONTYPE_FLOAT;
  26565. /**
  26566. * Vector3 animation type
  26567. */
  26568. private static _ANIMATIONTYPE_VECTOR3;
  26569. /**
  26570. * Quaternion animation type
  26571. */
  26572. private static _ANIMATIONTYPE_QUATERNION;
  26573. /**
  26574. * Matrix animation type
  26575. */
  26576. private static _ANIMATIONTYPE_MATRIX;
  26577. /**
  26578. * Color3 animation type
  26579. */
  26580. private static _ANIMATIONTYPE_COLOR3;
  26581. /**
  26582. * Vector2 animation type
  26583. */
  26584. private static _ANIMATIONTYPE_VECTOR2;
  26585. /**
  26586. * Size animation type
  26587. */
  26588. private static _ANIMATIONTYPE_SIZE;
  26589. /**
  26590. * Relative Loop Mode
  26591. */
  26592. private static _ANIMATIONLOOPMODE_RELATIVE;
  26593. /**
  26594. * Cycle Loop Mode
  26595. */
  26596. private static _ANIMATIONLOOPMODE_CYCLE;
  26597. /**
  26598. * Constant Loop Mode
  26599. */
  26600. private static _ANIMATIONLOOPMODE_CONSTANT;
  26601. /**
  26602. * Get the float animation type
  26603. */
  26604. static readonly ANIMATIONTYPE_FLOAT: number;
  26605. /**
  26606. * Get the Vector3 animation type
  26607. */
  26608. static readonly ANIMATIONTYPE_VECTOR3: number;
  26609. /**
  26610. * Get the Vector2 animation type
  26611. */
  26612. static readonly ANIMATIONTYPE_VECTOR2: number;
  26613. /**
  26614. * Get the Size animation type
  26615. */
  26616. static readonly ANIMATIONTYPE_SIZE: number;
  26617. /**
  26618. * Get the Quaternion animation type
  26619. */
  26620. static readonly ANIMATIONTYPE_QUATERNION: number;
  26621. /**
  26622. * Get the Matrix animation type
  26623. */
  26624. static readonly ANIMATIONTYPE_MATRIX: number;
  26625. /**
  26626. * Get the Color3 animation type
  26627. */
  26628. static readonly ANIMATIONTYPE_COLOR3: number;
  26629. /**
  26630. * Get the Relative Loop Mode
  26631. */
  26632. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26633. /**
  26634. * Get the Cycle Loop Mode
  26635. */
  26636. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26637. /**
  26638. * Get the Constant Loop Mode
  26639. */
  26640. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26641. /** @hidden */
  26642. static _UniversalLerp(left: any, right: any, amount: number): any;
  26643. /**
  26644. * Parses an animation object and creates an animation
  26645. * @param parsedAnimation Parsed animation object
  26646. * @returns Animation object
  26647. */
  26648. static Parse(parsedAnimation: any): Animation;
  26649. /**
  26650. * Appends the serialized animations from the source animations
  26651. * @param source Source containing the animations
  26652. * @param destination Target to store the animations
  26653. */
  26654. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26655. }
  26656. }
  26657. declare module "babylonjs/Materials/Textures/baseTexture" {
  26658. import { Observable } from "babylonjs/Misc/observable";
  26659. import { IAnimatable } from "babylonjs/Misc/tools";
  26660. import { Nullable } from "babylonjs/types";
  26661. import { Scene } from "babylonjs/scene";
  26662. import { Matrix, ISize } from "babylonjs/Maths/math";
  26663. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26665. /**
  26666. * Base class of all the textures in babylon.
  26667. * It groups all the common properties the materials, post process, lights... might need
  26668. * in order to make a correct use of the texture.
  26669. */
  26670. export class BaseTexture implements IAnimatable {
  26671. /**
  26672. * Default anisotropic filtering level for the application.
  26673. * It is set to 4 as a good tradeoff between perf and quality.
  26674. */
  26675. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26676. /**
  26677. * Gets or sets the unique id of the texture
  26678. */
  26679. uniqueId: number;
  26680. /**
  26681. * Define the name of the texture.
  26682. */
  26683. name: string;
  26684. /**
  26685. * Gets or sets an object used to store user defined information.
  26686. */
  26687. metadata: any;
  26688. /**
  26689. * For internal use only. Please do not use.
  26690. */
  26691. reservedDataStore: any;
  26692. private _hasAlpha;
  26693. /**
  26694. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26695. */
  26696. hasAlpha: boolean;
  26697. /**
  26698. * Defines if the alpha value should be determined via the rgb values.
  26699. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26700. */
  26701. getAlphaFromRGB: boolean;
  26702. /**
  26703. * Intensity or strength of the texture.
  26704. * It is commonly used by materials to fine tune the intensity of the texture
  26705. */
  26706. level: number;
  26707. /**
  26708. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26709. * This is part of the texture as textures usually maps to one uv set.
  26710. */
  26711. coordinatesIndex: number;
  26712. private _coordinatesMode;
  26713. /**
  26714. * How a texture is mapped.
  26715. *
  26716. * | Value | Type | Description |
  26717. * | ----- | ----------------------------------- | ----------- |
  26718. * | 0 | EXPLICIT_MODE | |
  26719. * | 1 | SPHERICAL_MODE | |
  26720. * | 2 | PLANAR_MODE | |
  26721. * | 3 | CUBIC_MODE | |
  26722. * | 4 | PROJECTION_MODE | |
  26723. * | 5 | SKYBOX_MODE | |
  26724. * | 6 | INVCUBIC_MODE | |
  26725. * | 7 | EQUIRECTANGULAR_MODE | |
  26726. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26727. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26728. */
  26729. coordinatesMode: number;
  26730. /**
  26731. * | Value | Type | Description |
  26732. * | ----- | ------------------ | ----------- |
  26733. * | 0 | CLAMP_ADDRESSMODE | |
  26734. * | 1 | WRAP_ADDRESSMODE | |
  26735. * | 2 | MIRROR_ADDRESSMODE | |
  26736. */
  26737. wrapU: number;
  26738. /**
  26739. * | Value | Type | Description |
  26740. * | ----- | ------------------ | ----------- |
  26741. * | 0 | CLAMP_ADDRESSMODE | |
  26742. * | 1 | WRAP_ADDRESSMODE | |
  26743. * | 2 | MIRROR_ADDRESSMODE | |
  26744. */
  26745. wrapV: number;
  26746. /**
  26747. * | Value | Type | Description |
  26748. * | ----- | ------------------ | ----------- |
  26749. * | 0 | CLAMP_ADDRESSMODE | |
  26750. * | 1 | WRAP_ADDRESSMODE | |
  26751. * | 2 | MIRROR_ADDRESSMODE | |
  26752. */
  26753. wrapR: number;
  26754. /**
  26755. * With compliant hardware and browser (supporting anisotropic filtering)
  26756. * this defines the level of anisotropic filtering in the texture.
  26757. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26758. */
  26759. anisotropicFilteringLevel: number;
  26760. /**
  26761. * Define if the texture is a cube texture or if false a 2d texture.
  26762. */
  26763. isCube: boolean;
  26764. /**
  26765. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26766. */
  26767. is3D: boolean;
  26768. /**
  26769. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26770. * HDR texture are usually stored in linear space.
  26771. * This only impacts the PBR and Background materials
  26772. */
  26773. gammaSpace: boolean;
  26774. /**
  26775. * Gets whether or not the texture contains RGBD data.
  26776. */
  26777. readonly isRGBD: boolean;
  26778. /**
  26779. * Is Z inverted in the texture (useful in a cube texture).
  26780. */
  26781. invertZ: boolean;
  26782. /**
  26783. * Are mip maps generated for this texture or not.
  26784. */
  26785. readonly noMipmap: boolean;
  26786. /**
  26787. * @hidden
  26788. */
  26789. lodLevelInAlpha: boolean;
  26790. /**
  26791. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26792. */
  26793. lodGenerationOffset: number;
  26794. /**
  26795. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26796. */
  26797. lodGenerationScale: number;
  26798. /**
  26799. * Define if the texture is a render target.
  26800. */
  26801. isRenderTarget: boolean;
  26802. /**
  26803. * Define the unique id of the texture in the scene.
  26804. */
  26805. readonly uid: string;
  26806. /**
  26807. * Return a string representation of the texture.
  26808. * @returns the texture as a string
  26809. */
  26810. toString(): string;
  26811. /**
  26812. * Get the class name of the texture.
  26813. * @returns "BaseTexture"
  26814. */
  26815. getClassName(): string;
  26816. /**
  26817. * Define the list of animation attached to the texture.
  26818. */
  26819. animations: import("babylonjs/Animations/animation").Animation[];
  26820. /**
  26821. * An event triggered when the texture is disposed.
  26822. */
  26823. onDisposeObservable: Observable<BaseTexture>;
  26824. private _onDisposeObserver;
  26825. /**
  26826. * Callback triggered when the texture has been disposed.
  26827. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26828. */
  26829. onDispose: () => void;
  26830. /**
  26831. * Define the current state of the loading sequence when in delayed load mode.
  26832. */
  26833. delayLoadState: number;
  26834. private _scene;
  26835. /** @hidden */
  26836. _texture: Nullable<InternalTexture>;
  26837. private _uid;
  26838. /**
  26839. * Define if the texture is preventinga material to render or not.
  26840. * If not and the texture is not ready, the engine will use a default black texture instead.
  26841. */
  26842. readonly isBlocking: boolean;
  26843. /**
  26844. * Instantiates a new BaseTexture.
  26845. * Base class of all the textures in babylon.
  26846. * It groups all the common properties the materials, post process, lights... might need
  26847. * in order to make a correct use of the texture.
  26848. * @param scene Define the scene the texture blongs to
  26849. */
  26850. constructor(scene: Nullable<Scene>);
  26851. /**
  26852. * Get the scene the texture belongs to.
  26853. * @returns the scene or null if undefined
  26854. */
  26855. getScene(): Nullable<Scene>;
  26856. /**
  26857. * Get the texture transform matrix used to offset tile the texture for istance.
  26858. * @returns the transformation matrix
  26859. */
  26860. getTextureMatrix(): Matrix;
  26861. /**
  26862. * Get the texture reflection matrix used to rotate/transform the reflection.
  26863. * @returns the reflection matrix
  26864. */
  26865. getReflectionTextureMatrix(): Matrix;
  26866. /**
  26867. * Get the underlying lower level texture from Babylon.
  26868. * @returns the insternal texture
  26869. */
  26870. getInternalTexture(): Nullable<InternalTexture>;
  26871. /**
  26872. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26873. * @returns true if ready or not blocking
  26874. */
  26875. isReadyOrNotBlocking(): boolean;
  26876. /**
  26877. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26878. * @returns true if fully ready
  26879. */
  26880. isReady(): boolean;
  26881. private _cachedSize;
  26882. /**
  26883. * Get the size of the texture.
  26884. * @returns the texture size.
  26885. */
  26886. getSize(): ISize;
  26887. /**
  26888. * Get the base size of the texture.
  26889. * It can be different from the size if the texture has been resized for POT for instance
  26890. * @returns the base size
  26891. */
  26892. getBaseSize(): ISize;
  26893. /**
  26894. * Update the sampling mode of the texture.
  26895. * Default is Trilinear mode.
  26896. *
  26897. * | Value | Type | Description |
  26898. * | ----- | ------------------ | ----------- |
  26899. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26900. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26901. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26902. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26903. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26904. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26905. * | 7 | NEAREST_LINEAR | |
  26906. * | 8 | NEAREST_NEAREST | |
  26907. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26908. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26909. * | 11 | LINEAR_LINEAR | |
  26910. * | 12 | LINEAR_NEAREST | |
  26911. *
  26912. * > _mag_: magnification filter (close to the viewer)
  26913. * > _min_: minification filter (far from the viewer)
  26914. * > _mip_: filter used between mip map levels
  26915. *@param samplingMode Define the new sampling mode of the texture
  26916. */
  26917. updateSamplingMode(samplingMode: number): void;
  26918. /**
  26919. * Scales the texture if is `canRescale()`
  26920. * @param ratio the resize factor we want to use to rescale
  26921. */
  26922. scale(ratio: number): void;
  26923. /**
  26924. * Get if the texture can rescale.
  26925. */
  26926. readonly canRescale: boolean;
  26927. /** @hidden */
  26928. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26929. /** @hidden */
  26930. _rebuild(): void;
  26931. /**
  26932. * Triggers the load sequence in delayed load mode.
  26933. */
  26934. delayLoad(): void;
  26935. /**
  26936. * Clones the texture.
  26937. * @returns the cloned texture
  26938. */
  26939. clone(): Nullable<BaseTexture>;
  26940. /**
  26941. * Get the texture underlying type (INT, FLOAT...)
  26942. */
  26943. readonly textureType: number;
  26944. /**
  26945. * Get the texture underlying format (RGB, RGBA...)
  26946. */
  26947. readonly textureFormat: number;
  26948. /**
  26949. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26950. * This will returns an RGBA array buffer containing either in values (0-255) or
  26951. * float values (0-1) depending of the underlying buffer type.
  26952. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26953. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26954. * @param buffer defines a user defined buffer to fill with data (can be null)
  26955. * @returns The Array buffer containing the pixels data.
  26956. */
  26957. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26958. /**
  26959. * Release and destroy the underlying lower level texture aka internalTexture.
  26960. */
  26961. releaseInternalTexture(): void;
  26962. /**
  26963. * Get the polynomial representation of the texture data.
  26964. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26965. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26966. */
  26967. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26968. /** @hidden */
  26969. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26970. /** @hidden */
  26971. readonly _lodTextureMid: Nullable<BaseTexture>;
  26972. /** @hidden */
  26973. readonly _lodTextureLow: Nullable<BaseTexture>;
  26974. /**
  26975. * Dispose the texture and release its associated resources.
  26976. */
  26977. dispose(): void;
  26978. /**
  26979. * Serialize the texture into a JSON representation that can be parsed later on.
  26980. * @returns the JSON representation of the texture
  26981. */
  26982. serialize(): any;
  26983. /**
  26984. * Helper function to be called back once a list of texture contains only ready textures.
  26985. * @param textures Define the list of textures to wait for
  26986. * @param callback Define the callback triggered once the entire list will be ready
  26987. */
  26988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26989. }
  26990. }
  26991. declare module "babylonjs/Materials/uniformBuffer" {
  26992. import { Nullable, FloatArray } from "babylonjs/types";
  26993. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26994. import { Engine } from "babylonjs/Engines/engine";
  26995. import { Effect } from "babylonjs/Materials/effect";
  26996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26997. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26998. /**
  26999. * Uniform buffer objects.
  27000. *
  27001. * Handles blocks of uniform on the GPU.
  27002. *
  27003. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27004. *
  27005. * For more information, please refer to :
  27006. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27007. */
  27008. export class UniformBuffer {
  27009. private _engine;
  27010. private _buffer;
  27011. private _data;
  27012. private _bufferData;
  27013. private _dynamic?;
  27014. private _uniformLocations;
  27015. private _uniformSizes;
  27016. private _uniformLocationPointer;
  27017. private _needSync;
  27018. private _noUBO;
  27019. private _currentEffect;
  27020. private static _MAX_UNIFORM_SIZE;
  27021. private static _tempBuffer;
  27022. /**
  27023. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27024. * This is dynamic to allow compat with webgl 1 and 2.
  27025. * You will need to pass the name of the uniform as well as the value.
  27026. */
  27027. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27028. /**
  27029. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27030. * This is dynamic to allow compat with webgl 1 and 2.
  27031. * You will need to pass the name of the uniform as well as the value.
  27032. */
  27033. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27034. /**
  27035. * Lambda to Update a single float in a uniform buffer.
  27036. * This is dynamic to allow compat with webgl 1 and 2.
  27037. * You will need to pass the name of the uniform as well as the value.
  27038. */
  27039. updateFloat: (name: string, x: number) => void;
  27040. /**
  27041. * Lambda to Update a vec2 of float in a uniform buffer.
  27042. * This is dynamic to allow compat with webgl 1 and 2.
  27043. * You will need to pass the name of the uniform as well as the value.
  27044. */
  27045. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27046. /**
  27047. * Lambda to Update a vec3 of float in a uniform buffer.
  27048. * This is dynamic to allow compat with webgl 1 and 2.
  27049. * You will need to pass the name of the uniform as well as the value.
  27050. */
  27051. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27052. /**
  27053. * Lambda to Update a vec4 of float in a uniform buffer.
  27054. * This is dynamic to allow compat with webgl 1 and 2.
  27055. * You will need to pass the name of the uniform as well as the value.
  27056. */
  27057. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27058. /**
  27059. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27060. * This is dynamic to allow compat with webgl 1 and 2.
  27061. * You will need to pass the name of the uniform as well as the value.
  27062. */
  27063. updateMatrix: (name: string, mat: Matrix) => void;
  27064. /**
  27065. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27066. * This is dynamic to allow compat with webgl 1 and 2.
  27067. * You will need to pass the name of the uniform as well as the value.
  27068. */
  27069. updateVector3: (name: string, vector: Vector3) => void;
  27070. /**
  27071. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27072. * This is dynamic to allow compat with webgl 1 and 2.
  27073. * You will need to pass the name of the uniform as well as the value.
  27074. */
  27075. updateVector4: (name: string, vector: Vector4) => void;
  27076. /**
  27077. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27078. * This is dynamic to allow compat with webgl 1 and 2.
  27079. * You will need to pass the name of the uniform as well as the value.
  27080. */
  27081. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27082. /**
  27083. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27084. * This is dynamic to allow compat with webgl 1 and 2.
  27085. * You will need to pass the name of the uniform as well as the value.
  27086. */
  27087. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27088. /**
  27089. * Instantiates a new Uniform buffer objects.
  27090. *
  27091. * Handles blocks of uniform on the GPU.
  27092. *
  27093. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27094. *
  27095. * For more information, please refer to :
  27096. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27097. * @param engine Define the engine the buffer is associated with
  27098. * @param data Define the data contained in the buffer
  27099. * @param dynamic Define if the buffer is updatable
  27100. */
  27101. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27102. /**
  27103. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27104. * or just falling back on setUniformXXX calls.
  27105. */
  27106. readonly useUbo: boolean;
  27107. /**
  27108. * Indicates if the WebGL underlying uniform buffer is in sync
  27109. * with the javascript cache data.
  27110. */
  27111. readonly isSync: boolean;
  27112. /**
  27113. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27114. * Also, a dynamic UniformBuffer will disable cache verification and always
  27115. * update the underlying WebGL uniform buffer to the GPU.
  27116. * @returns if Dynamic, otherwise false
  27117. */
  27118. isDynamic(): boolean;
  27119. /**
  27120. * The data cache on JS side.
  27121. * @returns the underlying data as a float array
  27122. */
  27123. getData(): Float32Array;
  27124. /**
  27125. * The underlying WebGL Uniform buffer.
  27126. * @returns the webgl buffer
  27127. */
  27128. getBuffer(): Nullable<DataBuffer>;
  27129. /**
  27130. * std140 layout specifies how to align data within an UBO structure.
  27131. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27132. * for specs.
  27133. */
  27134. private _fillAlignment;
  27135. /**
  27136. * Adds an uniform in the buffer.
  27137. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27138. * for the layout to be correct !
  27139. * @param name Name of the uniform, as used in the uniform block in the shader.
  27140. * @param size Data size, or data directly.
  27141. */
  27142. addUniform(name: string, size: number | number[]): void;
  27143. /**
  27144. * Adds a Matrix 4x4 to the uniform buffer.
  27145. * @param name Name of the uniform, as used in the uniform block in the shader.
  27146. * @param mat A 4x4 matrix.
  27147. */
  27148. addMatrix(name: string, mat: Matrix): void;
  27149. /**
  27150. * Adds a vec2 to the uniform buffer.
  27151. * @param name Name of the uniform, as used in the uniform block in the shader.
  27152. * @param x Define the x component value of the vec2
  27153. * @param y Define the y component value of the vec2
  27154. */
  27155. addFloat2(name: string, x: number, y: number): void;
  27156. /**
  27157. * Adds a vec3 to the uniform buffer.
  27158. * @param name Name of the uniform, as used in the uniform block in the shader.
  27159. * @param x Define the x component value of the vec3
  27160. * @param y Define the y component value of the vec3
  27161. * @param z Define the z component value of the vec3
  27162. */
  27163. addFloat3(name: string, x: number, y: number, z: number): void;
  27164. /**
  27165. * Adds a vec3 to the uniform buffer.
  27166. * @param name Name of the uniform, as used in the uniform block in the shader.
  27167. * @param color Define the vec3 from a Color
  27168. */
  27169. addColor3(name: string, color: Color3): void;
  27170. /**
  27171. * Adds a vec4 to the uniform buffer.
  27172. * @param name Name of the uniform, as used in the uniform block in the shader.
  27173. * @param color Define the rgb components from a Color
  27174. * @param alpha Define the a component of the vec4
  27175. */
  27176. addColor4(name: string, color: Color3, alpha: number): void;
  27177. /**
  27178. * Adds a vec3 to the uniform buffer.
  27179. * @param name Name of the uniform, as used in the uniform block in the shader.
  27180. * @param vector Define the vec3 components from a Vector
  27181. */
  27182. addVector3(name: string, vector: Vector3): void;
  27183. /**
  27184. * Adds a Matrix 3x3 to the uniform buffer.
  27185. * @param name Name of the uniform, as used in the uniform block in the shader.
  27186. */
  27187. addMatrix3x3(name: string): void;
  27188. /**
  27189. * Adds a Matrix 2x2 to the uniform buffer.
  27190. * @param name Name of the uniform, as used in the uniform block in the shader.
  27191. */
  27192. addMatrix2x2(name: string): void;
  27193. /**
  27194. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27195. */
  27196. create(): void;
  27197. /** @hidden */
  27198. _rebuild(): void;
  27199. /**
  27200. * Updates the WebGL Uniform Buffer on the GPU.
  27201. * If the `dynamic` flag is set to true, no cache comparison is done.
  27202. * Otherwise, the buffer will be updated only if the cache differs.
  27203. */
  27204. update(): void;
  27205. /**
  27206. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27207. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27208. * @param data Define the flattened data
  27209. * @param size Define the size of the data.
  27210. */
  27211. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27212. private _updateMatrix3x3ForUniform;
  27213. private _updateMatrix3x3ForEffect;
  27214. private _updateMatrix2x2ForEffect;
  27215. private _updateMatrix2x2ForUniform;
  27216. private _updateFloatForEffect;
  27217. private _updateFloatForUniform;
  27218. private _updateFloat2ForEffect;
  27219. private _updateFloat2ForUniform;
  27220. private _updateFloat3ForEffect;
  27221. private _updateFloat3ForUniform;
  27222. private _updateFloat4ForEffect;
  27223. private _updateFloat4ForUniform;
  27224. private _updateMatrixForEffect;
  27225. private _updateMatrixForUniform;
  27226. private _updateVector3ForEffect;
  27227. private _updateVector3ForUniform;
  27228. private _updateVector4ForEffect;
  27229. private _updateVector4ForUniform;
  27230. private _updateColor3ForEffect;
  27231. private _updateColor3ForUniform;
  27232. private _updateColor4ForEffect;
  27233. private _updateColor4ForUniform;
  27234. /**
  27235. * Sets a sampler uniform on the effect.
  27236. * @param name Define the name of the sampler.
  27237. * @param texture Define the texture to set in the sampler
  27238. */
  27239. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27240. /**
  27241. * Directly updates the value of the uniform in the cache AND on the GPU.
  27242. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27243. * @param data Define the flattened data
  27244. */
  27245. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27246. /**
  27247. * Binds this uniform buffer to an effect.
  27248. * @param effect Define the effect to bind the buffer to
  27249. * @param name Name of the uniform block in the shader.
  27250. */
  27251. bindToEffect(effect: Effect, name: string): void;
  27252. /**
  27253. * Disposes the uniform buffer.
  27254. */
  27255. dispose(): void;
  27256. }
  27257. }
  27258. declare module "babylonjs/Audio/analyser" {
  27259. import { Scene } from "babylonjs/scene";
  27260. /**
  27261. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27263. */
  27264. export class Analyser {
  27265. /**
  27266. * Gets or sets the smoothing
  27267. * @ignorenaming
  27268. */
  27269. SMOOTHING: number;
  27270. /**
  27271. * Gets or sets the FFT table size
  27272. * @ignorenaming
  27273. */
  27274. FFT_SIZE: number;
  27275. /**
  27276. * Gets or sets the bar graph amplitude
  27277. * @ignorenaming
  27278. */
  27279. BARGRAPHAMPLITUDE: number;
  27280. /**
  27281. * Gets or sets the position of the debug canvas
  27282. * @ignorenaming
  27283. */
  27284. DEBUGCANVASPOS: {
  27285. x: number;
  27286. y: number;
  27287. };
  27288. /**
  27289. * Gets or sets the debug canvas size
  27290. * @ignorenaming
  27291. */
  27292. DEBUGCANVASSIZE: {
  27293. width: number;
  27294. height: number;
  27295. };
  27296. private _byteFreqs;
  27297. private _byteTime;
  27298. private _floatFreqs;
  27299. private _webAudioAnalyser;
  27300. private _debugCanvas;
  27301. private _debugCanvasContext;
  27302. private _scene;
  27303. private _registerFunc;
  27304. private _audioEngine;
  27305. /**
  27306. * Creates a new analyser
  27307. * @param scene defines hosting scene
  27308. */
  27309. constructor(scene: Scene);
  27310. /**
  27311. * Get the number of data values you will have to play with for the visualization
  27312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27313. * @returns a number
  27314. */
  27315. getFrequencyBinCount(): number;
  27316. /**
  27317. * Gets the current frequency data as a byte array
  27318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27319. * @returns a Uint8Array
  27320. */
  27321. getByteFrequencyData(): Uint8Array;
  27322. /**
  27323. * Gets the current waveform as a byte array
  27324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27325. * @returns a Uint8Array
  27326. */
  27327. getByteTimeDomainData(): Uint8Array;
  27328. /**
  27329. * Gets the current frequency data as a float array
  27330. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27331. * @returns a Float32Array
  27332. */
  27333. getFloatFrequencyData(): Float32Array;
  27334. /**
  27335. * Renders the debug canvas
  27336. */
  27337. drawDebugCanvas(): void;
  27338. /**
  27339. * Stops rendering the debug canvas and removes it
  27340. */
  27341. stopDebugCanvas(): void;
  27342. /**
  27343. * Connects two audio nodes
  27344. * @param inputAudioNode defines first node to connect
  27345. * @param outputAudioNode defines second node to connect
  27346. */
  27347. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27348. /**
  27349. * Releases all associated resources
  27350. */
  27351. dispose(): void;
  27352. }
  27353. }
  27354. declare module "babylonjs/Audio/audioEngine" {
  27355. import { IDisposable } from "babylonjs/scene";
  27356. import { Analyser } from "babylonjs/Audio/analyser";
  27357. import { Nullable } from "babylonjs/types";
  27358. import { Observable } from "babylonjs/Misc/observable";
  27359. /**
  27360. * This represents an audio engine and it is responsible
  27361. * to play, synchronize and analyse sounds throughout the application.
  27362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27363. */
  27364. export interface IAudioEngine extends IDisposable {
  27365. /**
  27366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27367. */
  27368. readonly canUseWebAudio: boolean;
  27369. /**
  27370. * Gets the current AudioContext if available.
  27371. */
  27372. readonly audioContext: Nullable<AudioContext>;
  27373. /**
  27374. * The master gain node defines the global audio volume of your audio engine.
  27375. */
  27376. readonly masterGain: GainNode;
  27377. /**
  27378. * Gets whether or not mp3 are supported by your browser.
  27379. */
  27380. readonly isMP3supported: boolean;
  27381. /**
  27382. * Gets whether or not ogg are supported by your browser.
  27383. */
  27384. readonly isOGGsupported: boolean;
  27385. /**
  27386. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27387. * @ignoreNaming
  27388. */
  27389. WarnedWebAudioUnsupported: boolean;
  27390. /**
  27391. * Defines if the audio engine relies on a custom unlocked button.
  27392. * In this case, the embedded button will not be displayed.
  27393. */
  27394. useCustomUnlockedButton: boolean;
  27395. /**
  27396. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27397. */
  27398. readonly unlocked: boolean;
  27399. /**
  27400. * Event raised when audio has been unlocked on the browser.
  27401. */
  27402. onAudioUnlockedObservable: Observable<AudioEngine>;
  27403. /**
  27404. * Event raised when audio has been locked on the browser.
  27405. */
  27406. onAudioLockedObservable: Observable<AudioEngine>;
  27407. /**
  27408. * Flags the audio engine in Locked state.
  27409. * This happens due to new browser policies preventing audio to autoplay.
  27410. */
  27411. lock(): void;
  27412. /**
  27413. * Unlocks the audio engine once a user action has been done on the dom.
  27414. * This is helpful to resume play once browser policies have been satisfied.
  27415. */
  27416. unlock(): void;
  27417. }
  27418. /**
  27419. * This represents the default audio engine used in babylon.
  27420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27422. */
  27423. export class AudioEngine implements IAudioEngine {
  27424. private _audioContext;
  27425. private _audioContextInitialized;
  27426. private _muteButton;
  27427. private _hostElement;
  27428. /**
  27429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27430. */
  27431. canUseWebAudio: boolean;
  27432. /**
  27433. * The master gain node defines the global audio volume of your audio engine.
  27434. */
  27435. masterGain: GainNode;
  27436. /**
  27437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27438. * @ignoreNaming
  27439. */
  27440. WarnedWebAudioUnsupported: boolean;
  27441. /**
  27442. * Gets whether or not mp3 are supported by your browser.
  27443. */
  27444. isMP3supported: boolean;
  27445. /**
  27446. * Gets whether or not ogg are supported by your browser.
  27447. */
  27448. isOGGsupported: boolean;
  27449. /**
  27450. * Gets whether audio has been unlocked on the device.
  27451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27452. * a user interaction has happened.
  27453. */
  27454. unlocked: boolean;
  27455. /**
  27456. * Defines if the audio engine relies on a custom unlocked button.
  27457. * In this case, the embedded button will not be displayed.
  27458. */
  27459. useCustomUnlockedButton: boolean;
  27460. /**
  27461. * Event raised when audio has been unlocked on the browser.
  27462. */
  27463. onAudioUnlockedObservable: Observable<AudioEngine>;
  27464. /**
  27465. * Event raised when audio has been locked on the browser.
  27466. */
  27467. onAudioLockedObservable: Observable<AudioEngine>;
  27468. /**
  27469. * Gets the current AudioContext if available.
  27470. */
  27471. readonly audioContext: Nullable<AudioContext>;
  27472. private _connectedAnalyser;
  27473. /**
  27474. * Instantiates a new audio engine.
  27475. *
  27476. * There should be only one per page as some browsers restrict the number
  27477. * of audio contexts you can create.
  27478. * @param hostElement defines the host element where to display the mute icon if necessary
  27479. */
  27480. constructor(hostElement?: Nullable<HTMLElement>);
  27481. /**
  27482. * Flags the audio engine in Locked state.
  27483. * This happens due to new browser policies preventing audio to autoplay.
  27484. */
  27485. lock(): void;
  27486. /**
  27487. * Unlocks the audio engine once a user action has been done on the dom.
  27488. * This is helpful to resume play once browser policies have been satisfied.
  27489. */
  27490. unlock(): void;
  27491. private _resumeAudioContext;
  27492. private _initializeAudioContext;
  27493. private _tryToRun;
  27494. private _triggerRunningState;
  27495. private _triggerSuspendedState;
  27496. private _displayMuteButton;
  27497. private _moveButtonToTopLeft;
  27498. private _onResize;
  27499. private _hideMuteButton;
  27500. /**
  27501. * Destroy and release the resources associated with the audio ccontext.
  27502. */
  27503. dispose(): void;
  27504. /**
  27505. * Gets the global volume sets on the master gain.
  27506. * @returns the global volume if set or -1 otherwise
  27507. */
  27508. getGlobalVolume(): number;
  27509. /**
  27510. * Sets the global volume of your experience (sets on the master gain).
  27511. * @param newVolume Defines the new global volume of the application
  27512. */
  27513. setGlobalVolume(newVolume: number): void;
  27514. /**
  27515. * Connect the audio engine to an audio analyser allowing some amazing
  27516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27518. * @param analyser The analyser to connect to the engine
  27519. */
  27520. connectToAnalyser(analyser: Analyser): void;
  27521. }
  27522. }
  27523. declare module "babylonjs/Loading/loadingScreen" {
  27524. /**
  27525. * Interface used to present a loading screen while loading a scene
  27526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27527. */
  27528. export interface ILoadingScreen {
  27529. /**
  27530. * Function called to display the loading screen
  27531. */
  27532. displayLoadingUI: () => void;
  27533. /**
  27534. * Function called to hide the loading screen
  27535. */
  27536. hideLoadingUI: () => void;
  27537. /**
  27538. * Gets or sets the color to use for the background
  27539. */
  27540. loadingUIBackgroundColor: string;
  27541. /**
  27542. * Gets or sets the text to display while loading
  27543. */
  27544. loadingUIText: string;
  27545. }
  27546. /**
  27547. * Class used for the default loading screen
  27548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27549. */
  27550. export class DefaultLoadingScreen implements ILoadingScreen {
  27551. private _renderingCanvas;
  27552. private _loadingText;
  27553. private _loadingDivBackgroundColor;
  27554. private _loadingDiv;
  27555. private _loadingTextDiv;
  27556. /**
  27557. * Creates a new default loading screen
  27558. * @param _renderingCanvas defines the canvas used to render the scene
  27559. * @param _loadingText defines the default text to display
  27560. * @param _loadingDivBackgroundColor defines the default background color
  27561. */
  27562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27563. /**
  27564. * Function called to display the loading screen
  27565. */
  27566. displayLoadingUI(): void;
  27567. /**
  27568. * Function called to hide the loading screen
  27569. */
  27570. hideLoadingUI(): void;
  27571. /**
  27572. * Gets or sets the text to display while loading
  27573. */
  27574. loadingUIText: string;
  27575. /**
  27576. * Gets or sets the color to use for the background
  27577. */
  27578. loadingUIBackgroundColor: string;
  27579. private _resizeLoadingUI;
  27580. }
  27581. }
  27582. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27583. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27584. import { Engine } from "babylonjs/Engines/engine";
  27585. import { Nullable } from "babylonjs/types";
  27586. /** @hidden */
  27587. export class WebGLPipelineContext implements IPipelineContext {
  27588. engine: Engine;
  27589. program: Nullable<WebGLProgram>;
  27590. context?: WebGLRenderingContext;
  27591. vertexShader?: WebGLShader;
  27592. fragmentShader?: WebGLShader;
  27593. isParallelCompiled: boolean;
  27594. onCompiled?: () => void;
  27595. transformFeedback?: WebGLTransformFeedback | null;
  27596. readonly isAsync: boolean;
  27597. readonly isReady: boolean;
  27598. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27599. }
  27600. }
  27601. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27602. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27603. /** @hidden */
  27604. export class WebGLDataBuffer extends DataBuffer {
  27605. private _buffer;
  27606. constructor(resource: WebGLBuffer);
  27607. readonly underlyingResource: any;
  27608. }
  27609. }
  27610. declare module "babylonjs/Materials/Textures/videoTexture" {
  27611. import { Observable } from "babylonjs/Misc/observable";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Scene } from "babylonjs/scene";
  27614. import { Texture } from "babylonjs/Materials/Textures/texture";
  27615. /**
  27616. * Settings for finer control over video usage
  27617. */
  27618. export interface VideoTextureSettings {
  27619. /**
  27620. * Applies `autoplay` to video, if specified
  27621. */
  27622. autoPlay?: boolean;
  27623. /**
  27624. * Applies `loop` to video, if specified
  27625. */
  27626. loop?: boolean;
  27627. /**
  27628. * Automatically updates internal texture from video at every frame in the render loop
  27629. */
  27630. autoUpdateTexture: boolean;
  27631. /**
  27632. * Image src displayed during the video loading or until the user interacts with the video.
  27633. */
  27634. poster?: string;
  27635. }
  27636. /**
  27637. * If you want to display a video in your scene, this is the special texture for that.
  27638. * This special texture works similar to other textures, with the exception of a few parameters.
  27639. * @see https://doc.babylonjs.com/how_to/video_texture
  27640. */
  27641. export class VideoTexture extends Texture {
  27642. /**
  27643. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27644. */
  27645. readonly autoUpdateTexture: boolean;
  27646. /**
  27647. * The video instance used by the texture internally
  27648. */
  27649. readonly video: HTMLVideoElement;
  27650. private _onUserActionRequestedObservable;
  27651. /**
  27652. * Event triggerd when a dom action is required by the user to play the video.
  27653. * This happens due to recent changes in browser policies preventing video to auto start.
  27654. */
  27655. readonly onUserActionRequestedObservable: Observable<Texture>;
  27656. private _generateMipMaps;
  27657. private _engine;
  27658. private _stillImageCaptured;
  27659. private _displayingPosterTexture;
  27660. private _settings;
  27661. private _createInternalTextureOnEvent;
  27662. /**
  27663. * Creates a video texture.
  27664. * If you want to display a video in your scene, this is the special texture for that.
  27665. * This special texture works similar to other textures, with the exception of a few parameters.
  27666. * @see https://doc.babylonjs.com/how_to/video_texture
  27667. * @param name optional name, will detect from video source, if not defined
  27668. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27669. * @param scene is obviously the current scene.
  27670. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27671. * @param invertY is false by default but can be used to invert video on Y axis
  27672. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27673. * @param settings allows finer control over video usage
  27674. */
  27675. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27676. private _getName;
  27677. private _getVideo;
  27678. private _createInternalTexture;
  27679. private reset;
  27680. /**
  27681. * @hidden Internal method to initiate `update`.
  27682. */
  27683. _rebuild(): void;
  27684. /**
  27685. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27686. */
  27687. update(): void;
  27688. /**
  27689. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27690. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27691. */
  27692. updateTexture(isVisible: boolean): void;
  27693. protected _updateInternalTexture: () => void;
  27694. /**
  27695. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27696. * @param url New url.
  27697. */
  27698. updateURL(url: string): void;
  27699. /**
  27700. * Dispose the texture and release its associated resources.
  27701. */
  27702. dispose(): void;
  27703. /**
  27704. * Creates a video texture straight from a stream.
  27705. * @param scene Define the scene the texture should be created in
  27706. * @param stream Define the stream the texture should be created from
  27707. * @returns The created video texture as a promise
  27708. */
  27709. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27710. /**
  27711. * Creates a video texture straight from your WebCam video feed.
  27712. * @param scene Define the scene the texture should be created in
  27713. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27714. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27715. * @returns The created video texture as a promise
  27716. */
  27717. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27718. minWidth: number;
  27719. maxWidth: number;
  27720. minHeight: number;
  27721. maxHeight: number;
  27722. deviceId: string;
  27723. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27724. /**
  27725. * Creates a video texture straight from your WebCam video feed.
  27726. * @param scene Define the scene the texture should be created in
  27727. * @param onReady Define a callback to triggered once the texture will be ready
  27728. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27729. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27730. */
  27731. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27732. minWidth: number;
  27733. maxWidth: number;
  27734. minHeight: number;
  27735. maxHeight: number;
  27736. deviceId: string;
  27737. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27738. }
  27739. }
  27740. declare module "babylonjs/Engines/engine" {
  27741. import { Observable } from "babylonjs/Misc/observable";
  27742. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27743. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27744. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27745. import { Camera } from "babylonjs/Cameras/camera";
  27746. import { Scene } from "babylonjs/scene";
  27747. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27748. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27749. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27750. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27751. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27752. import { Material } from "babylonjs/Materials/material";
  27753. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27756. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27757. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27758. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27759. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27760. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27761. import { WebRequest } from "babylonjs/Misc/webRequest";
  27762. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27763. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27765. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27766. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27767. /**
  27768. * Interface for attribute information associated with buffer instanciation
  27769. */
  27770. export class InstancingAttributeInfo {
  27771. /**
  27772. * Index/offset of the attribute in the vertex shader
  27773. */
  27774. index: number;
  27775. /**
  27776. * size of the attribute, 1, 2, 3 or 4
  27777. */
  27778. attributeSize: number;
  27779. /**
  27780. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27781. * default is FLOAT
  27782. */
  27783. attribyteType: number;
  27784. /**
  27785. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27786. */
  27787. normalized: boolean;
  27788. /**
  27789. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27790. */
  27791. offset: number;
  27792. /**
  27793. * Name of the GLSL attribute, for debugging purpose only
  27794. */
  27795. attributeName: string;
  27796. }
  27797. /**
  27798. * Define options used to create a depth texture
  27799. */
  27800. export class DepthTextureCreationOptions {
  27801. /** Specifies whether or not a stencil should be allocated in the texture */
  27802. generateStencil?: boolean;
  27803. /** Specifies whether or not bilinear filtering is enable on the texture */
  27804. bilinearFiltering?: boolean;
  27805. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27806. comparisonFunction?: number;
  27807. /** Specifies if the created texture is a cube texture */
  27808. isCube?: boolean;
  27809. }
  27810. /**
  27811. * Class used to describe the capabilities of the engine relatively to the current browser
  27812. */
  27813. export class EngineCapabilities {
  27814. /** Maximum textures units per fragment shader */
  27815. maxTexturesImageUnits: number;
  27816. /** Maximum texture units per vertex shader */
  27817. maxVertexTextureImageUnits: number;
  27818. /** Maximum textures units in the entire pipeline */
  27819. maxCombinedTexturesImageUnits: number;
  27820. /** Maximum texture size */
  27821. maxTextureSize: number;
  27822. /** Maximum cube texture size */
  27823. maxCubemapTextureSize: number;
  27824. /** Maximum render texture size */
  27825. maxRenderTextureSize: number;
  27826. /** Maximum number of vertex attributes */
  27827. maxVertexAttribs: number;
  27828. /** Maximum number of varyings */
  27829. maxVaryingVectors: number;
  27830. /** Maximum number of uniforms per vertex shader */
  27831. maxVertexUniformVectors: number;
  27832. /** Maximum number of uniforms per fragment shader */
  27833. maxFragmentUniformVectors: number;
  27834. /** Defines if standard derivates (dx/dy) are supported */
  27835. standardDerivatives: boolean;
  27836. /** Defines if s3tc texture compression is supported */
  27837. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27838. /** Defines if pvrtc texture compression is supported */
  27839. pvrtc: any;
  27840. /** Defines if etc1 texture compression is supported */
  27841. etc1: any;
  27842. /** Defines if etc2 texture compression is supported */
  27843. etc2: any;
  27844. /** Defines if astc texture compression is supported */
  27845. astc: any;
  27846. /** Defines if float textures are supported */
  27847. textureFloat: boolean;
  27848. /** Defines if vertex array objects are supported */
  27849. vertexArrayObject: boolean;
  27850. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27851. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27852. /** Gets the maximum level of anisotropy supported */
  27853. maxAnisotropy: number;
  27854. /** Defines if instancing is supported */
  27855. instancedArrays: boolean;
  27856. /** Defines if 32 bits indices are supported */
  27857. uintIndices: boolean;
  27858. /** Defines if high precision shaders are supported */
  27859. highPrecisionShaderSupported: boolean;
  27860. /** Defines if depth reading in the fragment shader is supported */
  27861. fragmentDepthSupported: boolean;
  27862. /** Defines if float texture linear filtering is supported*/
  27863. textureFloatLinearFiltering: boolean;
  27864. /** Defines if rendering to float textures is supported */
  27865. textureFloatRender: boolean;
  27866. /** Defines if half float textures are supported*/
  27867. textureHalfFloat: boolean;
  27868. /** Defines if half float texture linear filtering is supported*/
  27869. textureHalfFloatLinearFiltering: boolean;
  27870. /** Defines if rendering to half float textures is supported */
  27871. textureHalfFloatRender: boolean;
  27872. /** Defines if textureLOD shader command is supported */
  27873. textureLOD: boolean;
  27874. /** Defines if draw buffers extension is supported */
  27875. drawBuffersExtension: boolean;
  27876. /** Defines if depth textures are supported */
  27877. depthTextureExtension: boolean;
  27878. /** Defines if float color buffer are supported */
  27879. colorBufferFloat: boolean;
  27880. /** Gets disjoint timer query extension (null if not supported) */
  27881. timerQuery: EXT_disjoint_timer_query;
  27882. /** Defines if timestamp can be used with timer query */
  27883. canUseTimestampForTimerQuery: boolean;
  27884. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27885. multiview: any;
  27886. /** Function used to let the system compiles shaders in background */
  27887. parallelShaderCompile: {
  27888. COMPLETION_STATUS_KHR: number;
  27889. };
  27890. }
  27891. /** Interface defining initialization parameters for Engine class */
  27892. export interface EngineOptions extends WebGLContextAttributes {
  27893. /**
  27894. * Defines if the engine should no exceed a specified device ratio
  27895. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27896. */
  27897. limitDeviceRatio?: number;
  27898. /**
  27899. * Defines if webvr should be enabled automatically
  27900. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27901. */
  27902. autoEnableWebVR?: boolean;
  27903. /**
  27904. * Defines if webgl2 should be turned off even if supported
  27905. * @see http://doc.babylonjs.com/features/webgl2
  27906. */
  27907. disableWebGL2Support?: boolean;
  27908. /**
  27909. * Defines if webaudio should be initialized as well
  27910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27911. */
  27912. audioEngine?: boolean;
  27913. /**
  27914. * Defines if animations should run using a deterministic lock step
  27915. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27916. */
  27917. deterministicLockstep?: boolean;
  27918. /** Defines the maximum steps to use with deterministic lock step mode */
  27919. lockstepMaxSteps?: number;
  27920. /**
  27921. * Defines that engine should ignore context lost events
  27922. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27923. */
  27924. doNotHandleContextLost?: boolean;
  27925. /**
  27926. * Defines that engine should ignore modifying touch action attribute and style
  27927. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27928. */
  27929. doNotHandleTouchAction?: boolean;
  27930. /**
  27931. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27932. */
  27933. useHighPrecisionFloats?: boolean;
  27934. }
  27935. /**
  27936. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27937. */
  27938. export class Engine {
  27939. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27940. static ExceptionList: ({
  27941. key: string;
  27942. capture: string;
  27943. captureConstraint: number;
  27944. targets: string[];
  27945. } | {
  27946. key: string;
  27947. capture: null;
  27948. captureConstraint: null;
  27949. targets: string[];
  27950. })[];
  27951. /** Gets the list of created engines */
  27952. static readonly Instances: Engine[];
  27953. /**
  27954. * Gets the latest created engine
  27955. */
  27956. static readonly LastCreatedEngine: Nullable<Engine>;
  27957. /**
  27958. * Gets the latest created scene
  27959. */
  27960. static readonly LastCreatedScene: Nullable<Scene>;
  27961. /**
  27962. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27963. * @param flag defines which part of the materials must be marked as dirty
  27964. * @param predicate defines a predicate used to filter which materials should be affected
  27965. */
  27966. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27967. /**
  27968. * Hidden
  27969. */
  27970. static _TextureLoaders: IInternalTextureLoader[];
  27971. /** Defines that alpha blending is disabled */
  27972. static readonly ALPHA_DISABLE: number;
  27973. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27974. static readonly ALPHA_ADD: number;
  27975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27976. static readonly ALPHA_COMBINE: number;
  27977. /** Defines that alpha blending to DEST - SRC * DEST */
  27978. static readonly ALPHA_SUBTRACT: number;
  27979. /** Defines that alpha blending to SRC * DEST */
  27980. static readonly ALPHA_MULTIPLY: number;
  27981. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27982. static readonly ALPHA_MAXIMIZED: number;
  27983. /** Defines that alpha blending to SRC + DEST */
  27984. static readonly ALPHA_ONEONE: number;
  27985. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27986. static readonly ALPHA_PREMULTIPLIED: number;
  27987. /**
  27988. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27989. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27990. */
  27991. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27992. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27993. static readonly ALPHA_INTERPOLATE: number;
  27994. /**
  27995. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27996. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27997. */
  27998. static readonly ALPHA_SCREENMODE: number;
  27999. /** Defines that the ressource is not delayed*/
  28000. static readonly DELAYLOADSTATE_NONE: number;
  28001. /** Defines that the ressource was successfully delay loaded */
  28002. static readonly DELAYLOADSTATE_LOADED: number;
  28003. /** Defines that the ressource is currently delay loading */
  28004. static readonly DELAYLOADSTATE_LOADING: number;
  28005. /** Defines that the ressource is delayed and has not started loading */
  28006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28008. static readonly NEVER: number;
  28009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  28010. static readonly ALWAYS: number;
  28011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28012. static readonly LESS: number;
  28013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28014. static readonly EQUAL: number;
  28015. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  28016. static readonly LEQUAL: number;
  28017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28018. static readonly GREATER: number;
  28019. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  28020. static readonly GEQUAL: number;
  28021. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  28022. static readonly NOTEQUAL: number;
  28023. /** Passed to stencilOperation to specify that stencil value must be kept */
  28024. static readonly KEEP: number;
  28025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28026. static readonly REPLACE: number;
  28027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28028. static readonly INCR: number;
  28029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28030. static readonly DECR: number;
  28031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28032. static readonly INVERT: number;
  28033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28034. static readonly INCR_WRAP: number;
  28035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28036. static readonly DECR_WRAP: number;
  28037. /** Texture is not repeating outside of 0..1 UVs */
  28038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28039. /** Texture is repeating outside of 0..1 UVs */
  28040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28041. /** Texture is repeating and mirrored */
  28042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28043. /** ALPHA */
  28044. static readonly TEXTUREFORMAT_ALPHA: number;
  28045. /** LUMINANCE */
  28046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28047. /** LUMINANCE_ALPHA */
  28048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28049. /** RGB */
  28050. static readonly TEXTUREFORMAT_RGB: number;
  28051. /** RGBA */
  28052. static readonly TEXTUREFORMAT_RGBA: number;
  28053. /** RED */
  28054. static readonly TEXTUREFORMAT_RED: number;
  28055. /** RED (2nd reference) */
  28056. static readonly TEXTUREFORMAT_R: number;
  28057. /** RG */
  28058. static readonly TEXTUREFORMAT_RG: number;
  28059. /** RED_INTEGER */
  28060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28061. /** RED_INTEGER (2nd reference) */
  28062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28063. /** RG_INTEGER */
  28064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28065. /** RGB_INTEGER */
  28066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28067. /** RGBA_INTEGER */
  28068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28069. /** UNSIGNED_BYTE */
  28070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28071. /** UNSIGNED_BYTE (2nd reference) */
  28072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28073. /** FLOAT */
  28074. static readonly TEXTURETYPE_FLOAT: number;
  28075. /** HALF_FLOAT */
  28076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28077. /** BYTE */
  28078. static readonly TEXTURETYPE_BYTE: number;
  28079. /** SHORT */
  28080. static readonly TEXTURETYPE_SHORT: number;
  28081. /** UNSIGNED_SHORT */
  28082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28083. /** INT */
  28084. static readonly TEXTURETYPE_INT: number;
  28085. /** UNSIGNED_INT */
  28086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28087. /** UNSIGNED_SHORT_4_4_4_4 */
  28088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28089. /** UNSIGNED_SHORT_5_5_5_1 */
  28090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28091. /** UNSIGNED_SHORT_5_6_5 */
  28092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28093. /** UNSIGNED_INT_2_10_10_10_REV */
  28094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28095. /** UNSIGNED_INT_24_8 */
  28096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28097. /** UNSIGNED_INT_10F_11F_11F_REV */
  28098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28099. /** UNSIGNED_INT_5_9_9_9_REV */
  28100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28103. /** nearest is mag = nearest and min = nearest and mip = linear */
  28104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28107. /** Trilinear is mag = linear and min = linear and mip = linear */
  28108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28109. /** nearest is mag = nearest and min = nearest and mip = linear */
  28110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28113. /** Trilinear is mag = linear and min = linear and mip = linear */
  28114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28115. /** mag = nearest and min = nearest and mip = nearest */
  28116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28117. /** mag = nearest and min = linear and mip = nearest */
  28118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28119. /** mag = nearest and min = linear and mip = linear */
  28120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28121. /** mag = nearest and min = linear and mip = none */
  28122. static readonly TEXTURE_NEAREST_LINEAR: number;
  28123. /** mag = nearest and min = nearest and mip = none */
  28124. static readonly TEXTURE_NEAREST_NEAREST: number;
  28125. /** mag = linear and min = nearest and mip = nearest */
  28126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28127. /** mag = linear and min = nearest and mip = linear */
  28128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28129. /** mag = linear and min = linear and mip = none */
  28130. static readonly TEXTURE_LINEAR_LINEAR: number;
  28131. /** mag = linear and min = nearest and mip = none */
  28132. static readonly TEXTURE_LINEAR_NEAREST: number;
  28133. /** Explicit coordinates mode */
  28134. static readonly TEXTURE_EXPLICIT_MODE: number;
  28135. /** Spherical coordinates mode */
  28136. static readonly TEXTURE_SPHERICAL_MODE: number;
  28137. /** Planar coordinates mode */
  28138. static readonly TEXTURE_PLANAR_MODE: number;
  28139. /** Cubic coordinates mode */
  28140. static readonly TEXTURE_CUBIC_MODE: number;
  28141. /** Projection coordinates mode */
  28142. static readonly TEXTURE_PROJECTION_MODE: number;
  28143. /** Skybox coordinates mode */
  28144. static readonly TEXTURE_SKYBOX_MODE: number;
  28145. /** Inverse Cubic coordinates mode */
  28146. static readonly TEXTURE_INVCUBIC_MODE: number;
  28147. /** Equirectangular coordinates mode */
  28148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28149. /** Equirectangular Fixed coordinates mode */
  28150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28151. /** Equirectangular Fixed Mirrored coordinates mode */
  28152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28154. static readonly SCALEMODE_FLOOR: number;
  28155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28156. static readonly SCALEMODE_NEAREST: number;
  28157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28158. static readonly SCALEMODE_CEILING: number;
  28159. /**
  28160. * Returns the current npm package of the sdk
  28161. */
  28162. static readonly NpmPackage: string;
  28163. /**
  28164. * Returns the current version of the framework
  28165. */
  28166. static readonly Version: string;
  28167. /**
  28168. * Returns a string describing the current engine
  28169. */
  28170. readonly description: string;
  28171. /**
  28172. * Gets or sets the epsilon value used by collision engine
  28173. */
  28174. static CollisionsEpsilon: number;
  28175. /**
  28176. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28177. */
  28178. static ShadersRepository: string;
  28179. /**
  28180. * Method called to create the default loading screen.
  28181. * This can be overriden in your own app.
  28182. * @param canvas The rendering canvas element
  28183. * @returns The loading screen
  28184. */
  28185. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28186. /**
  28187. * Method called to create the default rescale post process on each engine.
  28188. */
  28189. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28190. /**
  28191. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28192. */
  28193. forcePOTTextures: boolean;
  28194. /**
  28195. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28196. */
  28197. isFullscreen: boolean;
  28198. /**
  28199. * Gets a boolean indicating if the pointer is currently locked
  28200. */
  28201. isPointerLock: boolean;
  28202. /**
  28203. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28204. */
  28205. cullBackFaces: boolean;
  28206. /**
  28207. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28208. */
  28209. renderEvenInBackground: boolean;
  28210. /**
  28211. * Gets or sets a boolean indicating that cache can be kept between frames
  28212. */
  28213. preventCacheWipeBetweenFrames: boolean;
  28214. /**
  28215. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28216. **/
  28217. enableOfflineSupport: boolean;
  28218. /**
  28219. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  28220. **/
  28221. disableManifestCheck: boolean;
  28222. /**
  28223. * Gets the list of created scenes
  28224. */
  28225. scenes: Scene[];
  28226. /**
  28227. * Event raised when a new scene is created
  28228. */
  28229. onNewSceneAddedObservable: Observable<Scene>;
  28230. /**
  28231. * Gets the list of created postprocesses
  28232. */
  28233. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28234. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28235. validateShaderPrograms: boolean;
  28236. /**
  28237. * Observable event triggered each time the rendering canvas is resized
  28238. */
  28239. onResizeObservable: Observable<Engine>;
  28240. /**
  28241. * Observable event triggered each time the canvas loses focus
  28242. */
  28243. onCanvasBlurObservable: Observable<Engine>;
  28244. /**
  28245. * Observable event triggered each time the canvas gains focus
  28246. */
  28247. onCanvasFocusObservable: Observable<Engine>;
  28248. /**
  28249. * Observable event triggered each time the canvas receives pointerout event
  28250. */
  28251. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28252. /**
  28253. * Observable event triggered before each texture is initialized
  28254. */
  28255. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28256. /**
  28257. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28258. */
  28259. disableUniformBuffers: boolean;
  28260. /** @hidden */
  28261. _uniformBuffers: UniformBuffer[];
  28262. /**
  28263. * Gets a boolean indicating that the engine supports uniform buffers
  28264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28265. */
  28266. readonly supportsUniformBuffers: boolean;
  28267. /**
  28268. * Observable raised when the engine begins a new frame
  28269. */
  28270. onBeginFrameObservable: Observable<Engine>;
  28271. /**
  28272. * If set, will be used to request the next animation frame for the render loop
  28273. */
  28274. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28275. /**
  28276. * Observable raised when the engine ends the current frame
  28277. */
  28278. onEndFrameObservable: Observable<Engine>;
  28279. /**
  28280. * Observable raised when the engine is about to compile a shader
  28281. */
  28282. onBeforeShaderCompilationObservable: Observable<Engine>;
  28283. /**
  28284. * Observable raised when the engine has jsut compiled a shader
  28285. */
  28286. onAfterShaderCompilationObservable: Observable<Engine>;
  28287. /** @hidden */
  28288. _gl: WebGLRenderingContext;
  28289. private _renderingCanvas;
  28290. private _windowIsBackground;
  28291. private _webGLVersion;
  28292. protected _highPrecisionShadersAllowed: boolean;
  28293. /** @hidden */
  28294. readonly _shouldUseHighPrecisionShader: boolean;
  28295. /**
  28296. * Gets a boolean indicating that only power of 2 textures are supported
  28297. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28298. */
  28299. readonly needPOTTextures: boolean;
  28300. /** @hidden */
  28301. _badOS: boolean;
  28302. /** @hidden */
  28303. _badDesktopOS: boolean;
  28304. /**
  28305. * Gets the audio engine
  28306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28307. * @ignorenaming
  28308. */
  28309. static audioEngine: IAudioEngine;
  28310. /**
  28311. * Default AudioEngine factory responsible of creating the Audio Engine.
  28312. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28313. */
  28314. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28315. /**
  28316. * Default offline support factory responsible of creating a tool used to store data locally.
  28317. * By default, this will create a Database object if the workload has been embedded.
  28318. */
  28319. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28320. private _onFocus;
  28321. private _onBlur;
  28322. private _onCanvasPointerOut;
  28323. private _onCanvasBlur;
  28324. private _onCanvasFocus;
  28325. private _onFullscreenChange;
  28326. private _onPointerLockChange;
  28327. private _hardwareScalingLevel;
  28328. /** @hidden */
  28329. _caps: EngineCapabilities;
  28330. private _pointerLockRequested;
  28331. private _isStencilEnable;
  28332. private _colorWrite;
  28333. private _loadingScreen;
  28334. /** @hidden */
  28335. _drawCalls: PerfCounter;
  28336. private _glVersion;
  28337. private _glRenderer;
  28338. private _glVendor;
  28339. private _videoTextureSupported;
  28340. private _renderingQueueLaunched;
  28341. private _activeRenderLoops;
  28342. private _deterministicLockstep;
  28343. private _lockstepMaxSteps;
  28344. /**
  28345. * Observable signaled when a context lost event is raised
  28346. */
  28347. onContextLostObservable: Observable<Engine>;
  28348. /**
  28349. * Observable signaled when a context restored event is raised
  28350. */
  28351. onContextRestoredObservable: Observable<Engine>;
  28352. private _onContextLost;
  28353. private _onContextRestored;
  28354. private _contextWasLost;
  28355. /** @hidden */
  28356. _doNotHandleContextLost: boolean;
  28357. /**
  28358. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28360. */
  28361. doNotHandleContextLost: boolean;
  28362. private _performanceMonitor;
  28363. private _fps;
  28364. private _deltaTime;
  28365. /**
  28366. * Turn this value on if you want to pause FPS computation when in background
  28367. */
  28368. disablePerformanceMonitorInBackground: boolean;
  28369. /**
  28370. * Gets the performance monitor attached to this engine
  28371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28372. */
  28373. readonly performanceMonitor: PerformanceMonitor;
  28374. /**
  28375. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28376. */
  28377. disableVertexArrayObjects: boolean;
  28378. /** @hidden */
  28379. protected _depthCullingState: _DepthCullingState;
  28380. /** @hidden */
  28381. protected _stencilState: _StencilState;
  28382. /** @hidden */
  28383. protected _alphaState: _AlphaState;
  28384. /** @hidden */
  28385. protected _alphaMode: number;
  28386. /** @hidden */
  28387. _internalTexturesCache: InternalTexture[];
  28388. /** @hidden */
  28389. protected _activeChannel: number;
  28390. private _currentTextureChannel;
  28391. /** @hidden */
  28392. protected _boundTexturesCache: {
  28393. [key: string]: Nullable<InternalTexture>;
  28394. };
  28395. /** @hidden */
  28396. protected _currentEffect: Nullable<Effect>;
  28397. /** @hidden */
  28398. protected _currentProgram: Nullable<WebGLProgram>;
  28399. private _compiledEffects;
  28400. private _vertexAttribArraysEnabled;
  28401. /** @hidden */
  28402. protected _cachedViewport: Nullable<Viewport>;
  28403. private _cachedVertexArrayObject;
  28404. /** @hidden */
  28405. protected _cachedVertexBuffers: any;
  28406. /** @hidden */
  28407. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28408. /** @hidden */
  28409. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28410. /** @hidden */
  28411. _currentRenderTarget: Nullable<InternalTexture>;
  28412. private _uintIndicesCurrentlySet;
  28413. private _currentBoundBuffer;
  28414. /** @hidden */
  28415. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28416. private _currentBufferPointers;
  28417. private _currentInstanceLocations;
  28418. private _currentInstanceBuffers;
  28419. private _textureUnits;
  28420. /** @hidden */
  28421. _workingCanvas: Nullable<HTMLCanvasElement>;
  28422. /** @hidden */
  28423. _workingContext: Nullable<CanvasRenderingContext2D>;
  28424. private _rescalePostProcess;
  28425. private _dummyFramebuffer;
  28426. private _externalData;
  28427. /** @hidden */
  28428. _bindedRenderFunction: any;
  28429. private _vaoRecordInProgress;
  28430. private _mustWipeVertexAttributes;
  28431. private _emptyTexture;
  28432. private _emptyCubeTexture;
  28433. private _emptyTexture3D;
  28434. /** @hidden */
  28435. _frameHandler: number;
  28436. private _nextFreeTextureSlots;
  28437. private _maxSimultaneousTextures;
  28438. private _activeRequests;
  28439. private _texturesSupported;
  28440. /** @hidden */
  28441. _textureFormatInUse: Nullable<string>;
  28442. /**
  28443. * Gets the list of texture formats supported
  28444. */
  28445. readonly texturesSupported: Array<string>;
  28446. /**
  28447. * Gets the list of texture formats in use
  28448. */
  28449. readonly textureFormatInUse: Nullable<string>;
  28450. /**
  28451. * Gets the current viewport
  28452. */
  28453. readonly currentViewport: Nullable<Viewport>;
  28454. /**
  28455. * Gets the default empty texture
  28456. */
  28457. readonly emptyTexture: InternalTexture;
  28458. /**
  28459. * Gets the default empty 3D texture
  28460. */
  28461. readonly emptyTexture3D: InternalTexture;
  28462. /**
  28463. * Gets the default empty cube texture
  28464. */
  28465. readonly emptyCubeTexture: InternalTexture;
  28466. /**
  28467. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28468. */
  28469. readonly premultipliedAlpha: boolean;
  28470. /**
  28471. * Creates a new engine
  28472. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  28473. * @param antialias defines enable antialiasing (default: false)
  28474. * @param options defines further options to be sent to the getContext() function
  28475. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28476. */
  28477. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28478. /**
  28479. * Initializes a webVR display and starts listening to display change events
  28480. * The onVRDisplayChangedObservable will be notified upon these changes
  28481. * @returns The onVRDisplayChangedObservable
  28482. */
  28483. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28484. /** @hidden */
  28485. _prepareVRComponent(): void;
  28486. /** @hidden */
  28487. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28488. /** @hidden */
  28489. _submitVRFrame(): void;
  28490. /**
  28491. * Call this function to leave webVR mode
  28492. * Will do nothing if webVR is not supported or if there is no webVR device
  28493. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28494. */
  28495. disableVR(): void;
  28496. /**
  28497. * Gets a boolean indicating that the system is in VR mode and is presenting
  28498. * @returns true if VR mode is engaged
  28499. */
  28500. isVRPresenting(): boolean;
  28501. /** @hidden */
  28502. _requestVRFrame(): void;
  28503. private _disableTouchAction;
  28504. private _rebuildInternalTextures;
  28505. private _rebuildEffects;
  28506. /**
  28507. * Gets a boolean indicating if all created effects are ready
  28508. * @returns true if all effects are ready
  28509. */
  28510. areAllEffectsReady(): boolean;
  28511. private _rebuildBuffers;
  28512. private _initGLContext;
  28513. /**
  28514. * Gets version of the current webGL context
  28515. */
  28516. readonly webGLVersion: number;
  28517. /**
  28518. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28519. */
  28520. readonly isStencilEnable: boolean;
  28521. /** @hidden */
  28522. _prepareWorkingCanvas(): void;
  28523. /**
  28524. * Reset the texture cache to empty state
  28525. */
  28526. resetTextureCache(): void;
  28527. /**
  28528. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28530. * @returns true if engine is in deterministic lock step mode
  28531. */
  28532. isDeterministicLockStep(): boolean;
  28533. /**
  28534. * Gets the max steps when engine is running in deterministic lock step
  28535. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28536. * @returns the max steps
  28537. */
  28538. getLockstepMaxSteps(): number;
  28539. /**
  28540. * Gets an object containing information about the current webGL context
  28541. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28542. */
  28543. getGlInfo(): {
  28544. vendor: string;
  28545. renderer: string;
  28546. version: string;
  28547. };
  28548. /**
  28549. * Gets current aspect ratio
  28550. * @param camera defines the camera to use to get the aspect ratio
  28551. * @param useScreen defines if screen size must be used (or the current render target if any)
  28552. * @returns a number defining the aspect ratio
  28553. */
  28554. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28555. /**
  28556. * Gets current screen aspect ratio
  28557. * @returns a number defining the aspect ratio
  28558. */
  28559. getScreenAspectRatio(): number;
  28560. /**
  28561. * Gets the current render width
  28562. * @param useScreen defines if screen size must be used (or the current render target if any)
  28563. * @returns a number defining the current render width
  28564. */
  28565. getRenderWidth(useScreen?: boolean): number;
  28566. /**
  28567. * Gets the current render height
  28568. * @param useScreen defines if screen size must be used (or the current render target if any)
  28569. * @returns a number defining the current render height
  28570. */
  28571. getRenderHeight(useScreen?: boolean): number;
  28572. /**
  28573. * Gets the HTML canvas attached with the current webGL context
  28574. * @returns a HTML canvas
  28575. */
  28576. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28577. /**
  28578. * Gets the client rect of the HTML canvas attached with the current webGL context
  28579. * @returns a client rectanglee
  28580. */
  28581. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28582. /**
  28583. * Defines the hardware scaling level.
  28584. * By default the hardware scaling level is computed from the window device ratio.
  28585. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  28586. * @param level defines the level to use
  28587. */
  28588. setHardwareScalingLevel(level: number): void;
  28589. /**
  28590. * Gets the current hardware scaling level.
  28591. * By default the hardware scaling level is computed from the window device ratio.
  28592. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  28593. * @returns a number indicating the current hardware scaling level
  28594. */
  28595. getHardwareScalingLevel(): number;
  28596. /**
  28597. * Gets the list of loaded textures
  28598. * @returns an array containing all loaded textures
  28599. */
  28600. getLoadedTexturesCache(): InternalTexture[];
  28601. /**
  28602. * Gets the object containing all engine capabilities
  28603. * @returns the EngineCapabilities object
  28604. */
  28605. getCaps(): EngineCapabilities;
  28606. /**
  28607. * Gets the current depth function
  28608. * @returns a number defining the depth function
  28609. */
  28610. getDepthFunction(): Nullable<number>;
  28611. /**
  28612. * Sets the current depth function
  28613. * @param depthFunc defines the function to use
  28614. */
  28615. setDepthFunction(depthFunc: number): void;
  28616. /**
  28617. * Sets the current depth function to GREATER
  28618. */
  28619. setDepthFunctionToGreater(): void;
  28620. /**
  28621. * Sets the current depth function to GEQUAL
  28622. */
  28623. setDepthFunctionToGreaterOrEqual(): void;
  28624. /**
  28625. * Sets the current depth function to LESS
  28626. */
  28627. setDepthFunctionToLess(): void;
  28628. private _cachedStencilBuffer;
  28629. private _cachedStencilFunction;
  28630. private _cachedStencilMask;
  28631. private _cachedStencilOperationPass;
  28632. private _cachedStencilOperationFail;
  28633. private _cachedStencilOperationDepthFail;
  28634. private _cachedStencilReference;
  28635. /**
  28636. * Caches the the state of the stencil buffer
  28637. */
  28638. cacheStencilState(): void;
  28639. /**
  28640. * Restores the state of the stencil buffer
  28641. */
  28642. restoreStencilState(): void;
  28643. /**
  28644. * Sets the current depth function to LEQUAL
  28645. */
  28646. setDepthFunctionToLessOrEqual(): void;
  28647. /**
  28648. * Gets a boolean indicating if stencil buffer is enabled
  28649. * @returns the current stencil buffer state
  28650. */
  28651. getStencilBuffer(): boolean;
  28652. /**
  28653. * Enable or disable the stencil buffer
  28654. * @param enable defines if the stencil buffer must be enabled or disabled
  28655. */
  28656. setStencilBuffer(enable: boolean): void;
  28657. /**
  28658. * Gets the current stencil mask
  28659. * @returns a number defining the new stencil mask to use
  28660. */
  28661. getStencilMask(): number;
  28662. /**
  28663. * Sets the current stencil mask
  28664. * @param mask defines the new stencil mask to use
  28665. */
  28666. setStencilMask(mask: number): void;
  28667. /**
  28668. * Gets the current stencil function
  28669. * @returns a number defining the stencil function to use
  28670. */
  28671. getStencilFunction(): number;
  28672. /**
  28673. * Gets the current stencil reference value
  28674. * @returns a number defining the stencil reference value to use
  28675. */
  28676. getStencilFunctionReference(): number;
  28677. /**
  28678. * Gets the current stencil mask
  28679. * @returns a number defining the stencil mask to use
  28680. */
  28681. getStencilFunctionMask(): number;
  28682. /**
  28683. * Sets the current stencil function
  28684. * @param stencilFunc defines the new stencil function to use
  28685. */
  28686. setStencilFunction(stencilFunc: number): void;
  28687. /**
  28688. * Sets the current stencil reference
  28689. * @param reference defines the new stencil reference to use
  28690. */
  28691. setStencilFunctionReference(reference: number): void;
  28692. /**
  28693. * Sets the current stencil mask
  28694. * @param mask defines the new stencil mask to use
  28695. */
  28696. setStencilFunctionMask(mask: number): void;
  28697. /**
  28698. * Gets the current stencil operation when stencil fails
  28699. * @returns a number defining stencil operation to use when stencil fails
  28700. */
  28701. getStencilOperationFail(): number;
  28702. /**
  28703. * Gets the current stencil operation when depth fails
  28704. * @returns a number defining stencil operation to use when depth fails
  28705. */
  28706. getStencilOperationDepthFail(): number;
  28707. /**
  28708. * Gets the current stencil operation when stencil passes
  28709. * @returns a number defining stencil operation to use when stencil passes
  28710. */
  28711. getStencilOperationPass(): number;
  28712. /**
  28713. * Sets the stencil operation to use when stencil fails
  28714. * @param operation defines the stencil operation to use when stencil fails
  28715. */
  28716. setStencilOperationFail(operation: number): void;
  28717. /**
  28718. * Sets the stencil operation to use when depth fails
  28719. * @param operation defines the stencil operation to use when depth fails
  28720. */
  28721. setStencilOperationDepthFail(operation: number): void;
  28722. /**
  28723. * Sets the stencil operation to use when stencil passes
  28724. * @param operation defines the stencil operation to use when stencil passes
  28725. */
  28726. setStencilOperationPass(operation: number): void;
  28727. /**
  28728. * Sets a boolean indicating if the dithering state is enabled or disabled
  28729. * @param value defines the dithering state
  28730. */
  28731. setDitheringState(value: boolean): void;
  28732. /**
  28733. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28734. * @param value defines the rasterizer state
  28735. */
  28736. setRasterizerState(value: boolean): void;
  28737. /**
  28738. * stop executing a render loop function and remove it from the execution array
  28739. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28740. */
  28741. stopRenderLoop(renderFunction?: () => void): void;
  28742. /** @hidden */
  28743. _renderLoop(): void;
  28744. /**
  28745. * Register and execute a render loop. The engine can have more than one render function
  28746. * @param renderFunction defines the function to continuously execute
  28747. */
  28748. runRenderLoop(renderFunction: () => void): void;
  28749. /**
  28750. * Toggle full screen mode
  28751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28752. */
  28753. switchFullscreen(requestPointerLock: boolean): void;
  28754. /**
  28755. * Enters full screen mode
  28756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28757. */
  28758. enterFullscreen(requestPointerLock: boolean): void;
  28759. /**
  28760. * Exits full screen mode
  28761. */
  28762. exitFullscreen(): void;
  28763. /**
  28764. * Clear the current render buffer or the current render target (if any is set up)
  28765. * @param color defines the color to use
  28766. * @param backBuffer defines if the back buffer must be cleared
  28767. * @param depth defines if the depth buffer must be cleared
  28768. * @param stencil defines if the stencil buffer must be cleared
  28769. */
  28770. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28771. /**
  28772. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28773. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28774. * @param y defines the y-coordinate of the corner of the clear rectangle
  28775. * @param width defines the width of the clear rectangle
  28776. * @param height defines the height of the clear rectangle
  28777. * @param clearColor defines the clear color
  28778. */
  28779. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28780. /**
  28781. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28783. * @param y defines the y-coordinate of the corner of the clear rectangle
  28784. * @param width defines the width of the clear rectangle
  28785. * @param height defines the height of the clear rectangle
  28786. */
  28787. enableScissor(x: number, y: number, width: number, height: number): void;
  28788. /**
  28789. * Disable previously set scissor test rectangle
  28790. */
  28791. disableScissor(): void;
  28792. private _viewportCached;
  28793. /** @hidden */
  28794. _viewport(x: number, y: number, width: number, height: number): void;
  28795. /**
  28796. * Set the WebGL's viewport
  28797. * @param viewport defines the viewport element to be used
  28798. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28799. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28800. */
  28801. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28802. /**
  28803. * Directly set the WebGL Viewport
  28804. * @param x defines the x coordinate of the viewport (in screen space)
  28805. * @param y defines the y coordinate of the viewport (in screen space)
  28806. * @param width defines the width of the viewport (in screen space)
  28807. * @param height defines the height of the viewport (in screen space)
  28808. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  28809. */
  28810. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28811. /**
  28812. * Begin a new frame
  28813. */
  28814. beginFrame(): void;
  28815. /**
  28816. * Enf the current frame
  28817. */
  28818. endFrame(): void;
  28819. /**
  28820. * Resize the view according to the canvas' size
  28821. */
  28822. resize(): void;
  28823. /**
  28824. * Force a specific size of the canvas
  28825. * @param width defines the new canvas' width
  28826. * @param height defines the new canvas' height
  28827. */
  28828. setSize(width: number, height: number): void;
  28829. /**
  28830. * Binds the frame buffer to the specified texture.
  28831. * @param texture The texture to render to or null for the default canvas
  28832. * @param faceIndex The face of the texture to render to in case of cube texture
  28833. * @param requiredWidth The width of the target to render to
  28834. * @param requiredHeight The height of the target to render to
  28835. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28836. * @param depthStencilTexture The depth stencil texture to use to render
  28837. * @param lodLevel defines le lod level to bind to the frame buffer
  28838. */
  28839. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28840. /** @hidden */
  28841. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28842. /**
  28843. * Unbind the current render target texture from the webGL context
  28844. * @param texture defines the render target texture to unbind
  28845. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28846. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28847. */
  28848. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28849. /**
  28850. * Force the mipmap generation for the given render target texture
  28851. * @param texture defines the render target texture to use
  28852. */
  28853. generateMipMapsForCubemap(texture: InternalTexture): void;
  28854. /**
  28855. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28856. */
  28857. flushFramebuffer(): void;
  28858. /**
  28859. * Unbind the current render target and bind the default framebuffer
  28860. */
  28861. restoreDefaultFramebuffer(): void;
  28862. /**
  28863. * Create an uniform buffer
  28864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28865. * @param elements defines the content of the uniform buffer
  28866. * @returns the webGL uniform buffer
  28867. */
  28868. createUniformBuffer(elements: FloatArray): DataBuffer;
  28869. /**
  28870. * Create a dynamic uniform buffer
  28871. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28872. * @param elements defines the content of the uniform buffer
  28873. * @returns the webGL uniform buffer
  28874. */
  28875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28876. /**
  28877. * Update an existing uniform buffer
  28878. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28879. * @param uniformBuffer defines the target uniform buffer
  28880. * @param elements defines the content to update
  28881. * @param offset defines the offset in the uniform buffer where update should start
  28882. * @param count defines the size of the data to update
  28883. */
  28884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28885. private _resetVertexBufferBinding;
  28886. /**
  28887. * Creates a vertex buffer
  28888. * @param data the data for the vertex buffer
  28889. * @returns the new WebGL static buffer
  28890. */
  28891. createVertexBuffer(data: DataArray): DataBuffer;
  28892. /**
  28893. * Creates a dynamic vertex buffer
  28894. * @param data the data for the dynamic vertex buffer
  28895. * @returns the new WebGL dynamic buffer
  28896. */
  28897. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28898. /**
  28899. * Update a dynamic index buffer
  28900. * @param indexBuffer defines the target index buffer
  28901. * @param indices defines the data to update
  28902. * @param offset defines the offset in the target index buffer where update should start
  28903. */
  28904. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28905. /**
  28906. * Updates a dynamic vertex buffer.
  28907. * @param vertexBuffer the vertex buffer to update
  28908. * @param data the data used to update the vertex buffer
  28909. * @param byteOffset the byte offset of the data
  28910. * @param byteLength the byte length of the data
  28911. */
  28912. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28913. private _resetIndexBufferBinding;
  28914. /**
  28915. * Creates a new index buffer
  28916. * @param indices defines the content of the index buffer
  28917. * @param updatable defines if the index buffer must be updatable
  28918. * @returns a new webGL buffer
  28919. */
  28920. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28921. /**
  28922. * Bind a webGL buffer to the webGL context
  28923. * @param buffer defines the buffer to bind
  28924. */
  28925. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28926. /**
  28927. * Bind an uniform buffer to the current webGL context
  28928. * @param buffer defines the buffer to bind
  28929. */
  28930. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28931. /**
  28932. * Bind a buffer to the current webGL context at a given location
  28933. * @param buffer defines the buffer to bind
  28934. * @param location defines the index where to bind the buffer
  28935. */
  28936. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28937. /**
  28938. * Bind a specific block at a given index in a specific shader program
  28939. * @param pipelineContext defines the pipeline context to use
  28940. * @param blockName defines the block name
  28941. * @param index defines the index where to bind the block
  28942. */
  28943. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28944. private bindIndexBuffer;
  28945. private bindBuffer;
  28946. /**
  28947. * update the bound buffer with the given data
  28948. * @param data defines the data to update
  28949. */
  28950. updateArrayBuffer(data: Float32Array): void;
  28951. private _vertexAttribPointer;
  28952. private _bindIndexBufferWithCache;
  28953. private _bindVertexBuffersAttributes;
  28954. /**
  28955. * Records a vertex array object
  28956. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28957. * @param vertexBuffers defines the list of vertex buffers to store
  28958. * @param indexBuffer defines the index buffer to store
  28959. * @param effect defines the effect to store
  28960. * @returns the new vertex array object
  28961. */
  28962. recordVertexArrayObject(vertexBuffers: {
  28963. [key: string]: VertexBuffer;
  28964. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28965. /**
  28966. * Bind a specific vertex array object
  28967. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28968. * @param vertexArrayObject defines the vertex array object to bind
  28969. * @param indexBuffer defines the index buffer to bind
  28970. */
  28971. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28972. /**
  28973. * Bind webGl buffers directly to the webGL context
  28974. * @param vertexBuffer defines the vertex buffer to bind
  28975. * @param indexBuffer defines the index buffer to bind
  28976. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28977. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28978. * @param effect defines the effect associated with the vertex buffer
  28979. */
  28980. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28981. private _unbindVertexArrayObject;
  28982. /**
  28983. * Bind a list of vertex buffers to the webGL context
  28984. * @param vertexBuffers defines the list of vertex buffers to bind
  28985. * @param indexBuffer defines the index buffer to bind
  28986. * @param effect defines the effect associated with the vertex buffers
  28987. */
  28988. bindBuffers(vertexBuffers: {
  28989. [key: string]: Nullable<VertexBuffer>;
  28990. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28991. /**
  28992. * Unbind all instance attributes
  28993. */
  28994. unbindInstanceAttributes(): void;
  28995. /**
  28996. * Release and free the memory of a vertex array object
  28997. * @param vao defines the vertex array object to delete
  28998. */
  28999. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29000. /** @hidden */
  29001. _releaseBuffer(buffer: DataBuffer): boolean;
  29002. /**
  29003. * Creates a webGL buffer to use with instanciation
  29004. * @param capacity defines the size of the buffer
  29005. * @returns the webGL buffer
  29006. */
  29007. createInstancesBuffer(capacity: number): DataBuffer;
  29008. /**
  29009. * Delete a webGL buffer used with instanciation
  29010. * @param buffer defines the webGL buffer to delete
  29011. */
  29012. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29013. /**
  29014. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29015. * @param instancesBuffer defines the webGL buffer to update and bind
  29016. * @param data defines the data to store in the buffer
  29017. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29018. */
  29019. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29020. /**
  29021. * Apply all cached states (depth, culling, stencil and alpha)
  29022. */
  29023. applyStates(): void;
  29024. /**
  29025. * Send a draw order
  29026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29027. * @param indexStart defines the starting index
  29028. * @param indexCount defines the number of index to draw
  29029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29030. */
  29031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29032. /**
  29033. * Draw a list of points
  29034. * @param verticesStart defines the index of first vertex to draw
  29035. * @param verticesCount defines the count of vertices to draw
  29036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29037. */
  29038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29039. /**
  29040. * Draw a list of unindexed primitives
  29041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29042. * @param verticesStart defines the index of first vertex to draw
  29043. * @param verticesCount defines the count of vertices to draw
  29044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29045. */
  29046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29047. /**
  29048. * Draw a list of indexed primitives
  29049. * @param fillMode defines the primitive to use
  29050. * @param indexStart defines the starting index
  29051. * @param indexCount defines the number of index to draw
  29052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29053. */
  29054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29055. /**
  29056. * Draw a list of unindexed primitives
  29057. * @param fillMode defines the primitive to use
  29058. * @param verticesStart defines the index of first vertex to draw
  29059. * @param verticesCount defines the count of vertices to draw
  29060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29061. */
  29062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29063. private _drawMode;
  29064. /** @hidden */
  29065. _releaseEffect(effect: Effect): void;
  29066. /** @hidden */
  29067. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29068. /**
  29069. * Create a new effect (used to store vertex/fragment shaders)
  29070. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29071. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29072. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29073. * @param samplers defines an array of string used to represent textures
  29074. * @param defines defines the string containing the defines to use to compile the shaders
  29075. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29076. * @param onCompiled defines a function to call when the effect creation is successful
  29077. * @param onError defines a function to call when the effect creation has failed
  29078. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29079. * @returns the new Effect
  29080. */
  29081. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29082. private _compileShader;
  29083. private _compileRawShader;
  29084. /**
  29085. * Directly creates a webGL program
  29086. * @param pipelineContext defines the pipeline context to attach to
  29087. * @param vertexCode defines the vertex shader code to use
  29088. * @param fragmentCode defines the fragment shader code to use
  29089. * @param context defines the webGL context to use (if not set, the current one will be used)
  29090. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29091. * @returns the new webGL program
  29092. */
  29093. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29094. /**
  29095. * Creates a webGL program
  29096. * @param pipelineContext defines the pipeline context to attach to
  29097. * @param vertexCode defines the vertex shader code to use
  29098. * @param fragmentCode defines the fragment shader code to use
  29099. * @param defines defines the string containing the defines to use to compile the shaders
  29100. * @param context defines the webGL context to use (if not set, the current one will be used)
  29101. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29102. * @returns the new webGL program
  29103. */
  29104. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29105. /**
  29106. * Creates a new pipeline context
  29107. * @returns the new pipeline
  29108. */
  29109. createPipelineContext(): WebGLPipelineContext;
  29110. private _createShaderProgram;
  29111. private _finalizePipelineContext;
  29112. /** @hidden */
  29113. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29114. /** @hidden */
  29115. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29116. /** @hidden */
  29117. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29118. /**
  29119. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29120. * @param pipelineContext defines the pipeline context to use
  29121. * @param uniformsNames defines the list of uniform names
  29122. * @returns an array of webGL uniform locations
  29123. */
  29124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29125. /**
  29126. * Gets the lsit of active attributes for a given webGL program
  29127. * @param pipelineContext defines the pipeline context to use
  29128. * @param attributesNames defines the list of attribute names to get
  29129. * @returns an array of indices indicating the offset of each attribute
  29130. */
  29131. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29132. /**
  29133. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29134. * @param effect defines the effect to activate
  29135. */
  29136. enableEffect(effect: Nullable<Effect>): void;
  29137. /**
  29138. * Set the value of an uniform to an array of int32
  29139. * @param uniform defines the webGL uniform location where to store the value
  29140. * @param array defines the array of int32 to store
  29141. */
  29142. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29143. /**
  29144. * Set the value of an uniform to an array of int32 (stored as vec2)
  29145. * @param uniform defines the webGL uniform location where to store the value
  29146. * @param array defines the array of int32 to store
  29147. */
  29148. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29149. /**
  29150. * Set the value of an uniform to an array of int32 (stored as vec3)
  29151. * @param uniform defines the webGL uniform location where to store the value
  29152. * @param array defines the array of int32 to store
  29153. */
  29154. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29155. /**
  29156. * Set the value of an uniform to an array of int32 (stored as vec4)
  29157. * @param uniform defines the webGL uniform location where to store the value
  29158. * @param array defines the array of int32 to store
  29159. */
  29160. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29161. /**
  29162. * Set the value of an uniform to an array of float32
  29163. * @param uniform defines the webGL uniform location where to store the value
  29164. * @param array defines the array of float32 to store
  29165. */
  29166. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29167. /**
  29168. * Set the value of an uniform to an array of float32 (stored as vec2)
  29169. * @param uniform defines the webGL uniform location where to store the value
  29170. * @param array defines the array of float32 to store
  29171. */
  29172. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29173. /**
  29174. * Set the value of an uniform to an array of float32 (stored as vec3)
  29175. * @param uniform defines the webGL uniform location where to store the value
  29176. * @param array defines the array of float32 to store
  29177. */
  29178. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29179. /**
  29180. * Set the value of an uniform to an array of float32 (stored as vec4)
  29181. * @param uniform defines the webGL uniform location where to store the value
  29182. * @param array defines the array of float32 to store
  29183. */
  29184. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29185. /**
  29186. * Set the value of an uniform to an array of number
  29187. * @param uniform defines the webGL uniform location where to store the value
  29188. * @param array defines the array of number to store
  29189. */
  29190. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29191. /**
  29192. * Set the value of an uniform to an array of number (stored as vec2)
  29193. * @param uniform defines the webGL uniform location where to store the value
  29194. * @param array defines the array of number to store
  29195. */
  29196. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29197. /**
  29198. * Set the value of an uniform to an array of number (stored as vec3)
  29199. * @param uniform defines the webGL uniform location where to store the value
  29200. * @param array defines the array of number to store
  29201. */
  29202. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29203. /**
  29204. * Set the value of an uniform to an array of number (stored as vec4)
  29205. * @param uniform defines the webGL uniform location where to store the value
  29206. * @param array defines the array of number to store
  29207. */
  29208. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29209. /**
  29210. * Set the value of an uniform to an array of float32 (stored as matrices)
  29211. * @param uniform defines the webGL uniform location where to store the value
  29212. * @param matrices defines the array of float32 to store
  29213. */
  29214. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29215. /**
  29216. * Set the value of an uniform to a matrix
  29217. * @param uniform defines the webGL uniform location where to store the value
  29218. * @param matrix defines the matrix to store
  29219. */
  29220. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29221. /**
  29222. * Set the value of an uniform to a matrix (3x3)
  29223. * @param uniform defines the webGL uniform location where to store the value
  29224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29225. */
  29226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29227. /**
  29228. * Set the value of an uniform to a matrix (2x2)
  29229. * @param uniform defines the webGL uniform location where to store the value
  29230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29231. */
  29232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29233. /**
  29234. * Set the value of an uniform to a number (int)
  29235. * @param uniform defines the webGL uniform location where to store the value
  29236. * @param value defines the int number to store
  29237. */
  29238. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29239. /**
  29240. * Set the value of an uniform to a number (float)
  29241. * @param uniform defines the webGL uniform location where to store the value
  29242. * @param value defines the float number to store
  29243. */
  29244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29245. /**
  29246. * Set the value of an uniform to a vec2
  29247. * @param uniform defines the webGL uniform location where to store the value
  29248. * @param x defines the 1st component of the value
  29249. * @param y defines the 2nd component of the value
  29250. */
  29251. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29252. /**
  29253. * Set the value of an uniform to a vec3
  29254. * @param uniform defines the webGL uniform location where to store the value
  29255. * @param x defines the 1st component of the value
  29256. * @param y defines the 2nd component of the value
  29257. * @param z defines the 3rd component of the value
  29258. */
  29259. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29260. /**
  29261. * Set the value of an uniform to a boolean
  29262. * @param uniform defines the webGL uniform location where to store the value
  29263. * @param bool defines the boolean to store
  29264. */
  29265. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29266. /**
  29267. * Set the value of an uniform to a vec4
  29268. * @param uniform defines the webGL uniform location where to store the value
  29269. * @param x defines the 1st component of the value
  29270. * @param y defines the 2nd component of the value
  29271. * @param z defines the 3rd component of the value
  29272. * @param w defines the 4th component of the value
  29273. */
  29274. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29275. /**
  29276. * Set the value of an uniform to a Color3
  29277. * @param uniform defines the webGL uniform location where to store the value
  29278. * @param color3 defines the color to store
  29279. */
  29280. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29281. /**
  29282. * Set the value of an uniform to a Color3 and an alpha value
  29283. * @param uniform defines the webGL uniform location where to store the value
  29284. * @param color3 defines the color to store
  29285. * @param alpha defines the alpha component to store
  29286. */
  29287. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29288. /**
  29289. * Sets a Color4 on a uniform variable
  29290. * @param uniform defines the uniform location
  29291. * @param color4 defines the value to be set
  29292. */
  29293. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29294. /**
  29295. * Set various states to the webGL context
  29296. * @param culling defines backface culling state
  29297. * @param zOffset defines the value to apply to zOffset (0 by default)
  29298. * @param force defines if states must be applied even if cache is up to date
  29299. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29300. */
  29301. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29302. /**
  29303. * Set the z offset to apply to current rendering
  29304. * @param value defines the offset to apply
  29305. */
  29306. setZOffset(value: number): void;
  29307. /**
  29308. * Gets the current value of the zOffset
  29309. * @returns the current zOffset state
  29310. */
  29311. getZOffset(): number;
  29312. /**
  29313. * Enable or disable depth buffering
  29314. * @param enable defines the state to set
  29315. */
  29316. setDepthBuffer(enable: boolean): void;
  29317. /**
  29318. * Gets a boolean indicating if depth writing is enabled
  29319. * @returns the current depth writing state
  29320. */
  29321. getDepthWrite(): boolean;
  29322. /**
  29323. * Enable or disable depth writing
  29324. * @param enable defines the state to set
  29325. */
  29326. setDepthWrite(enable: boolean): void;
  29327. /**
  29328. * Enable or disable color writing
  29329. * @param enable defines the state to set
  29330. */
  29331. setColorWrite(enable: boolean): void;
  29332. /**
  29333. * Gets a boolean indicating if color writing is enabled
  29334. * @returns the current color writing state
  29335. */
  29336. getColorWrite(): boolean;
  29337. /**
  29338. * Sets alpha constants used by some alpha blending modes
  29339. * @param r defines the red component
  29340. * @param g defines the green component
  29341. * @param b defines the blue component
  29342. * @param a defines the alpha component
  29343. */
  29344. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29345. /**
  29346. * Sets the current alpha mode
  29347. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29348. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29349. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29350. */
  29351. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29352. /**
  29353. * Gets the current alpha mode
  29354. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29355. * @returns the current alpha mode
  29356. */
  29357. getAlphaMode(): number;
  29358. /**
  29359. * Clears the list of texture accessible through engine.
  29360. * This can help preventing texture load conflict due to name collision.
  29361. */
  29362. clearInternalTexturesCache(): void;
  29363. /**
  29364. * Force the entire cache to be cleared
  29365. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29366. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29367. */
  29368. wipeCaches(bruteForce?: boolean): void;
  29369. /**
  29370. * Set the compressed texture format to use, based on the formats you have, and the formats
  29371. * supported by the hardware / browser.
  29372. *
  29373. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29374. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29375. * to API arguments needed to compressed textures. This puts the burden on the container
  29376. * generator to house the arcane code for determining these for current & future formats.
  29377. *
  29378. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29379. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29380. *
  29381. * Note: The result of this call is not taken into account when a texture is base64.
  29382. *
  29383. * @param formatsAvailable defines the list of those format families you have created
  29384. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29385. *
  29386. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29387. * @returns The extension selected.
  29388. */
  29389. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29390. /** @hidden */
  29391. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29392. min: number;
  29393. mag: number;
  29394. };
  29395. /** @hidden */
  29396. _createTexture(): WebGLTexture;
  29397. /**
  29398. * Usually called from Texture.ts.
  29399. * Passed information to create a WebGLTexture
  29400. * @param urlArg defines a value which contains one of the following:
  29401. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29402. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29403. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29405. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  29406. * @param scene needed for loading to the correct scene
  29407. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29408. * @param onLoad optional callback to be called upon successful completion
  29409. * @param onError optional callback to be called upon failure
  29410. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  29411. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29412. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29413. * @param forcedExtension defines the extension to use to pick the right loader
  29414. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29415. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29416. */
  29417. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29418. private _rescaleTexture;
  29419. private _unpackFlipYCached;
  29420. /**
  29421. * In case you are sharing the context with other applications, it might
  29422. * be interested to not cache the unpack flip y state to ensure a consistent
  29423. * value would be set.
  29424. */
  29425. enableUnpackFlipYCached: boolean;
  29426. /** @hidden */
  29427. _unpackFlipY(value: boolean): void;
  29428. /** @hidden */
  29429. _getUnpackAlignement(): number;
  29430. /**
  29431. * Creates a dynamic texture
  29432. * @param width defines the width of the texture
  29433. * @param height defines the height of the texture
  29434. * @param generateMipMaps defines if the engine should generate the mip levels
  29435. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29436. * @returns the dynamic texture inside an InternalTexture
  29437. */
  29438. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29439. /**
  29440. * Update the sampling mode of a given texture
  29441. * @param samplingMode defines the required sampling mode
  29442. * @param texture defines the texture to update
  29443. */
  29444. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29445. /**
  29446. * Update the content of a dynamic texture
  29447. * @param texture defines the texture to update
  29448. * @param canvas defines the canvas containing the source
  29449. * @param invertY defines if data must be stored with Y axis inverted
  29450. * @param premulAlpha defines if alpha is stored as premultiplied
  29451. * @param format defines the format of the data
  29452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29453. */
  29454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29455. /**
  29456. * Update a video texture
  29457. * @param texture defines the texture to update
  29458. * @param video defines the video element to use
  29459. * @param invertY defines if data must be stored with Y axis inverted
  29460. */
  29461. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29462. /**
  29463. * Updates a depth texture Comparison Mode and Function.
  29464. * If the comparison Function is equal to 0, the mode will be set to none.
  29465. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29466. * @param texture The texture to set the comparison function for
  29467. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29468. */
  29469. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29470. /** @hidden */
  29471. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29472. width: number;
  29473. height: number;
  29474. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29475. /**
  29476. * Creates a depth stencil texture.
  29477. * This is only available in WebGL 2 or with the depth texture extension available.
  29478. * @param size The size of face edge in the texture.
  29479. * @param options The options defining the texture.
  29480. * @returns The texture
  29481. */
  29482. createDepthStencilTexture(size: number | {
  29483. width: number;
  29484. height: number;
  29485. }, options: DepthTextureCreationOptions): InternalTexture;
  29486. /**
  29487. * Creates a depth stencil texture.
  29488. * This is only available in WebGL 2 or with the depth texture extension available.
  29489. * @param size The size of face edge in the texture.
  29490. * @param options The options defining the texture.
  29491. * @returns The texture
  29492. */
  29493. private _createDepthStencilTexture;
  29494. /**
  29495. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29496. * @param renderTarget The render target to set the frame buffer for
  29497. */
  29498. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29499. /**
  29500. * Creates a new render target texture
  29501. * @param size defines the size of the texture
  29502. * @param options defines the options used to create the texture
  29503. * @returns a new render target texture stored in an InternalTexture
  29504. */
  29505. createRenderTargetTexture(size: number | {
  29506. width: number;
  29507. height: number;
  29508. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29509. /** @hidden */
  29510. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29511. /**
  29512. * Updates the sample count of a render target texture
  29513. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29514. * @param texture defines the texture to update
  29515. * @param samples defines the sample count to set
  29516. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29517. */
  29518. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29519. /** @hidden */
  29520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29521. /** @hidden */
  29522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29523. /** @hidden */
  29524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29525. /** @hidden */
  29526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29527. /**
  29528. * @hidden
  29529. */
  29530. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29531. private _prepareWebGLTextureContinuation;
  29532. private _prepareWebGLTexture;
  29533. /** @hidden */
  29534. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29535. /** @hidden */
  29536. _releaseFramebufferObjects(texture: InternalTexture): void;
  29537. /** @hidden */
  29538. _releaseTexture(texture: InternalTexture): void;
  29539. private setProgram;
  29540. private _boundUniforms;
  29541. /**
  29542. * Binds an effect to the webGL context
  29543. * @param effect defines the effect to bind
  29544. */
  29545. bindSamplers(effect: Effect): void;
  29546. private _activateCurrentTexture;
  29547. /** @hidden */
  29548. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29549. /** @hidden */
  29550. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29551. /**
  29552. * Sets a texture to the webGL context from a postprocess
  29553. * @param channel defines the channel to use
  29554. * @param postProcess defines the source postprocess
  29555. */
  29556. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29557. /**
  29558. * Binds the output of the passed in post process to the texture channel specified
  29559. * @param channel The channel the texture should be bound to
  29560. * @param postProcess The post process which's output should be bound
  29561. */
  29562. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29563. /**
  29564. * Unbind all textures from the webGL context
  29565. */
  29566. unbindAllTextures(): void;
  29567. /**
  29568. * Sets a texture to the according uniform.
  29569. * @param channel The texture channel
  29570. * @param uniform The uniform to set
  29571. * @param texture The texture to apply
  29572. */
  29573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29574. /**
  29575. * Sets a depth stencil texture from a render target to the according uniform.
  29576. * @param channel The texture channel
  29577. * @param uniform The uniform to set
  29578. * @param texture The render target texture containing the depth stencil texture to apply
  29579. */
  29580. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29581. private _bindSamplerUniformToChannel;
  29582. private _getTextureWrapMode;
  29583. private _setTexture;
  29584. /**
  29585. * Sets an array of texture to the webGL context
  29586. * @param channel defines the channel where the texture array must be set
  29587. * @param uniform defines the associated uniform location
  29588. * @param textures defines the array of textures to bind
  29589. */
  29590. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29591. /** @hidden */
  29592. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29593. private _setTextureParameterFloat;
  29594. private _setTextureParameterInteger;
  29595. /**
  29596. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29597. * @param x defines the x coordinate of the rectangle where pixels must be read
  29598. * @param y defines the y coordinate of the rectangle where pixels must be read
  29599. * @param width defines the width of the rectangle where pixels must be read
  29600. * @param height defines the height of the rectangle where pixels must be read
  29601. * @returns a Uint8Array containing RGBA colors
  29602. */
  29603. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29604. /**
  29605. * Add an externaly attached data from its key.
  29606. * This method call will fail and return false, if such key already exists.
  29607. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29608. * @param key the unique key that identifies the data
  29609. * @param data the data object to associate to the key for this Engine instance
  29610. * @return true if no such key were already present and the data was added successfully, false otherwise
  29611. */
  29612. addExternalData<T>(key: string, data: T): boolean;
  29613. /**
  29614. * Get an externaly attached data from its key
  29615. * @param key the unique key that identifies the data
  29616. * @return the associated data, if present (can be null), or undefined if not present
  29617. */
  29618. getExternalData<T>(key: string): T;
  29619. /**
  29620. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29621. * @param key the unique key that identifies the data
  29622. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29623. * @return the associated data, can be null if the factory returned null.
  29624. */
  29625. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29626. /**
  29627. * Remove an externaly attached data from the Engine instance
  29628. * @param key the unique key that identifies the data
  29629. * @return true if the data was successfully removed, false if it doesn't exist
  29630. */
  29631. removeExternalData(key: string): boolean;
  29632. /**
  29633. * Unbind all vertex attributes from the webGL context
  29634. */
  29635. unbindAllAttributes(): void;
  29636. /**
  29637. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  29638. */
  29639. releaseEffects(): void;
  29640. /**
  29641. * Dispose and release all associated resources
  29642. */
  29643. dispose(): void;
  29644. /**
  29645. * Display the loading screen
  29646. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29647. */
  29648. displayLoadingUI(): void;
  29649. /**
  29650. * Hide the loading screen
  29651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29652. */
  29653. hideLoadingUI(): void;
  29654. /**
  29655. * Gets the current loading screen object
  29656. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29657. */
  29658. /**
  29659. * Sets the current loading screen object
  29660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29661. */
  29662. loadingScreen: ILoadingScreen;
  29663. /**
  29664. * Sets the current loading screen text
  29665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29666. */
  29667. loadingUIText: string;
  29668. /**
  29669. * Sets the current loading screen background color
  29670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29671. */
  29672. loadingUIBackgroundColor: string;
  29673. /**
  29674. * Attach a new callback raised when context lost event is fired
  29675. * @param callback defines the callback to call
  29676. */
  29677. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29678. /**
  29679. * Attach a new callback raised when context restored event is fired
  29680. * @param callback defines the callback to call
  29681. */
  29682. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29683. /**
  29684. * Gets the source code of the vertex shader associated with a specific webGL program
  29685. * @param program defines the program to use
  29686. * @returns a string containing the source code of the vertex shader associated with the program
  29687. */
  29688. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29689. /**
  29690. * Gets the source code of the fragment shader associated with a specific webGL program
  29691. * @param program defines the program to use
  29692. * @returns a string containing the source code of the fragment shader associated with the program
  29693. */
  29694. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29695. /**
  29696. * Get the current error code of the webGL context
  29697. * @returns the error code
  29698. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29699. */
  29700. getError(): number;
  29701. /**
  29702. * Gets the current framerate
  29703. * @returns a number representing the framerate
  29704. */
  29705. getFps(): number;
  29706. /**
  29707. * Gets the time spent between current and previous frame
  29708. * @returns a number representing the delta time in ms
  29709. */
  29710. getDeltaTime(): number;
  29711. private _measureFps;
  29712. /** @hidden */
  29713. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29714. private _canRenderToFloatFramebuffer;
  29715. private _canRenderToHalfFloatFramebuffer;
  29716. private _canRenderToFramebuffer;
  29717. /** @hidden */
  29718. _getWebGLTextureType(type: number): number;
  29719. /** @hidden */
  29720. _getInternalFormat(format: number): number;
  29721. /** @hidden */
  29722. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29723. /** @hidden */
  29724. _getRGBAMultiSampleBufferFormat(type: number): number;
  29725. /** @hidden */
  29726. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29727. /** @hidden */
  29728. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29729. /**
  29730. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29731. * @returns true if the engine can be created
  29732. * @ignorenaming
  29733. */
  29734. static isSupported(): boolean;
  29735. }
  29736. }
  29737. declare module "babylonjs/Materials/effect" {
  29738. import { Observable } from "babylonjs/Misc/observable";
  29739. import { Nullable } from "babylonjs/types";
  29740. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29741. import { IDisposable } from "babylonjs/scene";
  29742. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29743. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29744. import { Engine } from "babylonjs/Engines/engine";
  29745. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29748. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29750. /**
  29751. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29752. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29753. */
  29754. export class EffectFallbacks {
  29755. private _defines;
  29756. private _currentRank;
  29757. private _maxRank;
  29758. private _mesh;
  29759. /**
  29760. * Removes the fallback from the bound mesh.
  29761. */
  29762. unBindMesh(): void;
  29763. /**
  29764. * Adds a fallback on the specified property.
  29765. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29766. * @param define The name of the define in the shader
  29767. */
  29768. addFallback(rank: number, define: string): void;
  29769. /**
  29770. * Sets the mesh to use CPU skinning when needing to fallback.
  29771. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29772. * @param mesh The mesh to use the fallbacks.
  29773. */
  29774. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29775. /**
  29776. * Checks to see if more fallbacks are still availible.
  29777. */
  29778. readonly isMoreFallbacks: boolean;
  29779. /**
  29780. * Removes the defines that shoould be removed when falling back.
  29781. * @param currentDefines defines the current define statements for the shader.
  29782. * @param effect defines the current effect we try to compile
  29783. * @returns The resulting defines with defines of the current rank removed.
  29784. */
  29785. reduce(currentDefines: string, effect: Effect): string;
  29786. }
  29787. /**
  29788. * Options to be used when creating an effect.
  29789. */
  29790. export class EffectCreationOptions {
  29791. /**
  29792. * Atrributes that will be used in the shader.
  29793. */
  29794. attributes: string[];
  29795. /**
  29796. * Uniform varible names that will be set in the shader.
  29797. */
  29798. uniformsNames: string[];
  29799. /**
  29800. * Uniform buffer varible names that will be set in the shader.
  29801. */
  29802. uniformBuffersNames: string[];
  29803. /**
  29804. * Sampler texture variable names that will be set in the shader.
  29805. */
  29806. samplers: string[];
  29807. /**
  29808. * Define statements that will be set in the shader.
  29809. */
  29810. defines: any;
  29811. /**
  29812. * Possible fallbacks for this effect to improve performance when needed.
  29813. */
  29814. fallbacks: Nullable<EffectFallbacks>;
  29815. /**
  29816. * Callback that will be called when the shader is compiled.
  29817. */
  29818. onCompiled: Nullable<(effect: Effect) => void>;
  29819. /**
  29820. * Callback that will be called if an error occurs during shader compilation.
  29821. */
  29822. onError: Nullable<(effect: Effect, errors: string) => void>;
  29823. /**
  29824. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29825. */
  29826. indexParameters: any;
  29827. /**
  29828. * Max number of lights that can be used in the shader.
  29829. */
  29830. maxSimultaneousLights: number;
  29831. /**
  29832. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29833. */
  29834. transformFeedbackVaryings: Nullable<string[]>;
  29835. }
  29836. /**
  29837. * Effect containing vertex and fragment shader that can be executed on an object.
  29838. */
  29839. export class Effect implements IDisposable {
  29840. /**
  29841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29842. */
  29843. static ShadersRepository: string;
  29844. /**
  29845. * Name of the effect.
  29846. */
  29847. name: any;
  29848. /**
  29849. * String container all the define statements that should be set on the shader.
  29850. */
  29851. defines: string;
  29852. /**
  29853. * Callback that will be called when the shader is compiled.
  29854. */
  29855. onCompiled: Nullable<(effect: Effect) => void>;
  29856. /**
  29857. * Callback that will be called if an error occurs during shader compilation.
  29858. */
  29859. onError: Nullable<(effect: Effect, errors: string) => void>;
  29860. /**
  29861. * Callback that will be called when effect is bound.
  29862. */
  29863. onBind: Nullable<(effect: Effect) => void>;
  29864. /**
  29865. * Unique ID of the effect.
  29866. */
  29867. uniqueId: number;
  29868. /**
  29869. * Observable that will be called when the shader is compiled.
  29870. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29871. */
  29872. onCompileObservable: Observable<Effect>;
  29873. /**
  29874. * Observable that will be called if an error occurs during shader compilation.
  29875. */
  29876. onErrorObservable: Observable<Effect>;
  29877. /** @hidden */
  29878. _onBindObservable: Nullable<Observable<Effect>>;
  29879. /**
  29880. * Observable that will be called when effect is bound.
  29881. */
  29882. readonly onBindObservable: Observable<Effect>;
  29883. /** @hidden */
  29884. _bonesComputationForcedToCPU: boolean;
  29885. private static _uniqueIdSeed;
  29886. private _engine;
  29887. private _uniformBuffersNames;
  29888. private _uniformsNames;
  29889. private _samplerList;
  29890. private _samplers;
  29891. private _isReady;
  29892. private _compilationError;
  29893. private _attributesNames;
  29894. private _attributes;
  29895. private _uniforms;
  29896. /**
  29897. * Key for the effect.
  29898. * @hidden
  29899. */
  29900. _key: string;
  29901. private _indexParameters;
  29902. private _fallbacks;
  29903. private _vertexSourceCode;
  29904. private _fragmentSourceCode;
  29905. private _vertexSourceCodeOverride;
  29906. private _fragmentSourceCodeOverride;
  29907. private _transformFeedbackVaryings;
  29908. /**
  29909. * Compiled shader to webGL program.
  29910. * @hidden
  29911. */
  29912. _pipelineContext: IPipelineContext;
  29913. private _valueCache;
  29914. private static _baseCache;
  29915. /**
  29916. * Instantiates an effect.
  29917. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29918. * @param baseName Name of the effect.
  29919. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29920. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29921. * @param samplers List of sampler variables that will be passed to the shader.
  29922. * @param engine Engine to be used to render the effect
  29923. * @param defines Define statements to be added to the shader.
  29924. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29925. * @param onCompiled Callback that will be called when the shader is compiled.
  29926. * @param onError Callback that will be called if an error occurs during shader compilation.
  29927. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29928. */
  29929. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29930. /**
  29931. * Unique key for this effect
  29932. */
  29933. readonly key: string;
  29934. /**
  29935. * If the effect has been compiled and prepared.
  29936. * @returns if the effect is compiled and prepared.
  29937. */
  29938. isReady(): boolean;
  29939. /**
  29940. * The engine the effect was initialized with.
  29941. * @returns the engine.
  29942. */
  29943. getEngine(): Engine;
  29944. /**
  29945. * The pipeline context for this effect
  29946. * @returns the associated pipeline context
  29947. */
  29948. getPipelineContext(): IPipelineContext;
  29949. /**
  29950. * The set of names of attribute variables for the shader.
  29951. * @returns An array of attribute names.
  29952. */
  29953. getAttributesNames(): string[];
  29954. /**
  29955. * Returns the attribute at the given index.
  29956. * @param index The index of the attribute.
  29957. * @returns The location of the attribute.
  29958. */
  29959. getAttributeLocation(index: number): number;
  29960. /**
  29961. * Returns the attribute based on the name of the variable.
  29962. * @param name of the attribute to look up.
  29963. * @returns the attribute location.
  29964. */
  29965. getAttributeLocationByName(name: string): number;
  29966. /**
  29967. * The number of attributes.
  29968. * @returns the numnber of attributes.
  29969. */
  29970. getAttributesCount(): number;
  29971. /**
  29972. * Gets the index of a uniform variable.
  29973. * @param uniformName of the uniform to look up.
  29974. * @returns the index.
  29975. */
  29976. getUniformIndex(uniformName: string): number;
  29977. /**
  29978. * Returns the attribute based on the name of the variable.
  29979. * @param uniformName of the uniform to look up.
  29980. * @returns the location of the uniform.
  29981. */
  29982. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29983. /**
  29984. * Returns an array of sampler variable names
  29985. * @returns The array of sampler variable neames.
  29986. */
  29987. getSamplers(): string[];
  29988. /**
  29989. * The error from the last compilation.
  29990. * @returns the error string.
  29991. */
  29992. getCompilationError(): string;
  29993. /**
  29994. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29995. * @param func The callback to be used.
  29996. */
  29997. executeWhenCompiled(func: (effect: Effect) => void): void;
  29998. private _checkIsReady;
  29999. /** @hidden */
  30000. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30001. /** @hidden */
  30002. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30003. /** @hidden */
  30004. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30005. private _processShaderConversion;
  30006. private _processIncludes;
  30007. private _processPrecision;
  30008. /**
  30009. * Recompiles the webGL program
  30010. * @param vertexSourceCode The source code for the vertex shader.
  30011. * @param fragmentSourceCode The source code for the fragment shader.
  30012. * @param onCompiled Callback called when completed.
  30013. * @param onError Callback called on error.
  30014. * @hidden
  30015. */
  30016. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30017. /**
  30018. * Prepares the effect
  30019. * @hidden
  30020. */
  30021. _prepareEffect(): void;
  30022. /**
  30023. * Checks if the effect is supported. (Must be called after compilation)
  30024. */
  30025. readonly isSupported: boolean;
  30026. /**
  30027. * Binds a texture to the engine to be used as output of the shader.
  30028. * @param channel Name of the output variable.
  30029. * @param texture Texture to bind.
  30030. * @hidden
  30031. */
  30032. _bindTexture(channel: string, texture: InternalTexture): void;
  30033. /**
  30034. * Sets a texture on the engine to be used in the shader.
  30035. * @param channel Name of the sampler variable.
  30036. * @param texture Texture to set.
  30037. */
  30038. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30039. /**
  30040. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30041. * @param channel Name of the sampler variable.
  30042. * @param texture Texture to set.
  30043. */
  30044. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30045. /**
  30046. * Sets an array of textures on the engine to be used in the shader.
  30047. * @param channel Name of the variable.
  30048. * @param textures Textures to set.
  30049. */
  30050. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30051. /**
  30052. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  30053. * @param channel Name of the sampler variable.
  30054. * @param postProcess Post process to get the input texture from.
  30055. */
  30056. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30057. /**
  30058. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30059. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  30060. * @param channel Name of the sampler variable.
  30061. * @param postProcess Post process to get the output texture from.
  30062. */
  30063. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30064. /** @hidden */
  30065. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30066. /** @hidden */
  30067. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30068. /** @hidden */
  30069. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30070. /** @hidden */
  30071. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30072. /**
  30073. * Binds a buffer to a uniform.
  30074. * @param buffer Buffer to bind.
  30075. * @param name Name of the uniform variable to bind to.
  30076. */
  30077. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30078. /**
  30079. * Binds block to a uniform.
  30080. * @param blockName Name of the block to bind.
  30081. * @param index Index to bind.
  30082. */
  30083. bindUniformBlock(blockName: string, index: number): void;
  30084. /**
  30085. * Sets an interger value on a uniform variable.
  30086. * @param uniformName Name of the variable.
  30087. * @param value Value to be set.
  30088. * @returns this effect.
  30089. */
  30090. setInt(uniformName: string, value: number): Effect;
  30091. /**
  30092. * Sets an int array on a uniform variable.
  30093. * @param uniformName Name of the variable.
  30094. * @param array array to be set.
  30095. * @returns this effect.
  30096. */
  30097. setIntArray(uniformName: string, array: Int32Array): Effect;
  30098. /**
  30099. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30100. * @param uniformName Name of the variable.
  30101. * @param array array to be set.
  30102. * @returns this effect.
  30103. */
  30104. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30105. /**
  30106. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30107. * @param uniformName Name of the variable.
  30108. * @param array array to be set.
  30109. * @returns this effect.
  30110. */
  30111. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30112. /**
  30113. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30114. * @param uniformName Name of the variable.
  30115. * @param array array to be set.
  30116. * @returns this effect.
  30117. */
  30118. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30119. /**
  30120. * Sets an float array on a uniform variable.
  30121. * @param uniformName Name of the variable.
  30122. * @param array array to be set.
  30123. * @returns this effect.
  30124. */
  30125. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30126. /**
  30127. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30128. * @param uniformName Name of the variable.
  30129. * @param array array to be set.
  30130. * @returns this effect.
  30131. */
  30132. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30133. /**
  30134. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30135. * @param uniformName Name of the variable.
  30136. * @param array array to be set.
  30137. * @returns this effect.
  30138. */
  30139. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30140. /**
  30141. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30142. * @param uniformName Name of the variable.
  30143. * @param array array to be set.
  30144. * @returns this effect.
  30145. */
  30146. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30147. /**
  30148. * Sets an array on a uniform variable.
  30149. * @param uniformName Name of the variable.
  30150. * @param array array to be set.
  30151. * @returns this effect.
  30152. */
  30153. setArray(uniformName: string, array: number[]): Effect;
  30154. /**
  30155. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  30156. * @param uniformName Name of the variable.
  30157. * @param array array to be set.
  30158. * @returns this effect.
  30159. */
  30160. setArray2(uniformName: string, array: number[]): Effect;
  30161. /**
  30162. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  30163. * @param uniformName Name of the variable.
  30164. * @param array array to be set.
  30165. * @returns this effect.
  30166. */
  30167. setArray3(uniformName: string, array: number[]): Effect;
  30168. /**
  30169. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  30170. * @param uniformName Name of the variable.
  30171. * @param array array to be set.
  30172. * @returns this effect.
  30173. */
  30174. setArray4(uniformName: string, array: number[]): Effect;
  30175. /**
  30176. * Sets matrices on a uniform variable.
  30177. * @param uniformName Name of the variable.
  30178. * @param matrices matrices to be set.
  30179. * @returns this effect.
  30180. */
  30181. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30182. /**
  30183. * Sets matrix on a uniform variable.
  30184. * @param uniformName Name of the variable.
  30185. * @param matrix matrix to be set.
  30186. * @returns this effect.
  30187. */
  30188. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30189. /**
  30190. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  30191. * @param uniformName Name of the variable.
  30192. * @param matrix matrix to be set.
  30193. * @returns this effect.
  30194. */
  30195. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30196. /**
  30197. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30198. * @param uniformName Name of the variable.
  30199. * @param matrix matrix to be set.
  30200. * @returns this effect.
  30201. */
  30202. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30203. /**
  30204. * Sets a float on a uniform variable.
  30205. * @param uniformName Name of the variable.
  30206. * @param value value to be set.
  30207. * @returns this effect.
  30208. */
  30209. setFloat(uniformName: string, value: number): Effect;
  30210. /**
  30211. * Sets a boolean on a uniform variable.
  30212. * @param uniformName Name of the variable.
  30213. * @param bool value to be set.
  30214. * @returns this effect.
  30215. */
  30216. setBool(uniformName: string, bool: boolean): Effect;
  30217. /**
  30218. * Sets a Vector2 on a uniform variable.
  30219. * @param uniformName Name of the variable.
  30220. * @param vector2 vector2 to be set.
  30221. * @returns this effect.
  30222. */
  30223. setVector2(uniformName: string, vector2: Vector2): Effect;
  30224. /**
  30225. * Sets a float2 on a uniform variable.
  30226. * @param uniformName Name of the variable.
  30227. * @param x First float in float2.
  30228. * @param y Second float in float2.
  30229. * @returns this effect.
  30230. */
  30231. setFloat2(uniformName: string, x: number, y: number): Effect;
  30232. /**
  30233. * Sets a Vector3 on a uniform variable.
  30234. * @param uniformName Name of the variable.
  30235. * @param vector3 Value to be set.
  30236. * @returns this effect.
  30237. */
  30238. setVector3(uniformName: string, vector3: Vector3): Effect;
  30239. /**
  30240. * Sets a float3 on a uniform variable.
  30241. * @param uniformName Name of the variable.
  30242. * @param x First float in float3.
  30243. * @param y Second float in float3.
  30244. * @param z Third float in float3.
  30245. * @returns this effect.
  30246. */
  30247. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30248. /**
  30249. * Sets a Vector4 on a uniform variable.
  30250. * @param uniformName Name of the variable.
  30251. * @param vector4 Value to be set.
  30252. * @returns this effect.
  30253. */
  30254. setVector4(uniformName: string, vector4: Vector4): Effect;
  30255. /**
  30256. * Sets a float4 on a uniform variable.
  30257. * @param uniformName Name of the variable.
  30258. * @param x First float in float4.
  30259. * @param y Second float in float4.
  30260. * @param z Third float in float4.
  30261. * @param w Fourth float in float4.
  30262. * @returns this effect.
  30263. */
  30264. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30265. /**
  30266. * Sets a Color3 on a uniform variable.
  30267. * @param uniformName Name of the variable.
  30268. * @param color3 Value to be set.
  30269. * @returns this effect.
  30270. */
  30271. setColor3(uniformName: string, color3: Color3): Effect;
  30272. /**
  30273. * Sets a Color4 on a uniform variable.
  30274. * @param uniformName Name of the variable.
  30275. * @param color3 Value to be set.
  30276. * @param alpha Alpha value to be set.
  30277. * @returns this effect.
  30278. */
  30279. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30280. /**
  30281. * Sets a Color4 on a uniform variable
  30282. * @param uniformName defines the name of the variable
  30283. * @param color4 defines the value to be set
  30284. * @returns this effect.
  30285. */
  30286. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30287. /** Release all associated resources */
  30288. dispose(): void;
  30289. /**
  30290. * This function will add a new shader to the shader store
  30291. * @param name the name of the shader
  30292. * @param pixelShader optional pixel shader content
  30293. * @param vertexShader optional vertex shader content
  30294. */
  30295. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30296. /**
  30297. * Store of each shader (The can be looked up using effect.key)
  30298. */
  30299. static ShadersStore: {
  30300. [key: string]: string;
  30301. };
  30302. /**
  30303. * Store of each included file for a shader (The can be looked up using effect.key)
  30304. */
  30305. static IncludesShadersStore: {
  30306. [key: string]: string;
  30307. };
  30308. /**
  30309. * Resets the cache of effects.
  30310. */
  30311. static ResetCache(): void;
  30312. }
  30313. }
  30314. declare module "babylonjs/Materials/colorCurves" {
  30315. import { Effect } from "babylonjs/Materials/effect";
  30316. /**
  30317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30319. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  30320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30321. */
  30322. export class ColorCurves {
  30323. private _dirty;
  30324. private _tempColor;
  30325. private _globalCurve;
  30326. private _highlightsCurve;
  30327. private _midtonesCurve;
  30328. private _shadowsCurve;
  30329. private _positiveCurve;
  30330. private _negativeCurve;
  30331. private _globalHue;
  30332. private _globalDensity;
  30333. private _globalSaturation;
  30334. private _globalExposure;
  30335. /**
  30336. * Gets the global Hue value.
  30337. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30338. */
  30339. /**
  30340. * Sets the global Hue value.
  30341. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30342. */
  30343. globalHue: number;
  30344. /**
  30345. * Gets the global Density value.
  30346. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30347. * Values less than zero provide a filter of opposite hue.
  30348. */
  30349. /**
  30350. * Sets the global Density value.
  30351. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30352. * Values less than zero provide a filter of opposite hue.
  30353. */
  30354. globalDensity: number;
  30355. /**
  30356. * Gets the global Saturation value.
  30357. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30358. */
  30359. /**
  30360. * Sets the global Saturation value.
  30361. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30362. */
  30363. globalSaturation: number;
  30364. /**
  30365. * Gets the global Exposure value.
  30366. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30367. */
  30368. /**
  30369. * Sets the global Exposure value.
  30370. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30371. */
  30372. globalExposure: number;
  30373. private _highlightsHue;
  30374. private _highlightsDensity;
  30375. private _highlightsSaturation;
  30376. private _highlightsExposure;
  30377. /**
  30378. * Gets the highlights Hue value.
  30379. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30380. */
  30381. /**
  30382. * Sets the highlights Hue value.
  30383. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30384. */
  30385. highlightsHue: number;
  30386. /**
  30387. * Gets the highlights Density value.
  30388. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30389. * Values less than zero provide a filter of opposite hue.
  30390. */
  30391. /**
  30392. * Sets the highlights Density value.
  30393. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30394. * Values less than zero provide a filter of opposite hue.
  30395. */
  30396. highlightsDensity: number;
  30397. /**
  30398. * Gets the highlights Saturation value.
  30399. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30400. */
  30401. /**
  30402. * Sets the highlights Saturation value.
  30403. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30404. */
  30405. highlightsSaturation: number;
  30406. /**
  30407. * Gets the highlights Exposure value.
  30408. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30409. */
  30410. /**
  30411. * Sets the highlights Exposure value.
  30412. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30413. */
  30414. highlightsExposure: number;
  30415. private _midtonesHue;
  30416. private _midtonesDensity;
  30417. private _midtonesSaturation;
  30418. private _midtonesExposure;
  30419. /**
  30420. * Gets the midtones Hue value.
  30421. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30422. */
  30423. /**
  30424. * Sets the midtones Hue value.
  30425. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30426. */
  30427. midtonesHue: number;
  30428. /**
  30429. * Gets the midtones Density value.
  30430. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30431. * Values less than zero provide a filter of opposite hue.
  30432. */
  30433. /**
  30434. * Sets the midtones Density value.
  30435. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30436. * Values less than zero provide a filter of opposite hue.
  30437. */
  30438. midtonesDensity: number;
  30439. /**
  30440. * Gets the midtones Saturation value.
  30441. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30442. */
  30443. /**
  30444. * Sets the midtones Saturation value.
  30445. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30446. */
  30447. midtonesSaturation: number;
  30448. /**
  30449. * Gets the midtones Exposure value.
  30450. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30451. */
  30452. /**
  30453. * Sets the midtones Exposure value.
  30454. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30455. */
  30456. midtonesExposure: number;
  30457. private _shadowsHue;
  30458. private _shadowsDensity;
  30459. private _shadowsSaturation;
  30460. private _shadowsExposure;
  30461. /**
  30462. * Gets the shadows Hue value.
  30463. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30464. */
  30465. /**
  30466. * Sets the shadows Hue value.
  30467. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  30468. */
  30469. shadowsHue: number;
  30470. /**
  30471. * Gets the shadows Density value.
  30472. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30473. * Values less than zero provide a filter of opposite hue.
  30474. */
  30475. /**
  30476. * Sets the shadows Density value.
  30477. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  30478. * Values less than zero provide a filter of opposite hue.
  30479. */
  30480. shadowsDensity: number;
  30481. /**
  30482. * Gets the shadows Saturation value.
  30483. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30484. */
  30485. /**
  30486. * Sets the shadows Saturation value.
  30487. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  30488. */
  30489. shadowsSaturation: number;
  30490. /**
  30491. * Gets the shadows Exposure value.
  30492. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30493. */
  30494. /**
  30495. * Sets the shadows Exposure value.
  30496. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30497. */
  30498. shadowsExposure: number;
  30499. /**
  30500. * Returns the class name
  30501. * @returns The class name
  30502. */
  30503. getClassName(): string;
  30504. /**
  30505. * Binds the color curves to the shader.
  30506. * @param colorCurves The color curve to bind
  30507. * @param effect The effect to bind to
  30508. * @param positiveUniform The positive uniform shader parameter
  30509. * @param neutralUniform The neutral uniform shader parameter
  30510. * @param negativeUniform The negative uniform shader parameter
  30511. */
  30512. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30513. /**
  30514. * Prepare the list of uniforms associated with the ColorCurves effects.
  30515. * @param uniformsList The list of uniforms used in the effect
  30516. */
  30517. static PrepareUniforms(uniformsList: string[]): void;
  30518. /**
  30519. * Returns color grading data based on a hue, density, saturation and exposure value.
  30520. * @param filterHue The hue of the color filter.
  30521. * @param filterDensity The density of the color filter.
  30522. * @param saturation The saturation.
  30523. * @param exposure The exposure.
  30524. * @param result The result data container.
  30525. */
  30526. private getColorGradingDataToRef;
  30527. /**
  30528. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30529. * @param value The input slider value in range [-100,100].
  30530. * @returns Adjusted value.
  30531. */
  30532. private static applyColorGradingSliderNonlinear;
  30533. /**
  30534. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30535. * @param hue The hue (H) input.
  30536. * @param saturation The saturation (S) input.
  30537. * @param brightness The brightness (B) input.
  30538. * @result An RGBA color represented as Vector4.
  30539. */
  30540. private static fromHSBToRef;
  30541. /**
  30542. * Returns a value clamped between min and max
  30543. * @param value The value to clamp
  30544. * @param min The minimum of value
  30545. * @param max The maximum of value
  30546. * @returns The clamped value.
  30547. */
  30548. private static clamp;
  30549. /**
  30550. * Clones the current color curve instance.
  30551. * @return The cloned curves
  30552. */
  30553. clone(): ColorCurves;
  30554. /**
  30555. * Serializes the current color curve instance to a json representation.
  30556. * @return a JSON representation
  30557. */
  30558. serialize(): any;
  30559. /**
  30560. * Parses the color curve from a json representation.
  30561. * @param source the JSON source to parse
  30562. * @return The parsed curves
  30563. */
  30564. static Parse(source: any): ColorCurves;
  30565. }
  30566. }
  30567. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30568. import { Observable } from "babylonjs/Misc/observable";
  30569. import { Nullable } from "babylonjs/types";
  30570. import { Color4 } from "babylonjs/Maths/math";
  30571. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30572. import { Effect } from "babylonjs/Materials/effect";
  30573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30574. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30575. /**
  30576. * Interface to follow in your material defines to integrate easily the
  30577. * Image proccessing functions.
  30578. * @hidden
  30579. */
  30580. export interface IImageProcessingConfigurationDefines {
  30581. IMAGEPROCESSING: boolean;
  30582. VIGNETTE: boolean;
  30583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30584. VIGNETTEBLENDMODEOPAQUE: boolean;
  30585. TONEMAPPING: boolean;
  30586. TONEMAPPING_ACES: boolean;
  30587. CONTRAST: boolean;
  30588. EXPOSURE: boolean;
  30589. COLORCURVES: boolean;
  30590. COLORGRADING: boolean;
  30591. COLORGRADING3D: boolean;
  30592. SAMPLER3DGREENDEPTH: boolean;
  30593. SAMPLER3DBGRMAP: boolean;
  30594. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30595. }
  30596. /**
  30597. * @hidden
  30598. */
  30599. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30600. IMAGEPROCESSING: boolean;
  30601. VIGNETTE: boolean;
  30602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30603. VIGNETTEBLENDMODEOPAQUE: boolean;
  30604. TONEMAPPING: boolean;
  30605. TONEMAPPING_ACES: boolean;
  30606. CONTRAST: boolean;
  30607. COLORCURVES: boolean;
  30608. COLORGRADING: boolean;
  30609. COLORGRADING3D: boolean;
  30610. SAMPLER3DGREENDEPTH: boolean;
  30611. SAMPLER3DBGRMAP: boolean;
  30612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30613. EXPOSURE: boolean;
  30614. constructor();
  30615. }
  30616. /**
  30617. * This groups together the common properties used for image processing either in direct forward pass
  30618. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30619. * or not.
  30620. */
  30621. export class ImageProcessingConfiguration {
  30622. /**
  30623. * Default tone mapping applied in BabylonJS.
  30624. */
  30625. static readonly TONEMAPPING_STANDARD: number;
  30626. /**
  30627. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30628. * to other engines rendering to increase portability.
  30629. */
  30630. static readonly TONEMAPPING_ACES: number;
  30631. /**
  30632. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30633. */
  30634. colorCurves: Nullable<ColorCurves>;
  30635. private _colorCurvesEnabled;
  30636. /**
  30637. * Gets wether the color curves effect is enabled.
  30638. */
  30639. /**
  30640. * Sets wether the color curves effect is enabled.
  30641. */
  30642. colorCurvesEnabled: boolean;
  30643. private _colorGradingTexture;
  30644. /**
  30645. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30646. */
  30647. /**
  30648. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30649. */
  30650. colorGradingTexture: Nullable<BaseTexture>;
  30651. private _colorGradingEnabled;
  30652. /**
  30653. * Gets wether the color grading effect is enabled.
  30654. */
  30655. /**
  30656. * Sets wether the color grading effect is enabled.
  30657. */
  30658. colorGradingEnabled: boolean;
  30659. private _colorGradingWithGreenDepth;
  30660. /**
  30661. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30662. */
  30663. /**
  30664. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30665. */
  30666. colorGradingWithGreenDepth: boolean;
  30667. private _colorGradingBGR;
  30668. /**
  30669. * Gets wether the color grading texture contains BGR values.
  30670. */
  30671. /**
  30672. * Sets wether the color grading texture contains BGR values.
  30673. */
  30674. colorGradingBGR: boolean;
  30675. /** @hidden */
  30676. _exposure: number;
  30677. /**
  30678. * Gets the Exposure used in the effect.
  30679. */
  30680. /**
  30681. * Sets the Exposure used in the effect.
  30682. */
  30683. exposure: number;
  30684. private _toneMappingEnabled;
  30685. /**
  30686. * Gets wether the tone mapping effect is enabled.
  30687. */
  30688. /**
  30689. * Sets wether the tone mapping effect is enabled.
  30690. */
  30691. toneMappingEnabled: boolean;
  30692. private _toneMappingType;
  30693. /**
  30694. * Gets the type of tone mapping effect.
  30695. */
  30696. /**
  30697. * Sets the type of tone mapping effect used in BabylonJS.
  30698. */
  30699. toneMappingType: number;
  30700. protected _contrast: number;
  30701. /**
  30702. * Gets the contrast used in the effect.
  30703. */
  30704. /**
  30705. * Sets the contrast used in the effect.
  30706. */
  30707. contrast: number;
  30708. /**
  30709. * Vignette stretch size.
  30710. */
  30711. vignetteStretch: number;
  30712. /**
  30713. * Vignette centre X Offset.
  30714. */
  30715. vignetteCentreX: number;
  30716. /**
  30717. * Vignette centre Y Offset.
  30718. */
  30719. vignetteCentreY: number;
  30720. /**
  30721. * Vignette weight or intensity of the vignette effect.
  30722. */
  30723. vignetteWeight: number;
  30724. /**
  30725. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30726. * if vignetteEnabled is set to true.
  30727. */
  30728. vignetteColor: Color4;
  30729. /**
  30730. * Camera field of view used by the Vignette effect.
  30731. */
  30732. vignetteCameraFov: number;
  30733. private _vignetteBlendMode;
  30734. /**
  30735. * Gets the vignette blend mode allowing different kind of effect.
  30736. */
  30737. /**
  30738. * Sets the vignette blend mode allowing different kind of effect.
  30739. */
  30740. vignetteBlendMode: number;
  30741. private _vignetteEnabled;
  30742. /**
  30743. * Gets wether the vignette effect is enabled.
  30744. */
  30745. /**
  30746. * Sets wether the vignette effect is enabled.
  30747. */
  30748. vignetteEnabled: boolean;
  30749. private _applyByPostProcess;
  30750. /**
  30751. * Gets wether the image processing is applied through a post process or not.
  30752. */
  30753. /**
  30754. * Sets wether the image processing is applied through a post process or not.
  30755. */
  30756. applyByPostProcess: boolean;
  30757. private _isEnabled;
  30758. /**
  30759. * Gets wether the image processing is enabled or not.
  30760. */
  30761. /**
  30762. * Sets wether the image processing is enabled or not.
  30763. */
  30764. isEnabled: boolean;
  30765. /**
  30766. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30767. */
  30768. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30769. /**
  30770. * Method called each time the image processing information changes requires to recompile the effect.
  30771. */
  30772. protected _updateParameters(): void;
  30773. /**
  30774. * Gets the current class name.
  30775. * @return "ImageProcessingConfiguration"
  30776. */
  30777. getClassName(): string;
  30778. /**
  30779. * Prepare the list of uniforms associated with the Image Processing effects.
  30780. * @param uniforms The list of uniforms used in the effect
  30781. * @param defines the list of defines currently in use
  30782. */
  30783. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30784. /**
  30785. * Prepare the list of samplers associated with the Image Processing effects.
  30786. * @param samplersList The list of uniforms used in the effect
  30787. * @param defines the list of defines currently in use
  30788. */
  30789. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30790. /**
  30791. * Prepare the list of defines associated to the shader.
  30792. * @param defines the list of defines to complete
  30793. * @param forPostProcess Define if we are currently in post process mode or not
  30794. */
  30795. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30796. /**
  30797. * Returns true if all the image processing information are ready.
  30798. * @returns True if ready, otherwise, false
  30799. */
  30800. isReady(): boolean;
  30801. /**
  30802. * Binds the image processing to the shader.
  30803. * @param effect The effect to bind to
  30804. * @param aspectRatio Define the current aspect ratio of the effect
  30805. */
  30806. bind(effect: Effect, aspectRatio?: number): void;
  30807. /**
  30808. * Clones the current image processing instance.
  30809. * @return The cloned image processing
  30810. */
  30811. clone(): ImageProcessingConfiguration;
  30812. /**
  30813. * Serializes the current image processing instance to a json representation.
  30814. * @return a JSON representation
  30815. */
  30816. serialize(): any;
  30817. /**
  30818. * Parses the image processing from a json representation.
  30819. * @param source the JSON source to parse
  30820. * @return The parsed image processing
  30821. */
  30822. static Parse(source: any): ImageProcessingConfiguration;
  30823. private static _VIGNETTEMODE_MULTIPLY;
  30824. private static _VIGNETTEMODE_OPAQUE;
  30825. /**
  30826. * Used to apply the vignette as a mix with the pixel color.
  30827. */
  30828. static readonly VIGNETTEMODE_MULTIPLY: number;
  30829. /**
  30830. * Used to apply the vignette as a replacement of the pixel color.
  30831. */
  30832. static readonly VIGNETTEMODE_OPAQUE: number;
  30833. }
  30834. }
  30835. declare module "babylonjs/Materials/fresnelParameters" {
  30836. import { Color3 } from "babylonjs/Maths/math";
  30837. /**
  30838. * This represents all the required information to add a fresnel effect on a material:
  30839. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30840. */
  30841. export class FresnelParameters {
  30842. private _isEnabled;
  30843. /**
  30844. * Define if the fresnel effect is enable or not.
  30845. */
  30846. isEnabled: boolean;
  30847. /**
  30848. * Define the color used on edges (grazing angle)
  30849. */
  30850. leftColor: Color3;
  30851. /**
  30852. * Define the color used on center
  30853. */
  30854. rightColor: Color3;
  30855. /**
  30856. * Define bias applied to computed fresnel term
  30857. */
  30858. bias: number;
  30859. /**
  30860. * Defined the power exponent applied to fresnel term
  30861. */
  30862. power: number;
  30863. /**
  30864. * Clones the current fresnel and its valuues
  30865. * @returns a clone fresnel configuration
  30866. */
  30867. clone(): FresnelParameters;
  30868. /**
  30869. * Serializes the current fresnel parameters to a JSON representation.
  30870. * @return the JSON serialization
  30871. */
  30872. serialize(): any;
  30873. /**
  30874. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30875. * @param parsedFresnelParameters Define the JSON representation
  30876. * @returns the parsed parameters
  30877. */
  30878. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30879. }
  30880. }
  30881. declare module "babylonjs/Misc/decorators" {
  30882. import { Nullable } from "babylonjs/types";
  30883. import { Scene } from "babylonjs/scene";
  30884. import { IAnimatable } from "babylonjs/Misc/tools";
  30885. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30886. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30887. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30888. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30889. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30890. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30891. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30892. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30893. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30894. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30895. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30896. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30897. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30898. /**
  30899. * Decorator used to define property that can be serialized as reference to a camera
  30900. * @param sourceName defines the name of the property to decorate
  30901. */
  30902. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30903. /**
  30904. * Class used to help serialization objects
  30905. */
  30906. export class SerializationHelper {
  30907. /** hidden */
  30908. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30909. /** hidden */
  30910. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30911. /** hidden */
  30912. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30913. /** hidden */
  30914. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30915. /**
  30916. * Appends the serialized animations from the source animations
  30917. * @param source Source containing the animations
  30918. * @param destination Target to store the animations
  30919. */
  30920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30921. /**
  30922. * Static function used to serialized a specific entity
  30923. * @param entity defines the entity to serialize
  30924. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30925. * @returns a JSON compatible object representing the serialization of the entity
  30926. */
  30927. static Serialize<T>(entity: T, serializationObject?: any): any;
  30928. /**
  30929. * Creates a new entity from a serialization data object
  30930. * @param creationFunction defines a function used to instanciated the new entity
  30931. * @param source defines the source serialization data
  30932. * @param scene defines the hosting scene
  30933. * @param rootUrl defines the root url for resources
  30934. * @returns a new entity
  30935. */
  30936. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30937. /**
  30938. * Clones an object
  30939. * @param creationFunction defines the function used to instanciate the new object
  30940. * @param source defines the source object
  30941. * @returns the cloned object
  30942. */
  30943. static Clone<T>(creationFunction: () => T, source: T): T;
  30944. /**
  30945. * Instanciates a new object based on a source one (some data will be shared between both object)
  30946. * @param creationFunction defines the function used to instanciate the new object
  30947. * @param source defines the source object
  30948. * @returns the new object
  30949. */
  30950. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30951. }
  30952. }
  30953. declare module "babylonjs/Cameras/camera" {
  30954. import { SmartArray } from "babylonjs/Misc/smartArray";
  30955. import { Observable } from "babylonjs/Misc/observable";
  30956. import { Nullable } from "babylonjs/types";
  30957. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30958. import { Scene } from "babylonjs/scene";
  30959. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30960. import { Node } from "babylonjs/node";
  30961. import { Mesh } from "babylonjs/Meshes/mesh";
  30962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30964. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30966. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30967. import { Ray } from "babylonjs/Culling/ray";
  30968. /**
  30969. * This is the base class of all the camera used in the application.
  30970. * @see http://doc.babylonjs.com/features/cameras
  30971. */
  30972. export class Camera extends Node {
  30973. /** @hidden */
  30974. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30975. /**
  30976. * This is the default projection mode used by the cameras.
  30977. * It helps recreating a feeling of perspective and better appreciate depth.
  30978. * This is the best way to simulate real life cameras.
  30979. */
  30980. static readonly PERSPECTIVE_CAMERA: number;
  30981. /**
  30982. * This helps creating camera with an orthographic mode.
  30983. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  30984. */
  30985. static readonly ORTHOGRAPHIC_CAMERA: number;
  30986. /**
  30987. * This is the default FOV mode for perspective cameras.
  30988. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30989. */
  30990. static readonly FOVMODE_VERTICAL_FIXED: number;
  30991. /**
  30992. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30993. */
  30994. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30995. /**
  30996. * This specifies ther is no need for a camera rig.
  30997. * Basically only one eye is rendered corresponding to the camera.
  30998. */
  30999. static readonly RIG_MODE_NONE: number;
  31000. /**
  31001. * Simulates a camera Rig with one blue eye and one red eye.
  31002. * This can be use with 3d blue and red glasses.
  31003. */
  31004. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31005. /**
  31006. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31007. */
  31008. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31009. /**
  31010. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31011. */
  31012. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31013. /**
  31014. * Defines that both eyes of the camera will be rendered over under each other.
  31015. */
  31016. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31017. /**
  31018. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31019. */
  31020. static readonly RIG_MODE_VR: number;
  31021. /**
  31022. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31023. */
  31024. static readonly RIG_MODE_WEBVR: number;
  31025. /**
  31026. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31027. */
  31028. static readonly RIG_MODE_CUSTOM: number;
  31029. /**
  31030. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31031. */
  31032. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31033. /**
  31034. * Define the input manager associated with the camera.
  31035. */
  31036. inputs: CameraInputsManager<Camera>;
  31037. /** @hidden */
  31038. _position: Vector3;
  31039. /**
  31040. * Define the current local position of the camera in the scene
  31041. */
  31042. position: Vector3;
  31043. /**
  31044. * The vector the camera should consider as up.
  31045. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31046. */
  31047. upVector: Vector3;
  31048. /**
  31049. * Define the current limit on the left side for an orthographic camera
  31050. * In scene unit
  31051. */
  31052. orthoLeft: Nullable<number>;
  31053. /**
  31054. * Define the current limit on the right side for an orthographic camera
  31055. * In scene unit
  31056. */
  31057. orthoRight: Nullable<number>;
  31058. /**
  31059. * Define the current limit on the bottom side for an orthographic camera
  31060. * In scene unit
  31061. */
  31062. orthoBottom: Nullable<number>;
  31063. /**
  31064. * Define the current limit on the top side for an orthographic camera
  31065. * In scene unit
  31066. */
  31067. orthoTop: Nullable<number>;
  31068. /**
  31069. * Field Of View is set in Radians. (default is 0.8)
  31070. */
  31071. fov: number;
  31072. /**
  31073. * Define the minimum distance the camera can see from.
  31074. * This is important to note that the depth buffer are not infinite and the closer it starts
  31075. * the more your scene might encounter depth fighting issue.
  31076. */
  31077. minZ: number;
  31078. /**
  31079. * Define the maximum distance the camera can see to.
  31080. * This is important to note that the depth buffer are not infinite and the further it end
  31081. * the more your scene might encounter depth fighting issue.
  31082. */
  31083. maxZ: number;
  31084. /**
  31085. * Define the default inertia of the camera.
  31086. * This helps giving a smooth feeling to the camera movement.
  31087. */
  31088. inertia: number;
  31089. /**
  31090. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31091. */
  31092. mode: number;
  31093. /**
  31094. * Define wether the camera is intermediate.
  31095. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31096. */
  31097. isIntermediate: boolean;
  31098. /**
  31099. * Define the viewport of the camera.
  31100. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31101. */
  31102. viewport: Viewport;
  31103. /**
  31104. * Restricts the camera to viewing objects with the same layerMask.
  31105. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31106. */
  31107. layerMask: number;
  31108. /**
  31109. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31110. */
  31111. fovMode: number;
  31112. /**
  31113. * Rig mode of the camera.
  31114. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31115. * This is normally controlled byt the camera themselves as internal use.
  31116. */
  31117. cameraRigMode: number;
  31118. /**
  31119. * Defines the distance between both "eyes" in case of a RIG
  31120. */
  31121. interaxialDistance: number;
  31122. /**
  31123. * Defines if stereoscopic rendering is done side by side or over under.
  31124. */
  31125. isStereoscopicSideBySide: boolean;
  31126. /**
  31127. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  31128. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31129. * else in the scene.
  31130. */
  31131. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31132. /**
  31133. * When set, the camera will render to this render target instead of the default canvas
  31134. */
  31135. outputRenderTarget: Nullable<RenderTargetTexture>;
  31136. /**
  31137. * Observable triggered when the camera view matrix has changed.
  31138. */
  31139. onViewMatrixChangedObservable: Observable<Camera>;
  31140. /**
  31141. * Observable triggered when the camera Projection matrix has changed.
  31142. */
  31143. onProjectionMatrixChangedObservable: Observable<Camera>;
  31144. /**
  31145. * Observable triggered when the inputs have been processed.
  31146. */
  31147. onAfterCheckInputsObservable: Observable<Camera>;
  31148. /**
  31149. * Observable triggered when reset has been called and applied to the camera.
  31150. */
  31151. onRestoreStateObservable: Observable<Camera>;
  31152. /** @hidden */
  31153. _cameraRigParams: any;
  31154. /** @hidden */
  31155. _rigCameras: Camera[];
  31156. /** @hidden */
  31157. _rigPostProcess: Nullable<PostProcess>;
  31158. protected _webvrViewMatrix: Matrix;
  31159. /** @hidden */
  31160. _skipRendering: boolean;
  31161. /** @hidden */
  31162. _projectionMatrix: Matrix;
  31163. /** @hidden */
  31164. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31165. /** @hidden */
  31166. _activeMeshes: SmartArray<AbstractMesh>;
  31167. protected _globalPosition: Vector3;
  31168. /** hidden */
  31169. _computedViewMatrix: Matrix;
  31170. private _doNotComputeProjectionMatrix;
  31171. private _transformMatrix;
  31172. private _frustumPlanes;
  31173. private _refreshFrustumPlanes;
  31174. private _storedFov;
  31175. private _stateStored;
  31176. /**
  31177. * Instantiates a new camera object.
  31178. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31179. * @see http://doc.babylonjs.com/features/cameras
  31180. * @param name Defines the name of the camera in the scene
  31181. * @param position Defines the position of the camera
  31182. * @param scene Defines the scene the camera belongs too
  31183. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31184. */
  31185. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31186. /**
  31187. * Store current camera state (fov, position, etc..)
  31188. * @returns the camera
  31189. */
  31190. storeState(): Camera;
  31191. /**
  31192. * Restores the camera state values if it has been stored. You must call storeState() first
  31193. */
  31194. protected _restoreStateValues(): boolean;
  31195. /**
  31196. * Restored camera state. You must call storeState() first.
  31197. * @returns true if restored and false otherwise
  31198. */
  31199. restoreState(): boolean;
  31200. /**
  31201. * Gets the class name of the camera.
  31202. * @returns the class name
  31203. */
  31204. getClassName(): string;
  31205. /** @hidden */
  31206. readonly _isCamera: boolean;
  31207. /**
  31208. * Gets a string representation of the camera useful for debug purpose.
  31209. * @param fullDetails Defines that a more verboe level of logging is required
  31210. * @returns the string representation
  31211. */
  31212. toString(fullDetails?: boolean): string;
  31213. /**
  31214. * Gets the current world space position of the camera.
  31215. */
  31216. readonly globalPosition: Vector3;
  31217. /**
  31218. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31219. * @returns the active meshe list
  31220. */
  31221. getActiveMeshes(): SmartArray<AbstractMesh>;
  31222. /**
  31223. * Check wether a mesh is part of the current active mesh list of the camera
  31224. * @param mesh Defines the mesh to check
  31225. * @returns true if active, false otherwise
  31226. */
  31227. isActiveMesh(mesh: Mesh): boolean;
  31228. /**
  31229. * Is this camera ready to be used/rendered
  31230. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31231. * @return true if the camera is ready
  31232. */
  31233. isReady(completeCheck?: boolean): boolean;
  31234. /** @hidden */
  31235. _initCache(): void;
  31236. /** @hidden */
  31237. _updateCache(ignoreParentClass?: boolean): void;
  31238. /** @hidden */
  31239. _isSynchronized(): boolean;
  31240. /** @hidden */
  31241. _isSynchronizedViewMatrix(): boolean;
  31242. /** @hidden */
  31243. _isSynchronizedProjectionMatrix(): boolean;
  31244. /**
  31245. * Attach the input controls to a specific dom element to get the input from.
  31246. * @param element Defines the element the controls should be listened from
  31247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31248. */
  31249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31250. /**
  31251. * Detach the current controls from the specified dom element.
  31252. * @param element Defines the element to stop listening the inputs from
  31253. */
  31254. detachControl(element: HTMLElement): void;
  31255. /**
  31256. * Update the camera state according to the different inputs gathered during the frame.
  31257. */
  31258. update(): void;
  31259. /** @hidden */
  31260. _checkInputs(): void;
  31261. /** @hidden */
  31262. readonly rigCameras: Camera[];
  31263. /**
  31264. * Gets the post process used by the rig cameras
  31265. */
  31266. readonly rigPostProcess: Nullable<PostProcess>;
  31267. /**
  31268. * Internal, gets the first post proces.
  31269. * @returns the first post process to be run on this camera.
  31270. */
  31271. _getFirstPostProcess(): Nullable<PostProcess>;
  31272. private _cascadePostProcessesToRigCams;
  31273. /**
  31274. * Attach a post process to the camera.
  31275. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31276. * @param postProcess The post process to attach to the camera
  31277. * @param insertAt The position of the post process in case several of them are in use in the scene
  31278. * @returns the position the post process has been inserted at
  31279. */
  31280. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31281. /**
  31282. * Detach a post process to the camera.
  31283. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31284. * @param postProcess The post process to detach from the camera
  31285. */
  31286. detachPostProcess(postProcess: PostProcess): void;
  31287. /**
  31288. * Gets the current world matrix of the camera
  31289. */
  31290. getWorldMatrix(): Matrix;
  31291. /** @hidden */
  31292. _getViewMatrix(): Matrix;
  31293. /**
  31294. * Gets the current view matrix of the camera.
  31295. * @param force forces the camera to recompute the matrix without looking at the cached state
  31296. * @returns the view matrix
  31297. */
  31298. getViewMatrix(force?: boolean): Matrix;
  31299. /**
  31300. * Freeze the projection matrix.
  31301. * It will prevent the cache check of the camera projection compute and can speed up perf
  31302. * if no parameter of the camera are meant to change
  31303. * @param projection Defines manually a projection if necessary
  31304. */
  31305. freezeProjectionMatrix(projection?: Matrix): void;
  31306. /**
  31307. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31308. */
  31309. unfreezeProjectionMatrix(): void;
  31310. /**
  31311. * Gets the current projection matrix of the camera.
  31312. * @param force forces the camera to recompute the matrix without looking at the cached state
  31313. * @returns the projection matrix
  31314. */
  31315. getProjectionMatrix(force?: boolean): Matrix;
  31316. /**
  31317. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31318. * @returns a Matrix
  31319. */
  31320. getTransformationMatrix(): Matrix;
  31321. private _updateFrustumPlanes;
  31322. /**
  31323. * Checks if a cullable object (mesh...) is in the camera frustum
  31324. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31325. * @param target The object to check
  31326. * @returns true if the object is in frustum otherwise false
  31327. */
  31328. isInFrustum(target: ICullable): boolean;
  31329. /**
  31330. * Checks if a cullable object (mesh...) is in the camera frustum
  31331. * Unlike isInFrustum this cheks the full bounding box
  31332. * @param target The object to check
  31333. * @returns true if the object is in frustum otherwise false
  31334. */
  31335. isCompletelyInFrustum(target: ICullable): boolean;
  31336. /**
  31337. * Gets a ray in the forward direction from the camera.
  31338. * @param length Defines the length of the ray to create
  31339. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31340. * @param origin Defines the start point of the ray which defaults to the camera position
  31341. * @returns the forward ray
  31342. */
  31343. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31344. /**
  31345. * Releases resources associated with this node.
  31346. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31347. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31348. */
  31349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31350. /** @hidden */
  31351. _isLeftCamera: boolean;
  31352. /**
  31353. * Gets the left camera of a rig setup in case of Rigged Camera
  31354. */
  31355. readonly isLeftCamera: boolean;
  31356. /** @hidden */
  31357. _isRightCamera: boolean;
  31358. /**
  31359. * Gets the right camera of a rig setup in case of Rigged Camera
  31360. */
  31361. readonly isRightCamera: boolean;
  31362. /**
  31363. * Gets the left camera of a rig setup in case of Rigged Camera
  31364. */
  31365. readonly leftCamera: Nullable<FreeCamera>;
  31366. /**
  31367. * Gets the right camera of a rig setup in case of Rigged Camera
  31368. */
  31369. readonly rightCamera: Nullable<FreeCamera>;
  31370. /**
  31371. * Gets the left camera target of a rig setup in case of Rigged Camera
  31372. * @returns the target position
  31373. */
  31374. getLeftTarget(): Nullable<Vector3>;
  31375. /**
  31376. * Gets the right camera target of a rig setup in case of Rigged Camera
  31377. * @returns the target position
  31378. */
  31379. getRightTarget(): Nullable<Vector3>;
  31380. /**
  31381. * @hidden
  31382. */
  31383. setCameraRigMode(mode: number, rigParams: any): void;
  31384. /** @hidden */
  31385. static _setStereoscopicRigMode(camera: Camera): void;
  31386. /** @hidden */
  31387. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31388. /** @hidden */
  31389. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31390. /** @hidden */
  31391. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31392. /** @hidden */
  31393. _getVRProjectionMatrix(): Matrix;
  31394. protected _updateCameraRotationMatrix(): void;
  31395. protected _updateWebVRCameraRotationMatrix(): void;
  31396. /**
  31397. * This function MUST be overwritten by the different WebVR cameras available.
  31398. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31399. * @hidden
  31400. */
  31401. _getWebVRProjectionMatrix(): Matrix;
  31402. /**
  31403. * This function MUST be overwritten by the different WebVR cameras available.
  31404. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31405. * @hidden
  31406. */
  31407. _getWebVRViewMatrix(): Matrix;
  31408. /** @hidden */
  31409. setCameraRigParameter(name: string, value: any): void;
  31410. /**
  31411. * needs to be overridden by children so sub has required properties to be copied
  31412. * @hidden
  31413. */
  31414. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31415. /**
  31416. * May need to be overridden by children
  31417. * @hidden
  31418. */
  31419. _updateRigCameras(): void;
  31420. /** @hidden */
  31421. _setupInputs(): void;
  31422. /**
  31423. * Serialiaze the camera setup to a json represention
  31424. * @returns the JSON representation
  31425. */
  31426. serialize(): any;
  31427. /**
  31428. * Clones the current camera.
  31429. * @param name The cloned camera name
  31430. * @returns the cloned camera
  31431. */
  31432. clone(name: string): Camera;
  31433. /**
  31434. * Gets the direction of the camera relative to a given local axis.
  31435. * @param localAxis Defines the reference axis to provide a relative direction.
  31436. * @return the direction
  31437. */
  31438. getDirection(localAxis: Vector3): Vector3;
  31439. /**
  31440. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31441. * @param localAxis Defines the reference axis to provide a relative direction.
  31442. * @param result Defines the vector to store the result in
  31443. */
  31444. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31445. /**
  31446. * Gets a camera constructor for a given camera type
  31447. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31448. * @param name The name of the camera the result will be able to instantiate
  31449. * @param scene The scene the result will construct the camera in
  31450. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31451. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31452. * @returns a factory method to construc the camera
  31453. */
  31454. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31455. /**
  31456. * Compute the world matrix of the camera.
  31457. * @returns the camera workd matrix
  31458. */
  31459. computeWorldMatrix(): Matrix;
  31460. /**
  31461. * Parse a JSON and creates the camera from the parsed information
  31462. * @param parsedCamera The JSON to parse
  31463. * @param scene The scene to instantiate the camera in
  31464. * @returns the newly constructed camera
  31465. */
  31466. static Parse(parsedCamera: any, scene: Scene): Camera;
  31467. }
  31468. }
  31469. declare module "babylonjs/Misc/tools" {
  31470. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31471. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31472. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31473. import { Observable } from "babylonjs/Misc/observable";
  31474. import { DomManagement } from "babylonjs/Misc/domManagement";
  31475. import { WebRequest } from "babylonjs/Misc/webRequest";
  31476. import { Camera } from "babylonjs/Cameras/camera";
  31477. import { Engine } from "babylonjs/Engines/engine";
  31478. import { Animation } from "babylonjs/Animations/animation";
  31479. /**
  31480. * Interface for any object that can request an animation frame
  31481. */
  31482. export interface ICustomAnimationFrameRequester {
  31483. /**
  31484. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31485. */
  31486. renderFunction?: Function;
  31487. /**
  31488. * Called to request the next frame to render to
  31489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31490. */
  31491. requestAnimationFrame: Function;
  31492. /**
  31493. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31494. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31495. */
  31496. requestID?: number;
  31497. }
  31498. /**
  31499. * Interface containing an array of animations
  31500. */
  31501. export interface IAnimatable {
  31502. /**
  31503. * Array of animations
  31504. */
  31505. animations: Nullable<Array<Animation>>;
  31506. }
  31507. /** Interface used by value gradients (color, factor, ...) */
  31508. export interface IValueGradient {
  31509. /**
  31510. * Gets or sets the gradient value (between 0 and 1)
  31511. */
  31512. gradient: number;
  31513. }
  31514. /** Class used to store color4 gradient */
  31515. export class ColorGradient implements IValueGradient {
  31516. /**
  31517. * Gets or sets the gradient value (between 0 and 1)
  31518. */
  31519. gradient: number;
  31520. /**
  31521. * Gets or sets first associated color
  31522. */
  31523. color1: Color4;
  31524. /**
  31525. * Gets or sets second associated color
  31526. */
  31527. color2?: Color4;
  31528. /**
  31529. * Will get a color picked randomly between color1 and color2.
  31530. * If color2 is undefined then color1 will be used
  31531. * @param result defines the target Color4 to store the result in
  31532. */
  31533. getColorToRef(result: Color4): void;
  31534. }
  31535. /** Class used to store color 3 gradient */
  31536. export class Color3Gradient implements IValueGradient {
  31537. /**
  31538. * Gets or sets the gradient value (between 0 and 1)
  31539. */
  31540. gradient: number;
  31541. /**
  31542. * Gets or sets the associated color
  31543. */
  31544. color: Color3;
  31545. }
  31546. /** Class used to store factor gradient */
  31547. export class FactorGradient implements IValueGradient {
  31548. /**
  31549. * Gets or sets the gradient value (between 0 and 1)
  31550. */
  31551. gradient: number;
  31552. /**
  31553. * Gets or sets first associated factor
  31554. */
  31555. factor1: number;
  31556. /**
  31557. * Gets or sets second associated factor
  31558. */
  31559. factor2?: number;
  31560. /**
  31561. * Will get a number picked randomly between factor1 and factor2.
  31562. * If factor2 is undefined then factor1 will be used
  31563. * @returns the picked number
  31564. */
  31565. getFactor(): number;
  31566. }
  31567. /**
  31568. * @ignore
  31569. * Application error to support additional information when loading a file
  31570. */
  31571. export class LoadFileError extends Error {
  31572. /** defines the optional web request */
  31573. request?: WebRequest | undefined;
  31574. private static _setPrototypeOf;
  31575. /**
  31576. * Creates a new LoadFileError
  31577. * @param message defines the message of the error
  31578. * @param request defines the optional web request
  31579. */
  31580. constructor(message: string,
  31581. /** defines the optional web request */
  31582. request?: WebRequest | undefined);
  31583. }
  31584. /**
  31585. * Class used to define a retry strategy when error happens while loading assets
  31586. */
  31587. export class RetryStrategy {
  31588. /**
  31589. * Function used to defines an exponential back off strategy
  31590. * @param maxRetries defines the maximum number of retries (3 by default)
  31591. * @param baseInterval defines the interval between retries
  31592. * @returns the strategy function to use
  31593. */
  31594. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31595. }
  31596. /**
  31597. * File request interface
  31598. */
  31599. export interface IFileRequest {
  31600. /**
  31601. * Raised when the request is complete (success or error).
  31602. */
  31603. onCompleteObservable: Observable<IFileRequest>;
  31604. /**
  31605. * Aborts the request for a file.
  31606. */
  31607. abort: () => void;
  31608. }
  31609. /**
  31610. * Class containing a set of static utilities functions
  31611. */
  31612. export class Tools {
  31613. /**
  31614. * Gets or sets the base URL to use to load assets
  31615. */
  31616. static BaseUrl: string;
  31617. /**
  31618. * Enable/Disable Custom HTTP Request Headers globally.
  31619. * default = false
  31620. * @see CustomRequestHeaders
  31621. */
  31622. static UseCustomRequestHeaders: boolean;
  31623. /**
  31624. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31625. * i.e. when loading files, where the server/service expects an Authorization header
  31626. */
  31627. static CustomRequestHeaders: {
  31628. [key: string]: string;
  31629. };
  31630. /**
  31631. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31632. */
  31633. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31634. /**
  31635. * Default behaviour for cors in the application.
  31636. * It can be a string if the expected behavior is identical in the entire app.
  31637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31638. */
  31639. static CorsBehavior: string | ((url: string | string[]) => string);
  31640. /**
  31641. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31642. * @ignorenaming
  31643. */
  31644. static UseFallbackTexture: boolean;
  31645. /**
  31646. * Use this object to register external classes like custom textures or material
  31647. * to allow the laoders to instantiate them
  31648. */
  31649. static RegisteredExternalClasses: {
  31650. [key: string]: Object;
  31651. };
  31652. /**
  31653. * Texture content used if a texture cannot loaded
  31654. * @ignorenaming
  31655. */
  31656. static fallbackTexture: string;
  31657. /**
  31658. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31659. * @param u defines the coordinate on X axis
  31660. * @param v defines the coordinate on Y axis
  31661. * @param width defines the width of the source data
  31662. * @param height defines the height of the source data
  31663. * @param pixels defines the source byte array
  31664. * @param color defines the output color
  31665. */
  31666. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31667. /**
  31668. * Interpolates between a and b via alpha
  31669. * @param a The lower value (returned when alpha = 0)
  31670. * @param b The upper value (returned when alpha = 1)
  31671. * @param alpha The interpolation-factor
  31672. * @return The mixed value
  31673. */
  31674. static Mix(a: number, b: number, alpha: number): number;
  31675. /**
  31676. * Tries to instantiate a new object from a given class name
  31677. * @param className defines the class name to instantiate
  31678. * @returns the new object or null if the system was not able to do the instantiation
  31679. */
  31680. static Instantiate(className: string): any;
  31681. /**
  31682. * Provides a slice function that will work even on IE
  31683. * @param data defines the array to slice
  31684. * @param start defines the start of the data (optional)
  31685. * @param end defines the end of the data (optional)
  31686. * @returns the new sliced array
  31687. */
  31688. static Slice<T>(data: T, start?: number, end?: number): T;
  31689. /**
  31690. * Polyfill for setImmediate
  31691. * @param action defines the action to execute after the current execution block
  31692. */
  31693. static SetImmediate(action: () => void): void;
  31694. /**
  31695. * Function indicating if a number is an exponent of 2
  31696. * @param value defines the value to test
  31697. * @returns true if the value is an exponent of 2
  31698. */
  31699. static IsExponentOfTwo(value: number): boolean;
  31700. private static _tmpFloatArray;
  31701. /**
  31702. * Returns the nearest 32-bit single precision float representation of a Number
  31703. * @param value A Number. If the parameter is of a different type, it will get converted
  31704. * to a number or to NaN if it cannot be converted
  31705. * @returns number
  31706. */
  31707. static FloatRound(value: number): number;
  31708. /**
  31709. * Find the next highest power of two.
  31710. * @param x Number to start search from.
  31711. * @return Next highest power of two.
  31712. */
  31713. static CeilingPOT(x: number): number;
  31714. /**
  31715. * Find the next lowest power of two.
  31716. * @param x Number to start search from.
  31717. * @return Next lowest power of two.
  31718. */
  31719. static FloorPOT(x: number): number;
  31720. /**
  31721. * Find the nearest power of two.
  31722. * @param x Number to start search from.
  31723. * @return Next nearest power of two.
  31724. */
  31725. static NearestPOT(x: number): number;
  31726. /**
  31727. * Get the closest exponent of two
  31728. * @param value defines the value to approximate
  31729. * @param max defines the maximum value to return
  31730. * @param mode defines how to define the closest value
  31731. * @returns closest exponent of two of the given value
  31732. */
  31733. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31734. /**
  31735. * Extracts the filename from a path
  31736. * @param path defines the path to use
  31737. * @returns the filename
  31738. */
  31739. static GetFilename(path: string): string;
  31740. /**
  31741. * Extracts the "folder" part of a path (everything before the filename).
  31742. * @param uri The URI to extract the info from
  31743. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31744. * @returns The "folder" part of the path
  31745. */
  31746. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31747. /**
  31748. * Extracts text content from a DOM element hierarchy
  31749. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31750. */
  31751. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31752. /**
  31753. * Convert an angle in radians to degrees
  31754. * @param angle defines the angle to convert
  31755. * @returns the angle in degrees
  31756. */
  31757. static ToDegrees(angle: number): number;
  31758. /**
  31759. * Convert an angle in degrees to radians
  31760. * @param angle defines the angle to convert
  31761. * @returns the angle in radians
  31762. */
  31763. static ToRadians(angle: number): number;
  31764. /**
  31765. * Encode a buffer to a base64 string
  31766. * @param buffer defines the buffer to encode
  31767. * @returns the encoded string
  31768. */
  31769. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31770. /**
  31771. * Extracts minimum and maximum values from a list of indexed positions
  31772. * @param positions defines the positions to use
  31773. * @param indices defines the indices to the positions
  31774. * @param indexStart defines the start index
  31775. * @param indexCount defines the end index
  31776. * @param bias defines bias value to add to the result
  31777. * @return minimum and maximum values
  31778. */
  31779. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31780. minimum: Vector3;
  31781. maximum: Vector3;
  31782. };
  31783. /**
  31784. * Extracts minimum and maximum values from a list of positions
  31785. * @param positions defines the positions to use
  31786. * @param start defines the start index in the positions array
  31787. * @param count defines the number of positions to handle
  31788. * @param bias defines bias value to add to the result
  31789. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31790. * @return minimum and maximum values
  31791. */
  31792. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31793. minimum: Vector3;
  31794. maximum: Vector3;
  31795. };
  31796. /**
  31797. * Returns an array if obj is not an array
  31798. * @param obj defines the object to evaluate as an array
  31799. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31800. * @returns either obj directly if obj is an array or a new array containing obj
  31801. */
  31802. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31803. /**
  31804. * Gets the pointer prefix to use
  31805. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31806. */
  31807. static GetPointerPrefix(): string;
  31808. /**
  31809. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31810. * @param func - the function to be called
  31811. * @param requester - the object that will request the next frame. Falls back to window.
  31812. * @returns frame number
  31813. */
  31814. static QueueNewFrame(func: () => void, requester?: any): number;
  31815. /**
  31816. * Ask the browser to promote the current element to fullscreen rendering mode
  31817. * @param element defines the DOM element to promote
  31818. */
  31819. static RequestFullscreen(element: HTMLElement): void;
  31820. /**
  31821. * Asks the browser to exit fullscreen mode
  31822. */
  31823. static ExitFullscreen(): void;
  31824. /**
  31825. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31826. * @param url define the url we are trying
  31827. * @param element define the dom element where to configure the cors policy
  31828. */
  31829. static SetCorsBehavior(url: string | string[], element: {
  31830. crossOrigin: string | null;
  31831. }): void;
  31832. /**
  31833. * Removes unwanted characters from an url
  31834. * @param url defines the url to clean
  31835. * @returns the cleaned url
  31836. */
  31837. static CleanUrl(url: string): string;
  31838. /**
  31839. * Gets or sets a function used to pre-process url before using them to load assets
  31840. */
  31841. static PreprocessUrl: (url: string) => string;
  31842. /**
  31843. * Loads an image as an HTMLImageElement.
  31844. * @param input url string, ArrayBuffer, or Blob to load
  31845. * @param onLoad callback called when the image successfully loads
  31846. * @param onError callback called when the image fails to load
  31847. * @param offlineProvider offline provider for caching
  31848. * @returns the HTMLImageElement of the loaded image
  31849. */
  31850. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31851. /**
  31852. * Loads a file
  31853. * @param url url string, ArrayBuffer, or Blob to load
  31854. * @param onSuccess callback called when the file successfully loads
  31855. * @param onProgress callback called while file is loading (if the server supports this mode)
  31856. * @param offlineProvider defines the offline provider for caching
  31857. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31858. * @param onError callback called when the file fails to load
  31859. * @returns a file request object
  31860. */
  31861. 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;
  31862. /**
  31863. * Load a script (identified by an url). When the url returns, the
  31864. * content of this file is added into a new script element, attached to the DOM (body element)
  31865. * @param scriptUrl defines the url of the script to laod
  31866. * @param onSuccess defines the callback called when the script is loaded
  31867. * @param onError defines the callback to call if an error occurs
  31868. * @param scriptId defines the id of the script element
  31869. */
  31870. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31871. /**
  31872. * Load an asynchronous script (identified by an url). When the url returns, the
  31873. * content of this file is added into a new script element, attached to the DOM (body element)
  31874. * @param scriptUrl defines the url of the script to laod
  31875. * @param scriptId defines the id of the script element
  31876. * @returns a promise request object
  31877. */
  31878. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31879. /**
  31880. * Loads a file from a blob
  31881. * @param fileToLoad defines the blob to use
  31882. * @param callback defines the callback to call when data is loaded
  31883. * @param progressCallback defines the callback to call during loading process
  31884. * @returns a file request object
  31885. */
  31886. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31887. /**
  31888. * Loads a file
  31889. * @param fileToLoad defines the file to load
  31890. * @param callback defines the callback to call when data is loaded
  31891. * @param progressCallBack defines the callback to call during loading process
  31892. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31893. * @returns a file request object
  31894. */
  31895. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31896. /**
  31897. * Creates a data url from a given string content
  31898. * @param content defines the content to convert
  31899. * @returns the new data url link
  31900. */
  31901. static FileAsURL(content: string): string;
  31902. /**
  31903. * Format the given number to a specific decimal format
  31904. * @param value defines the number to format
  31905. * @param decimals defines the number of decimals to use
  31906. * @returns the formatted string
  31907. */
  31908. static Format(value: number, decimals?: number): string;
  31909. /**
  31910. * Checks if a given vector is inside a specific range
  31911. * @param v defines the vector to test
  31912. * @param min defines the minimum range
  31913. * @param max defines the maximum range
  31914. */
  31915. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31916. /**
  31917. * Tries to copy an object by duplicating every property
  31918. * @param source defines the source object
  31919. * @param destination defines the target object
  31920. * @param doNotCopyList defines a list of properties to avoid
  31921. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31922. */
  31923. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31924. /**
  31925. * Gets a boolean indicating if the given object has no own property
  31926. * @param obj defines the object to test
  31927. * @returns true if object has no own property
  31928. */
  31929. static IsEmpty(obj: any): boolean;
  31930. /**
  31931. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31932. * @param str Source string
  31933. * @param suffix Suffix to search for in the source string
  31934. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31935. */
  31936. static EndsWith(str: string, suffix: string): boolean;
  31937. /**
  31938. * Function used to register events at window level
  31939. * @param events defines the events to register
  31940. */
  31941. static RegisterTopRootEvents(events: {
  31942. name: string;
  31943. handler: Nullable<(e: FocusEvent) => any>;
  31944. }[]): void;
  31945. /**
  31946. * Function used to unregister events from window level
  31947. * @param events defines the events to unregister
  31948. */
  31949. static UnregisterTopRootEvents(events: {
  31950. name: string;
  31951. handler: Nullable<(e: FocusEvent) => any>;
  31952. }[]): void;
  31953. /**
  31954. * @ignore
  31955. */
  31956. static _ScreenshotCanvas: HTMLCanvasElement;
  31957. /**
  31958. * Dumps the current bound framebuffer
  31959. * @param width defines the rendering width
  31960. * @param height defines the rendering height
  31961. * @param engine defines the hosting engine
  31962. * @param successCallback defines the callback triggered once the data are available
  31963. * @param mimeType defines the mime type of the result
  31964. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31965. */
  31966. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31967. /**
  31968. * Converts the canvas data to blob.
  31969. * This acts as a polyfill for browsers not supporting the to blob function.
  31970. * @param canvas Defines the canvas to extract the data from
  31971. * @param successCallback Defines the callback triggered once the data are available
  31972. * @param mimeType Defines the mime type of the result
  31973. */
  31974. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31975. /**
  31976. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31977. * @param successCallback defines the callback triggered once the data are available
  31978. * @param mimeType defines the mime type of the result
  31979. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31980. */
  31981. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31982. /**
  31983. * Downloads a blob in the browser
  31984. * @param blob defines the blob to download
  31985. * @param fileName defines the name of the downloaded file
  31986. */
  31987. static Download(blob: Blob, fileName: string): void;
  31988. /**
  31989. * Captures a screenshot of the current rendering
  31990. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31991. * @param engine defines the rendering engine
  31992. * @param camera defines the source camera
  31993. * @param size This parameter can be set to a single number or to an object with the
  31994. * following (optional) properties: precision, width, height. If a single number is passed,
  31995. * it will be used for both width and height. If an object is passed, the screenshot size
  31996. * will be derived from the parameters. The precision property is a multiplier allowing
  31997. * rendering at a higher or lower resolution
  31998. * @param successCallback defines the callback receives a single parameter which contains the
  31999. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32000. * src parameter of an <img> to display it
  32001. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32002. * Check your browser for supported MIME types
  32003. */
  32004. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32005. /**
  32006. * Generates an image screenshot from the specified camera.
  32007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32008. * @param engine The engine to use for rendering
  32009. * @param camera The camera to use for rendering
  32010. * @param size This parameter can be set to a single number or to an object with the
  32011. * following (optional) properties: precision, width, height. If a single number is passed,
  32012. * it will be used for both width and height. If an object is passed, the screenshot size
  32013. * will be derived from the parameters. The precision property is a multiplier allowing
  32014. * rendering at a higher or lower resolution
  32015. * @param successCallback The callback receives a single parameter which contains the
  32016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32017. * src parameter of an <img> to display it
  32018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32019. * Check your browser for supported MIME types
  32020. * @param samples Texture samples (default: 1)
  32021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32022. * @param fileName A name for for the downloaded file.
  32023. */
  32024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32025. /**
  32026. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32027. * Be aware Math.random() could cause collisions, but:
  32028. * "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"
  32029. * @returns a pseudo random id
  32030. */
  32031. static RandomId(): string;
  32032. /**
  32033. * Test if the given uri is a base64 string
  32034. * @param uri The uri to test
  32035. * @return True if the uri is a base64 string or false otherwise
  32036. */
  32037. static IsBase64(uri: string): boolean;
  32038. /**
  32039. * Decode the given base64 uri.
  32040. * @param uri The uri to decode
  32041. * @return The decoded base64 data.
  32042. */
  32043. static DecodeBase64(uri: string): ArrayBuffer;
  32044. /**
  32045. * Gets the absolute url.
  32046. * @param url the input url
  32047. * @return the absolute url
  32048. */
  32049. static GetAbsoluteUrl(url: string): string;
  32050. /**
  32051. * No log
  32052. */
  32053. static readonly NoneLogLevel: number;
  32054. /**
  32055. * Only message logs
  32056. */
  32057. static readonly MessageLogLevel: number;
  32058. /**
  32059. * Only warning logs
  32060. */
  32061. static readonly WarningLogLevel: number;
  32062. /**
  32063. * Only error logs
  32064. */
  32065. static readonly ErrorLogLevel: number;
  32066. /**
  32067. * All logs
  32068. */
  32069. static readonly AllLogLevel: number;
  32070. /**
  32071. * Gets a value indicating the number of loading errors
  32072. * @ignorenaming
  32073. */
  32074. static readonly errorsCount: number;
  32075. /**
  32076. * Callback called when a new log is added
  32077. */
  32078. static OnNewCacheEntry: (entry: string) => void;
  32079. /**
  32080. * Log a message to the console
  32081. * @param message defines the message to log
  32082. */
  32083. static Log(message: string): void;
  32084. /**
  32085. * Write a warning message to the console
  32086. * @param message defines the message to log
  32087. */
  32088. static Warn(message: string): void;
  32089. /**
  32090. * Write an error message to the console
  32091. * @param message defines the message to log
  32092. */
  32093. static Error(message: string): void;
  32094. /**
  32095. * Gets current log cache (list of logs)
  32096. */
  32097. static readonly LogCache: string;
  32098. /**
  32099. * Clears the log cache
  32100. */
  32101. static ClearLogCache(): void;
  32102. /**
  32103. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32104. */
  32105. static LogLevels: number;
  32106. /**
  32107. * Checks if the loaded document was accessed via `file:`-Protocol.
  32108. * @returns boolean
  32109. */
  32110. static IsFileURL(): boolean;
  32111. /**
  32112. * Checks if the window object exists
  32113. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32114. */
  32115. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32116. /**
  32117. * No performance log
  32118. */
  32119. static readonly PerformanceNoneLogLevel: number;
  32120. /**
  32121. * Use user marks to log performance
  32122. */
  32123. static readonly PerformanceUserMarkLogLevel: number;
  32124. /**
  32125. * Log performance to the console
  32126. */
  32127. static readonly PerformanceConsoleLogLevel: number;
  32128. private static _performance;
  32129. /**
  32130. * Sets the current performance log level
  32131. */
  32132. static PerformanceLogLevel: number;
  32133. private static _StartPerformanceCounterDisabled;
  32134. private static _EndPerformanceCounterDisabled;
  32135. private static _StartUserMark;
  32136. private static _EndUserMark;
  32137. private static _StartPerformanceConsole;
  32138. private static _EndPerformanceConsole;
  32139. /**
  32140. * Starts a performance counter
  32141. */
  32142. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32143. /**
  32144. * Ends a specific performance coutner
  32145. */
  32146. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32147. /**
  32148. * Gets either window.performance.now() if supported or Date.now() else
  32149. */
  32150. static readonly Now: number;
  32151. /**
  32152. * This method will return the name of the class used to create the instance of the given object.
  32153. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32154. * @param object the object to get the class name from
  32155. * @param isType defines if the object is actually a type
  32156. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32157. */
  32158. static GetClassName(object: any, isType?: boolean): string;
  32159. /**
  32160. * Gets the first element of an array satisfying a given predicate
  32161. * @param array defines the array to browse
  32162. * @param predicate defines the predicate to use
  32163. * @returns null if not found or the element
  32164. */
  32165. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32166. /**
  32167. * This method will return the name of the full name of the class, including its owning module (if any).
  32168. * 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).
  32169. * @param object the object to get the class name from
  32170. * @param isType defines if the object is actually a type
  32171. * @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.
  32172. * @ignorenaming
  32173. */
  32174. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32175. /**
  32176. * Returns a promise that resolves after the given amount of time.
  32177. * @param delay Number of milliseconds to delay
  32178. * @returns Promise that resolves after the given amount of time
  32179. */
  32180. static DelayAsync(delay: number): Promise<void>;
  32181. /**
  32182. * Gets the current gradient from an array of IValueGradient
  32183. * @param ratio defines the current ratio to get
  32184. * @param gradients defines the array of IValueGradient
  32185. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32186. */
  32187. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32188. }
  32189. /**
  32190. * This class is used to track a performance counter which is number based.
  32191. * The user has access to many properties which give statistics of different nature.
  32192. *
  32193. * The implementer can track two kinds of Performance Counter: time and count.
  32194. * 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.
  32195. * 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.
  32196. */
  32197. export class PerfCounter {
  32198. /**
  32199. * Gets or sets a global boolean to turn on and off all the counters
  32200. */
  32201. static Enabled: boolean;
  32202. /**
  32203. * Returns the smallest value ever
  32204. */
  32205. readonly min: number;
  32206. /**
  32207. * Returns the biggest value ever
  32208. */
  32209. readonly max: number;
  32210. /**
  32211. * Returns the average value since the performance counter is running
  32212. */
  32213. readonly average: number;
  32214. /**
  32215. * Returns the average value of the last second the counter was monitored
  32216. */
  32217. readonly lastSecAverage: number;
  32218. /**
  32219. * Returns the current value
  32220. */
  32221. readonly current: number;
  32222. /**
  32223. * Gets the accumulated total
  32224. */
  32225. readonly total: number;
  32226. /**
  32227. * Gets the total value count
  32228. */
  32229. readonly count: number;
  32230. /**
  32231. * Creates a new counter
  32232. */
  32233. constructor();
  32234. /**
  32235. * Call this method to start monitoring a new frame.
  32236. * 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.
  32237. */
  32238. fetchNewFrame(): void;
  32239. /**
  32240. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32241. * @param newCount the count value to add to the monitored count
  32242. * @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.
  32243. */
  32244. addCount(newCount: number, fetchResult: boolean): void;
  32245. /**
  32246. * Start monitoring this performance counter
  32247. */
  32248. beginMonitoring(): void;
  32249. /**
  32250. * Compute the time lapsed since the previous beginMonitoring() call.
  32251. * @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
  32252. */
  32253. endMonitoring(newFrame?: boolean): void;
  32254. private _fetchResult;
  32255. private _startMonitoringTime;
  32256. private _min;
  32257. private _max;
  32258. private _average;
  32259. private _current;
  32260. private _totalValueCount;
  32261. private _totalAccumulated;
  32262. private _lastSecAverage;
  32263. private _lastSecAccumulated;
  32264. private _lastSecTime;
  32265. private _lastSecValueCount;
  32266. }
  32267. /**
  32268. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32269. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32270. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32271. * @param name The name of the class, case should be preserved
  32272. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32273. */
  32274. export function className(name: string, module?: string): (target: Object) => void;
  32275. /**
  32276. * An implementation of a loop for asynchronous functions.
  32277. */
  32278. export class AsyncLoop {
  32279. /**
  32280. * Defines the number of iterations for the loop
  32281. */
  32282. iterations: number;
  32283. /**
  32284. * Defines the current index of the loop.
  32285. */
  32286. index: number;
  32287. private _done;
  32288. private _fn;
  32289. private _successCallback;
  32290. /**
  32291. * Constructor.
  32292. * @param iterations the number of iterations.
  32293. * @param func the function to run each iteration
  32294. * @param successCallback the callback that will be called upon succesful execution
  32295. * @param offset starting offset.
  32296. */
  32297. constructor(
  32298. /**
  32299. * Defines the number of iterations for the loop
  32300. */
  32301. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32302. /**
  32303. * Execute the next iteration. Must be called after the last iteration was finished.
  32304. */
  32305. executeNext(): void;
  32306. /**
  32307. * Break the loop and run the success callback.
  32308. */
  32309. breakLoop(): void;
  32310. /**
  32311. * Create and run an async loop.
  32312. * @param iterations the number of iterations.
  32313. * @param fn the function to run each iteration
  32314. * @param successCallback the callback that will be called upon succesful execution
  32315. * @param offset starting offset.
  32316. * @returns the created async loop object
  32317. */
  32318. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32319. /**
  32320. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32321. * @param iterations total number of iterations
  32322. * @param syncedIterations number of synchronous iterations in each async iteration.
  32323. * @param fn the function to call each iteration.
  32324. * @param callback a success call back that will be called when iterating stops.
  32325. * @param breakFunction a break condition (optional)
  32326. * @param timeout timeout settings for the setTimeout function. default - 0.
  32327. * @returns the created async loop object
  32328. */
  32329. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32330. }
  32331. }
  32332. declare module "babylonjs/Collisions/collisionCoordinator" {
  32333. import { Nullable } from "babylonjs/types";
  32334. import { Scene } from "babylonjs/scene";
  32335. import { Vector3 } from "babylonjs/Maths/math";
  32336. import { Collider } from "babylonjs/Collisions/collider";
  32337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32338. /** @hidden */
  32339. export interface ICollisionCoordinator {
  32340. createCollider(): Collider;
  32341. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32342. init(scene: Scene): void;
  32343. }
  32344. /** @hidden */
  32345. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32346. private _scene;
  32347. private _scaledPosition;
  32348. private _scaledVelocity;
  32349. private _finalPosition;
  32350. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32351. createCollider(): Collider;
  32352. init(scene: Scene): void;
  32353. private _collideWithWorld;
  32354. }
  32355. }
  32356. declare module "babylonjs/Inputs/scene.inputManager" {
  32357. import { Nullable } from "babylonjs/types";
  32358. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32359. import { Vector2 } from "babylonjs/Maths/math";
  32360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32361. import { Scene } from "babylonjs/scene";
  32362. /**
  32363. * Class used to manage all inputs for the scene.
  32364. */
  32365. export class InputManager {
  32366. /** The distance in pixel that you have to move to prevent some events */
  32367. static DragMovementThreshold: number;
  32368. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32369. static LongPressDelay: number;
  32370. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32371. static DoubleClickDelay: number;
  32372. /** If you need to check double click without raising a single click at first click, enable this flag */
  32373. static ExclusiveDoubleClickMode: boolean;
  32374. private _wheelEventName;
  32375. private _onPointerMove;
  32376. private _onPointerDown;
  32377. private _onPointerUp;
  32378. private _initClickEvent;
  32379. private _initActionManager;
  32380. private _delayedSimpleClick;
  32381. private _delayedSimpleClickTimeout;
  32382. private _previousDelayedSimpleClickTimeout;
  32383. private _meshPickProceed;
  32384. private _previousButtonPressed;
  32385. private _currentPickResult;
  32386. private _previousPickResult;
  32387. private _totalPointersPressed;
  32388. private _doubleClickOccured;
  32389. private _pointerOverMesh;
  32390. private _pickedDownMesh;
  32391. private _pickedUpMesh;
  32392. private _pointerX;
  32393. private _pointerY;
  32394. private _unTranslatedPointerX;
  32395. private _unTranslatedPointerY;
  32396. private _startingPointerPosition;
  32397. private _previousStartingPointerPosition;
  32398. private _startingPointerTime;
  32399. private _previousStartingPointerTime;
  32400. private _pointerCaptures;
  32401. private _onKeyDown;
  32402. private _onKeyUp;
  32403. private _onCanvasFocusObserver;
  32404. private _onCanvasBlurObserver;
  32405. private _scene;
  32406. /**
  32407. * Creates a new InputManager
  32408. * @param scene defines the hosting scene
  32409. */
  32410. constructor(scene: Scene);
  32411. /**
  32412. * Gets the mesh that is currently under the pointer
  32413. */
  32414. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32415. /**
  32416. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32417. */
  32418. readonly unTranslatedPointer: Vector2;
  32419. /**
  32420. * Gets or sets the current on-screen X position of the pointer
  32421. */
  32422. pointerX: number;
  32423. /**
  32424. * Gets or sets the current on-screen Y position of the pointer
  32425. */
  32426. pointerY: number;
  32427. private _updatePointerPosition;
  32428. private _processPointerMove;
  32429. private _setRayOnPointerInfo;
  32430. private _checkPrePointerObservable;
  32431. /**
  32432. * Use this method to simulate a pointer move on a mesh
  32433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32436. */
  32437. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32438. /**
  32439. * Use this method to simulate a pointer down on a mesh
  32440. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32441. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32442. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32443. */
  32444. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32445. private _processPointerDown;
  32446. /** @hidden */
  32447. _isPointerSwiping(): boolean;
  32448. /**
  32449. * Use this method to simulate a pointer up on a mesh
  32450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32453. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32454. */
  32455. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32456. private _processPointerUp;
  32457. /**
  32458. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32459. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32460. * @returns true if the pointer was captured
  32461. */
  32462. isPointerCaptured(pointerId?: number): boolean;
  32463. /**
  32464. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32465. * @param attachUp defines if you want to attach events to pointerup
  32466. * @param attachDown defines if you want to attach events to pointerdown
  32467. * @param attachMove defines if you want to attach events to pointermove
  32468. */
  32469. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32470. /**
  32471. * Detaches all event handlers
  32472. */
  32473. detachControl(): void;
  32474. /**
  32475. * Force the value of meshUnderPointer
  32476. * @param mesh defines the mesh to use
  32477. */
  32478. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32479. /**
  32480. * Gets the mesh under the pointer
  32481. * @returns a Mesh or null if no mesh is under the pointer
  32482. */
  32483. getPointerOverMesh(): Nullable<AbstractMesh>;
  32484. }
  32485. }
  32486. declare module "babylonjs/Animations/animationGroup" {
  32487. import { Animatable } from "babylonjs/Animations/animatable";
  32488. import { Animation } from "babylonjs/Animations/animation";
  32489. import { Scene, IDisposable } from "babylonjs/scene";
  32490. import { Observable } from "babylonjs/Misc/observable";
  32491. import { Nullable } from "babylonjs/types";
  32492. /**
  32493. * This class defines the direct association between an animation and a target
  32494. */
  32495. export class TargetedAnimation {
  32496. /**
  32497. * Animation to perform
  32498. */
  32499. animation: Animation;
  32500. /**
  32501. * Target to animate
  32502. */
  32503. target: any;
  32504. }
  32505. /**
  32506. * Use this class to create coordinated animations on multiple targets
  32507. */
  32508. export class AnimationGroup implements IDisposable {
  32509. /** The name of the animation group */
  32510. name: string;
  32511. private _scene;
  32512. private _targetedAnimations;
  32513. private _animatables;
  32514. private _from;
  32515. private _to;
  32516. private _isStarted;
  32517. private _isPaused;
  32518. private _speedRatio;
  32519. /**
  32520. * Gets or sets the unique id of the node
  32521. */
  32522. uniqueId: number;
  32523. /**
  32524. * This observable will notify when one animation have ended
  32525. */
  32526. onAnimationEndObservable: Observable<TargetedAnimation>;
  32527. /**
  32528. * Observer raised when one animation loops
  32529. */
  32530. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32531. /**
  32532. * This observable will notify when all animations have ended.
  32533. */
  32534. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32535. /**
  32536. * This observable will notify when all animations have paused.
  32537. */
  32538. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32539. /**
  32540. * This observable will notify when all animations are playing.
  32541. */
  32542. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32543. /**
  32544. * Gets the first frame
  32545. */
  32546. readonly from: number;
  32547. /**
  32548. * Gets the last frame
  32549. */
  32550. readonly to: number;
  32551. /**
  32552. * Define if the animations are started
  32553. */
  32554. readonly isStarted: boolean;
  32555. /**
  32556. * Gets a value indicating that the current group is playing
  32557. */
  32558. readonly isPlaying: boolean;
  32559. /**
  32560. * Gets or sets the speed ratio to use for all animations
  32561. */
  32562. /**
  32563. * Gets or sets the speed ratio to use for all animations
  32564. */
  32565. speedRatio: number;
  32566. /**
  32567. * Gets the targeted animations for this animation group
  32568. */
  32569. readonly targetedAnimations: Array<TargetedAnimation>;
  32570. /**
  32571. * returning the list of animatables controlled by this animation group.
  32572. */
  32573. readonly animatables: Array<Animatable>;
  32574. /**
  32575. * Instantiates a new Animation Group.
  32576. * This helps managing several animations at once.
  32577. * @see http://doc.babylonjs.com/how_to/group
  32578. * @param name Defines the name of the group
  32579. * @param scene Defines the scene the group belongs to
  32580. */
  32581. constructor(
  32582. /** The name of the animation group */
  32583. name: string, scene?: Nullable<Scene>);
  32584. /**
  32585. * Add an animation (with its target) in the group
  32586. * @param animation defines the animation we want to add
  32587. * @param target defines the target of the animation
  32588. * @returns the TargetedAnimation object
  32589. */
  32590. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32591. /**
  32592. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32593. * It can add constant keys at begin or end
  32594. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32595. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32596. * @returns the animation group
  32597. */
  32598. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32599. /**
  32600. * Start all animations on given targets
  32601. * @param loop defines if animations must loop
  32602. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32603. * @param from defines the from key (optional)
  32604. * @param to defines the to key (optional)
  32605. * @returns the current animation group
  32606. */
  32607. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32608. /**
  32609. * Pause all animations
  32610. * @returns the animation group
  32611. */
  32612. pause(): AnimationGroup;
  32613. /**
  32614. * Play all animations to initial state
  32615. * This function will start() the animations if they were not started or will restart() them if they were paused
  32616. * @param loop defines if animations must loop
  32617. * @returns the animation group
  32618. */
  32619. play(loop?: boolean): AnimationGroup;
  32620. /**
  32621. * Reset all animations to initial state
  32622. * @returns the animation group
  32623. */
  32624. reset(): AnimationGroup;
  32625. /**
  32626. * Restart animations from key 0
  32627. * @returns the animation group
  32628. */
  32629. restart(): AnimationGroup;
  32630. /**
  32631. * Stop all animations
  32632. * @returns the animation group
  32633. */
  32634. stop(): AnimationGroup;
  32635. /**
  32636. * Set animation weight for all animatables
  32637. * @param weight defines the weight to use
  32638. * @return the animationGroup
  32639. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32640. */
  32641. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32642. /**
  32643. * Synchronize and normalize all animatables with a source animatable
  32644. * @param root defines the root animatable to synchronize with
  32645. * @return the animationGroup
  32646. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32647. */
  32648. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32649. /**
  32650. * Goes to a specific frame in this animation group
  32651. * @param frame the frame number to go to
  32652. * @return the animationGroup
  32653. */
  32654. goToFrame(frame: number): AnimationGroup;
  32655. /**
  32656. * Dispose all associated resources
  32657. */
  32658. dispose(): void;
  32659. private _checkAnimationGroupEnded;
  32660. /**
  32661. * Clone the current animation group and returns a copy
  32662. * @param newName defines the name of the new group
  32663. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32664. * @returns the new aniamtion group
  32665. */
  32666. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32667. /**
  32668. * Returns a new AnimationGroup object parsed from the source provided.
  32669. * @param parsedAnimationGroup defines the source
  32670. * @param scene defines the scene that will receive the animationGroup
  32671. * @returns a new AnimationGroup
  32672. */
  32673. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32674. /**
  32675. * Returns the string "AnimationGroup"
  32676. * @returns "AnimationGroup"
  32677. */
  32678. getClassName(): string;
  32679. /**
  32680. * Creates a detailled string about the object
  32681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32682. * @returns a string representing the object
  32683. */
  32684. toString(fullDetails?: boolean): string;
  32685. }
  32686. }
  32687. declare module "babylonjs/scene" {
  32688. import { Nullable } from "babylonjs/types";
  32689. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32690. import { Observable } from "babylonjs/Misc/observable";
  32691. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32692. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32693. import { Geometry } from "babylonjs/Meshes/geometry";
  32694. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32695. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32697. import { Mesh } from "babylonjs/Meshes/mesh";
  32698. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32699. import { Bone } from "babylonjs/Bones/bone";
  32700. import { Skeleton } from "babylonjs/Bones/skeleton";
  32701. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32702. import { Camera } from "babylonjs/Cameras/camera";
  32703. import { AbstractScene } from "babylonjs/abstractScene";
  32704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32706. import { Material } from "babylonjs/Materials/material";
  32707. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32708. import { Effect } from "babylonjs/Materials/effect";
  32709. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32710. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32711. import { Light } from "babylonjs/Lights/light";
  32712. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32713. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32714. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32715. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32716. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32717. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32719. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32720. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32721. import { Engine } from "babylonjs/Engines/engine";
  32722. import { Node } from "babylonjs/node";
  32723. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32724. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32725. import { WebRequest } from "babylonjs/Misc/webRequest";
  32726. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32727. import { Ray } from "babylonjs/Culling/ray";
  32728. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32729. import { Animation } from "babylonjs/Animations/animation";
  32730. import { Animatable } from "babylonjs/Animations/animatable";
  32731. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32732. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32733. import { Collider } from "babylonjs/Collisions/collider";
  32734. /**
  32735. * Define an interface for all classes that will hold resources
  32736. */
  32737. export interface IDisposable {
  32738. /**
  32739. * Releases all held resources
  32740. */
  32741. dispose(): void;
  32742. }
  32743. /** Interface defining initialization parameters for Scene class */
  32744. export interface SceneOptions {
  32745. /**
  32746. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32747. * It will improve performance when the number of geometries becomes important.
  32748. */
  32749. useGeometryUniqueIdsMap?: boolean;
  32750. /**
  32751. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32752. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32753. */
  32754. useMaterialMeshMap?: boolean;
  32755. /**
  32756. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32757. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32758. */
  32759. useClonedMeshhMap?: boolean;
  32760. }
  32761. /**
  32762. * Represents a scene to be rendered by the engine.
  32763. * @see http://doc.babylonjs.com/features/scene
  32764. */
  32765. export class Scene extends AbstractScene implements IAnimatable {
  32766. private static _uniqueIdCounter;
  32767. /** The fog is deactivated */
  32768. static readonly FOGMODE_NONE: number;
  32769. /** The fog density is following an exponential function */
  32770. static readonly FOGMODE_EXP: number;
  32771. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32772. static readonly FOGMODE_EXP2: number;
  32773. /** The fog density is following a linear function. */
  32774. static readonly FOGMODE_LINEAR: number;
  32775. /**
  32776. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32778. */
  32779. static MinDeltaTime: number;
  32780. /**
  32781. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32782. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32783. */
  32784. static MaxDeltaTime: number;
  32785. /**
  32786. * Factory used to create the default material.
  32787. * @param name The name of the material to create
  32788. * @param scene The scene to create the material for
  32789. * @returns The default material
  32790. */
  32791. static DefaultMaterialFactory(scene: Scene): Material;
  32792. /**
  32793. * Factory used to create the a collision coordinator.
  32794. * @returns The collision coordinator
  32795. */
  32796. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32797. /** @hidden */
  32798. _inputManager: InputManager;
  32799. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32800. cameraToUseForPointers: Nullable<Camera>;
  32801. /** @hidden */
  32802. readonly _isScene: boolean;
  32803. /**
  32804. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32805. */
  32806. autoClear: boolean;
  32807. /**
  32808. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32809. */
  32810. autoClearDepthAndStencil: boolean;
  32811. /**
  32812. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32813. */
  32814. clearColor: Color4;
  32815. /**
  32816. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32817. */
  32818. ambientColor: Color3;
  32819. /**
  32820. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32821. * It should only be one of the following (if not the default embedded one):
  32822. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32823. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32824. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32825. * The material properties need to be setup according to the type of texture in use.
  32826. */
  32827. environmentBRDFTexture: BaseTexture;
  32828. /** @hidden */
  32829. protected _environmentTexture: Nullable<BaseTexture>;
  32830. /**
  32831. * Texture used in all pbr material as the reflection texture.
  32832. * As in the majority of the scene they are the same (exception for multi room and so on),
  32833. * this is easier to reference from here than from all the materials.
  32834. */
  32835. /**
  32836. * Texture used in all pbr material as the reflection texture.
  32837. * As in the majority of the scene they are the same (exception for multi room and so on),
  32838. * this is easier to set here than in all the materials.
  32839. */
  32840. environmentTexture: Nullable<BaseTexture>;
  32841. /** @hidden */
  32842. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32843. /**
  32844. * Default image processing configuration used either in the rendering
  32845. * Forward main pass or through the imageProcessingPostProcess if present.
  32846. * As in the majority of the scene they are the same (exception for multi camera),
  32847. * this is easier to reference from here than from all the materials and post process.
  32848. *
  32849. * No setter as we it is a shared configuration, you can set the values instead.
  32850. */
  32851. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32852. private _forceWireframe;
  32853. /**
  32854. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32855. */
  32856. forceWireframe: boolean;
  32857. private _forcePointsCloud;
  32858. /**
  32859. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32860. */
  32861. forcePointsCloud: boolean;
  32862. /**
  32863. * Gets or sets the active clipplane 1
  32864. */
  32865. clipPlane: Nullable<Plane>;
  32866. /**
  32867. * Gets or sets the active clipplane 2
  32868. */
  32869. clipPlane2: Nullable<Plane>;
  32870. /**
  32871. * Gets or sets the active clipplane 3
  32872. */
  32873. clipPlane3: Nullable<Plane>;
  32874. /**
  32875. * Gets or sets the active clipplane 4
  32876. */
  32877. clipPlane4: Nullable<Plane>;
  32878. /**
  32879. * Gets or sets a boolean indicating if animations are enabled
  32880. */
  32881. animationsEnabled: boolean;
  32882. private _animationPropertiesOverride;
  32883. /**
  32884. * Gets or sets the animation properties override
  32885. */
  32886. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32887. /**
  32888. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32889. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32890. */
  32891. useConstantAnimationDeltaTime: boolean;
  32892. /**
  32893. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32894. * Please note that it requires to run a ray cast through the scene on every frame
  32895. */
  32896. constantlyUpdateMeshUnderPointer: boolean;
  32897. /**
  32898. * Defines the HTML cursor to use when hovering over interactive elements
  32899. */
  32900. hoverCursor: string;
  32901. /**
  32902. * Defines the HTML default cursor to use (empty by default)
  32903. */
  32904. defaultCursor: string;
  32905. /**
  32906. * This is used to call preventDefault() on pointer down
  32907. * in order to block unwanted artifacts like system double clicks
  32908. */
  32909. preventDefaultOnPointerDown: boolean;
  32910. /**
  32911. * This is used to call preventDefault() on pointer up
  32912. * in order to block unwanted artifacts like system double clicks
  32913. */
  32914. preventDefaultOnPointerUp: boolean;
  32915. /**
  32916. * Gets or sets user defined metadata
  32917. */
  32918. metadata: any;
  32919. /**
  32920. * For internal use only. Please do not use.
  32921. */
  32922. reservedDataStore: any;
  32923. /**
  32924. * Gets the name of the plugin used to load this scene (null by default)
  32925. */
  32926. loadingPluginName: string;
  32927. /**
  32928. * Use this array to add regular expressions used to disable offline support for specific urls
  32929. */
  32930. disableOfflineSupportExceptionRules: RegExp[];
  32931. /**
  32932. * An event triggered when the scene is disposed.
  32933. */
  32934. onDisposeObservable: Observable<Scene>;
  32935. private _onDisposeObserver;
  32936. /** Sets a function to be executed when this scene is disposed. */
  32937. onDispose: () => void;
  32938. /**
  32939. * An event triggered before rendering the scene (right after animations and physics)
  32940. */
  32941. onBeforeRenderObservable: Observable<Scene>;
  32942. private _onBeforeRenderObserver;
  32943. /** Sets a function to be executed before rendering this scene */
  32944. beforeRender: Nullable<() => void>;
  32945. /**
  32946. * An event triggered after rendering the scene
  32947. */
  32948. onAfterRenderObservable: Observable<Scene>;
  32949. private _onAfterRenderObserver;
  32950. /** Sets a function to be executed after rendering this scene */
  32951. afterRender: Nullable<() => void>;
  32952. /**
  32953. * An event triggered before animating the scene
  32954. */
  32955. onBeforeAnimationsObservable: Observable<Scene>;
  32956. /**
  32957. * An event triggered after animations processing
  32958. */
  32959. onAfterAnimationsObservable: Observable<Scene>;
  32960. /**
  32961. * An event triggered before draw calls are ready to be sent
  32962. */
  32963. onBeforeDrawPhaseObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered after draw calls have been sent
  32966. */
  32967. onAfterDrawPhaseObservable: Observable<Scene>;
  32968. /**
  32969. * An event triggered when the scene is ready
  32970. */
  32971. onReadyObservable: Observable<Scene>;
  32972. /**
  32973. * An event triggered before rendering a camera
  32974. */
  32975. onBeforeCameraRenderObservable: Observable<Camera>;
  32976. private _onBeforeCameraRenderObserver;
  32977. /** Sets a function to be executed before rendering a camera*/
  32978. beforeCameraRender: () => void;
  32979. /**
  32980. * An event triggered after rendering a camera
  32981. */
  32982. onAfterCameraRenderObservable: Observable<Camera>;
  32983. private _onAfterCameraRenderObserver;
  32984. /** Sets a function to be executed after rendering a camera*/
  32985. afterCameraRender: () => void;
  32986. /**
  32987. * An event triggered when active meshes evaluation is about to start
  32988. */
  32989. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32990. /**
  32991. * An event triggered when active meshes evaluation is done
  32992. */
  32993. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32994. /**
  32995. * An event triggered when particles rendering is about to start
  32996. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32997. */
  32998. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32999. /**
  33000. * An event triggered when particles rendering is done
  33001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33002. */
  33003. onAfterParticlesRenderingObservable: Observable<Scene>;
  33004. /**
  33005. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33006. */
  33007. onDataLoadedObservable: Observable<Scene>;
  33008. /**
  33009. * An event triggered when a camera is created
  33010. */
  33011. onNewCameraAddedObservable: Observable<Camera>;
  33012. /**
  33013. * An event triggered when a camera is removed
  33014. */
  33015. onCameraRemovedObservable: Observable<Camera>;
  33016. /**
  33017. * An event triggered when a light is created
  33018. */
  33019. onNewLightAddedObservable: Observable<Light>;
  33020. /**
  33021. * An event triggered when a light is removed
  33022. */
  33023. onLightRemovedObservable: Observable<Light>;
  33024. /**
  33025. * An event triggered when a geometry is created
  33026. */
  33027. onNewGeometryAddedObservable: Observable<Geometry>;
  33028. /**
  33029. * An event triggered when a geometry is removed
  33030. */
  33031. onGeometryRemovedObservable: Observable<Geometry>;
  33032. /**
  33033. * An event triggered when a transform node is created
  33034. */
  33035. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33036. /**
  33037. * An event triggered when a transform node is removed
  33038. */
  33039. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33040. /**
  33041. * An event triggered when a mesh is created
  33042. */
  33043. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33044. /**
  33045. * An event triggered when a mesh is removed
  33046. */
  33047. onMeshRemovedObservable: Observable<AbstractMesh>;
  33048. /**
  33049. * An event triggered when a skeleton is created
  33050. */
  33051. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33052. /**
  33053. * An event triggered when a skeleton is removed
  33054. */
  33055. onSkeletonRemovedObservable: Observable<Skeleton>;
  33056. /**
  33057. * An event triggered when a material is created
  33058. */
  33059. onNewMaterialAddedObservable: Observable<Material>;
  33060. /**
  33061. * An event triggered when a material is removed
  33062. */
  33063. onMaterialRemovedObservable: Observable<Material>;
  33064. /**
  33065. * An event triggered when a texture is created
  33066. */
  33067. onNewTextureAddedObservable: Observable<BaseTexture>;
  33068. /**
  33069. * An event triggered when a texture is removed
  33070. */
  33071. onTextureRemovedObservable: Observable<BaseTexture>;
  33072. /**
  33073. * An event triggered when render targets are about to be rendered
  33074. * Can happen multiple times per frame.
  33075. */
  33076. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33077. /**
  33078. * An event triggered when render targets were rendered.
  33079. * Can happen multiple times per frame.
  33080. */
  33081. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33082. /**
  33083. * An event triggered before calculating deterministic simulation step
  33084. */
  33085. onBeforeStepObservable: Observable<Scene>;
  33086. /**
  33087. * An event triggered after calculating deterministic simulation step
  33088. */
  33089. onAfterStepObservable: Observable<Scene>;
  33090. /**
  33091. * An event triggered when the activeCamera property is updated
  33092. */
  33093. onActiveCameraChanged: Observable<Scene>;
  33094. /**
  33095. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33096. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33097. * 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)
  33098. */
  33099. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33100. /**
  33101. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33102. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33103. * 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)
  33104. */
  33105. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33106. /**
  33107. * This Observable will when a mesh has been imported into the scene.
  33108. */
  33109. onMeshImportedObservable: Observable<AbstractMesh>;
  33110. /**
  33111. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33112. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33113. */
  33114. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33115. /** @hidden */
  33116. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33117. /**
  33118. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33119. */
  33120. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33121. /**
  33122. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33123. */
  33124. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33125. /**
  33126. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33127. */
  33128. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33129. /** Callback called when a pointer move is detected */
  33130. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33131. /** Callback called when a pointer down is detected */
  33132. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33133. /** Callback called when a pointer up is detected */
  33134. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33135. /** Callback called when a pointer pick is detected */
  33136. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33137. /**
  33138. * 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).
  33139. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33140. */
  33141. onPrePointerObservable: Observable<PointerInfoPre>;
  33142. /**
  33143. * Observable event triggered each time an input event is received from the rendering canvas
  33144. */
  33145. onPointerObservable: Observable<PointerInfo>;
  33146. /**
  33147. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33148. */
  33149. readonly unTranslatedPointer: Vector2;
  33150. /**
  33151. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33152. */
  33153. static DragMovementThreshold: number;
  33154. /**
  33155. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33156. */
  33157. static LongPressDelay: number;
  33158. /**
  33159. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33160. */
  33161. static DoubleClickDelay: number;
  33162. /** If you need to check double click without raising a single click at first click, enable this flag */
  33163. static ExclusiveDoubleClickMode: boolean;
  33164. /** @hidden */
  33165. _mirroredCameraPosition: Nullable<Vector3>;
  33166. /**
  33167. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33168. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33169. */
  33170. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33171. /**
  33172. * Observable event triggered each time an keyboard event is received from the hosting window
  33173. */
  33174. onKeyboardObservable: Observable<KeyboardInfo>;
  33175. private _useRightHandedSystem;
  33176. /**
  33177. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33178. */
  33179. useRightHandedSystem: boolean;
  33180. private _timeAccumulator;
  33181. private _currentStepId;
  33182. private _currentInternalStep;
  33183. /**
  33184. * Sets the step Id used by deterministic lock step
  33185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33186. * @param newStepId defines the step Id
  33187. */
  33188. setStepId(newStepId: number): void;
  33189. /**
  33190. * Gets the step Id used by deterministic lock step
  33191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33192. * @returns the step Id
  33193. */
  33194. getStepId(): number;
  33195. /**
  33196. * Gets the internal step used by deterministic lock step
  33197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33198. * @returns the internal step
  33199. */
  33200. getInternalStep(): number;
  33201. private _fogEnabled;
  33202. /**
  33203. * Gets or sets a boolean indicating if fog is enabled on this scene
  33204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33205. * (Default is true)
  33206. */
  33207. fogEnabled: boolean;
  33208. private _fogMode;
  33209. /**
  33210. * Gets or sets the fog mode to use
  33211. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33212. * | mode | value |
  33213. * | --- | --- |
  33214. * | FOGMODE_NONE | 0 |
  33215. * | FOGMODE_EXP | 1 |
  33216. * | FOGMODE_EXP2 | 2 |
  33217. * | FOGMODE_LINEAR | 3 |
  33218. */
  33219. fogMode: number;
  33220. /**
  33221. * Gets or sets the fog color to use
  33222. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33223. * (Default is Color3(0.2, 0.2, 0.3))
  33224. */
  33225. fogColor: Color3;
  33226. /**
  33227. * Gets or sets the fog density to use
  33228. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33229. * (Default is 0.1)
  33230. */
  33231. fogDensity: number;
  33232. /**
  33233. * Gets or sets the fog start distance to use
  33234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33235. * (Default is 0)
  33236. */
  33237. fogStart: number;
  33238. /**
  33239. * Gets or sets the fog end distance to use
  33240. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33241. * (Default is 1000)
  33242. */
  33243. fogEnd: number;
  33244. private _shadowsEnabled;
  33245. /**
  33246. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33247. */
  33248. shadowsEnabled: boolean;
  33249. private _lightsEnabled;
  33250. /**
  33251. * Gets or sets a boolean indicating if lights are enabled on this scene
  33252. */
  33253. lightsEnabled: boolean;
  33254. /** All of the active cameras added to this scene. */
  33255. activeCameras: Camera[];
  33256. /** @hidden */
  33257. _activeCamera: Nullable<Camera>;
  33258. /** Gets or sets the current active camera */
  33259. activeCamera: Nullable<Camera>;
  33260. private _defaultMaterial;
  33261. /** The default material used on meshes when no material is affected */
  33262. /** The default material used on meshes when no material is affected */
  33263. defaultMaterial: Material;
  33264. private _texturesEnabled;
  33265. /**
  33266. * Gets or sets a boolean indicating if textures are enabled on this scene
  33267. */
  33268. texturesEnabled: boolean;
  33269. /**
  33270. * Gets or sets a boolean indicating if particles are enabled on this scene
  33271. */
  33272. particlesEnabled: boolean;
  33273. /**
  33274. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33275. */
  33276. spritesEnabled: boolean;
  33277. private _skeletonsEnabled;
  33278. /**
  33279. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33280. */
  33281. skeletonsEnabled: boolean;
  33282. /**
  33283. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33284. */
  33285. lensFlaresEnabled: boolean;
  33286. /**
  33287. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33289. */
  33290. collisionsEnabled: boolean;
  33291. private _collisionCoordinator;
  33292. /** @hidden */
  33293. readonly collisionCoordinator: ICollisionCoordinator;
  33294. /**
  33295. * Defines the gravity applied to this scene (used only for collisions)
  33296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33297. */
  33298. gravity: Vector3;
  33299. /**
  33300. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33301. */
  33302. postProcessesEnabled: boolean;
  33303. /**
  33304. * The list of postprocesses added to the scene
  33305. */
  33306. postProcesses: PostProcess[];
  33307. /**
  33308. * Gets the current postprocess manager
  33309. */
  33310. postProcessManager: PostProcessManager;
  33311. /**
  33312. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33313. */
  33314. renderTargetsEnabled: boolean;
  33315. /**
  33316. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33317. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33318. */
  33319. dumpNextRenderTargets: boolean;
  33320. /**
  33321. * The list of user defined render targets added to the scene
  33322. */
  33323. customRenderTargets: RenderTargetTexture[];
  33324. /**
  33325. * Defines if texture loading must be delayed
  33326. * If true, textures will only be loaded when they need to be rendered
  33327. */
  33328. useDelayedTextureLoading: boolean;
  33329. /**
  33330. * Gets the list of meshes imported to the scene through SceneLoader
  33331. */
  33332. importedMeshesFiles: String[];
  33333. /**
  33334. * Gets or sets a boolean indicating if probes are enabled on this scene
  33335. */
  33336. probesEnabled: boolean;
  33337. /**
  33338. * Gets or sets the current offline provider to use to store scene data
  33339. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33340. */
  33341. offlineProvider: IOfflineProvider;
  33342. /**
  33343. * Gets or sets the action manager associated with the scene
  33344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33345. */
  33346. actionManager: AbstractActionManager;
  33347. private _meshesForIntersections;
  33348. /**
  33349. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33350. */
  33351. proceduralTexturesEnabled: boolean;
  33352. private _engine;
  33353. private _totalVertices;
  33354. /** @hidden */
  33355. _activeIndices: PerfCounter;
  33356. /** @hidden */
  33357. _activeParticles: PerfCounter;
  33358. /** @hidden */
  33359. _activeBones: PerfCounter;
  33360. private _animationRatio;
  33361. /** @hidden */
  33362. _animationTimeLast: number;
  33363. /** @hidden */
  33364. _animationTime: number;
  33365. /**
  33366. * Gets or sets a general scale for animation speed
  33367. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33368. */
  33369. animationTimeScale: number;
  33370. /** @hidden */
  33371. _cachedMaterial: Nullable<Material>;
  33372. /** @hidden */
  33373. _cachedEffect: Nullable<Effect>;
  33374. /** @hidden */
  33375. _cachedVisibility: Nullable<number>;
  33376. private _renderId;
  33377. private _frameId;
  33378. private _executeWhenReadyTimeoutId;
  33379. private _intermediateRendering;
  33380. private _viewUpdateFlag;
  33381. private _projectionUpdateFlag;
  33382. /** @hidden */
  33383. _toBeDisposed: Nullable<IDisposable>[];
  33384. private _activeRequests;
  33385. /** @hidden */
  33386. _pendingData: any[];
  33387. private _isDisposed;
  33388. /**
  33389. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33390. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33391. */
  33392. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33393. private _activeMeshes;
  33394. private _processedMaterials;
  33395. private _renderTargets;
  33396. /** @hidden */
  33397. _activeParticleSystems: SmartArray<IParticleSystem>;
  33398. private _activeSkeletons;
  33399. private _softwareSkinnedMeshes;
  33400. private _renderingManager;
  33401. /** @hidden */
  33402. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33403. private _transformMatrix;
  33404. private _sceneUbo;
  33405. /** @hidden */
  33406. _viewMatrix: Matrix;
  33407. private _projectionMatrix;
  33408. /** @hidden */
  33409. _forcedViewPosition: Nullable<Vector3>;
  33410. /** @hidden */
  33411. _frustumPlanes: Plane[];
  33412. /**
  33413. * Gets the list of frustum planes (built from the active camera)
  33414. */
  33415. readonly frustumPlanes: Plane[];
  33416. /**
  33417. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33418. * This is useful if there are more lights that the maximum simulteanous authorized
  33419. */
  33420. requireLightSorting: boolean;
  33421. /** @hidden */
  33422. readonly useMaterialMeshMap: boolean;
  33423. /** @hidden */
  33424. readonly useClonedMeshhMap: boolean;
  33425. private _externalData;
  33426. private _uid;
  33427. /**
  33428. * @hidden
  33429. * Backing store of defined scene components.
  33430. */
  33431. _components: ISceneComponent[];
  33432. /**
  33433. * @hidden
  33434. * Backing store of defined scene components.
  33435. */
  33436. _serializableComponents: ISceneSerializableComponent[];
  33437. /**
  33438. * List of components to register on the next registration step.
  33439. */
  33440. private _transientComponents;
  33441. /**
  33442. * Registers the transient components if needed.
  33443. */
  33444. private _registerTransientComponents;
  33445. /**
  33446. * @hidden
  33447. * Add a component to the scene.
  33448. * Note that the ccomponent could be registered on th next frame if this is called after
  33449. * the register component stage.
  33450. * @param component Defines the component to add to the scene
  33451. */
  33452. _addComponent(component: ISceneComponent): void;
  33453. /**
  33454. * @hidden
  33455. * Gets a component from the scene.
  33456. * @param name defines the name of the component to retrieve
  33457. * @returns the component or null if not present
  33458. */
  33459. _getComponent(name: string): Nullable<ISceneComponent>;
  33460. /**
  33461. * @hidden
  33462. * Defines the actions happening before camera updates.
  33463. */
  33464. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33465. /**
  33466. * @hidden
  33467. * Defines the actions happening before clear the canvas.
  33468. */
  33469. _beforeClearStage: Stage<SimpleStageAction>;
  33470. /**
  33471. * @hidden
  33472. * Defines the actions when collecting render targets for the frame.
  33473. */
  33474. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33475. /**
  33476. * @hidden
  33477. * Defines the actions happening for one camera in the frame.
  33478. */
  33479. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33480. /**
  33481. * @hidden
  33482. * Defines the actions happening during the per mesh ready checks.
  33483. */
  33484. _isReadyForMeshStage: Stage<MeshStageAction>;
  33485. /**
  33486. * @hidden
  33487. * Defines the actions happening before evaluate active mesh checks.
  33488. */
  33489. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33490. /**
  33491. * @hidden
  33492. * Defines the actions happening during the evaluate sub mesh checks.
  33493. */
  33494. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33495. /**
  33496. * @hidden
  33497. * Defines the actions happening during the active mesh stage.
  33498. */
  33499. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33500. /**
  33501. * @hidden
  33502. * Defines the actions happening during the per camera render target step.
  33503. */
  33504. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33505. /**
  33506. * @hidden
  33507. * Defines the actions happening just before the active camera is drawing.
  33508. */
  33509. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33510. /**
  33511. * @hidden
  33512. * Defines the actions happening just before a render target is drawing.
  33513. */
  33514. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33515. /**
  33516. * @hidden
  33517. * Defines the actions happening just before a rendering group is drawing.
  33518. */
  33519. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33520. /**
  33521. * @hidden
  33522. * Defines the actions happening just before a mesh is drawing.
  33523. */
  33524. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33525. /**
  33526. * @hidden
  33527. * Defines the actions happening just after a mesh has been drawn.
  33528. */
  33529. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33530. /**
  33531. * @hidden
  33532. * Defines the actions happening just after a rendering group has been drawn.
  33533. */
  33534. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33535. /**
  33536. * @hidden
  33537. * Defines the actions happening just after the active camera has been drawn.
  33538. */
  33539. _afterCameraDrawStage: Stage<CameraStageAction>;
  33540. /**
  33541. * @hidden
  33542. * Defines the actions happening just after a render target has been drawn.
  33543. */
  33544. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33545. /**
  33546. * @hidden
  33547. * Defines the actions happening just after rendering all cameras and computing intersections.
  33548. */
  33549. _afterRenderStage: Stage<SimpleStageAction>;
  33550. /**
  33551. * @hidden
  33552. * Defines the actions happening when a pointer move event happens.
  33553. */
  33554. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33555. /**
  33556. * @hidden
  33557. * Defines the actions happening when a pointer down event happens.
  33558. */
  33559. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33560. /**
  33561. * @hidden
  33562. * Defines the actions happening when a pointer up event happens.
  33563. */
  33564. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33565. /**
  33566. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33567. */
  33568. private geometriesByUniqueId;
  33569. /**
  33570. * Creates a new Scene
  33571. * @param engine defines the engine to use to render this scene
  33572. * @param options defines the scene options
  33573. */
  33574. constructor(engine: Engine, options?: SceneOptions);
  33575. /**
  33576. * Gets a string idenfifying the name of the class
  33577. * @returns "Scene" string
  33578. */
  33579. getClassName(): string;
  33580. private _defaultMeshCandidates;
  33581. /**
  33582. * @hidden
  33583. */
  33584. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33585. private _defaultSubMeshCandidates;
  33586. /**
  33587. * @hidden
  33588. */
  33589. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33590. /**
  33591. * Sets the default candidate providers for the scene.
  33592. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33593. * and getCollidingSubMeshCandidates to their default function
  33594. */
  33595. setDefaultCandidateProviders(): void;
  33596. /**
  33597. * Gets the mesh that is currently under the pointer
  33598. */
  33599. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33600. /**
  33601. * Gets or sets the current on-screen X position of the pointer
  33602. */
  33603. pointerX: number;
  33604. /**
  33605. * Gets or sets the current on-screen Y position of the pointer
  33606. */
  33607. pointerY: number;
  33608. /**
  33609. * Gets the cached material (ie. the latest rendered one)
  33610. * @returns the cached material
  33611. */
  33612. getCachedMaterial(): Nullable<Material>;
  33613. /**
  33614. * Gets the cached effect (ie. the latest rendered one)
  33615. * @returns the cached effect
  33616. */
  33617. getCachedEffect(): Nullable<Effect>;
  33618. /**
  33619. * Gets the cached visibility state (ie. the latest rendered one)
  33620. * @returns the cached visibility state
  33621. */
  33622. getCachedVisibility(): Nullable<number>;
  33623. /**
  33624. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33625. * @param material defines the current material
  33626. * @param effect defines the current effect
  33627. * @param visibility defines the current visibility state
  33628. * @returns true if one parameter is not cached
  33629. */
  33630. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33631. /**
  33632. * Gets the engine associated with the scene
  33633. * @returns an Engine
  33634. */
  33635. getEngine(): Engine;
  33636. /**
  33637. * Gets the total number of vertices rendered per frame
  33638. * @returns the total number of vertices rendered per frame
  33639. */
  33640. getTotalVertices(): number;
  33641. /**
  33642. * Gets the performance counter for total vertices
  33643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33644. */
  33645. readonly totalVerticesPerfCounter: PerfCounter;
  33646. /**
  33647. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33648. * @returns the total number of active indices rendered per frame
  33649. */
  33650. getActiveIndices(): number;
  33651. /**
  33652. * Gets the performance counter for active indices
  33653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33654. */
  33655. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33656. /**
  33657. * Gets the total number of active particles rendered per frame
  33658. * @returns the total number of active particles rendered per frame
  33659. */
  33660. getActiveParticles(): number;
  33661. /**
  33662. * Gets the performance counter for active particles
  33663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33664. */
  33665. readonly activeParticlesPerfCounter: PerfCounter;
  33666. /**
  33667. * Gets the total number of active bones rendered per frame
  33668. * @returns the total number of active bones rendered per frame
  33669. */
  33670. getActiveBones(): number;
  33671. /**
  33672. * Gets the performance counter for active bones
  33673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33674. */
  33675. readonly activeBonesPerfCounter: PerfCounter;
  33676. /**
  33677. * Gets the array of active meshes
  33678. * @returns an array of AbstractMesh
  33679. */
  33680. getActiveMeshes(): SmartArray<AbstractMesh>;
  33681. /**
  33682. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33683. * @returns a number
  33684. */
  33685. getAnimationRatio(): number;
  33686. /**
  33687. * Gets an unique Id for the current render phase
  33688. * @returns a number
  33689. */
  33690. getRenderId(): number;
  33691. /**
  33692. * Gets an unique Id for the current frame
  33693. * @returns a number
  33694. */
  33695. getFrameId(): number;
  33696. /** Call this function if you want to manually increment the render Id*/
  33697. incrementRenderId(): void;
  33698. private _createUbo;
  33699. /**
  33700. * Use this method to simulate a pointer move on a mesh
  33701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33704. * @returns the current scene
  33705. */
  33706. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33707. /**
  33708. * Use this method to simulate a pointer down on a mesh
  33709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33712. * @returns the current scene
  33713. */
  33714. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33715. /**
  33716. * Use this method to simulate a pointer up on a mesh
  33717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33720. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33721. * @returns the current scene
  33722. */
  33723. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33724. /**
  33725. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33726. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33727. * @returns true if the pointer was captured
  33728. */
  33729. isPointerCaptured(pointerId?: number): boolean;
  33730. /**
  33731. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33732. * @param attachUp defines if you want to attach events to pointerup
  33733. * @param attachDown defines if you want to attach events to pointerdown
  33734. * @param attachMove defines if you want to attach events to pointermove
  33735. */
  33736. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33737. /** Detaches all event handlers*/
  33738. detachControl(): void;
  33739. /**
  33740. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33741. * Delay loaded resources are not taking in account
  33742. * @return true if all required resources are ready
  33743. */
  33744. isReady(): boolean;
  33745. /** Resets all cached information relative to material (including effect and visibility) */
  33746. resetCachedMaterial(): void;
  33747. /**
  33748. * Registers a function to be called before every frame render
  33749. * @param func defines the function to register
  33750. */
  33751. registerBeforeRender(func: () => void): void;
  33752. /**
  33753. * Unregisters a function called before every frame render
  33754. * @param func defines the function to unregister
  33755. */
  33756. unregisterBeforeRender(func: () => void): void;
  33757. /**
  33758. * Registers a function to be called after every frame render
  33759. * @param func defines the function to register
  33760. */
  33761. registerAfterRender(func: () => void): void;
  33762. /**
  33763. * Unregisters a function called after every frame render
  33764. * @param func defines the function to unregister
  33765. */
  33766. unregisterAfterRender(func: () => void): void;
  33767. private _executeOnceBeforeRender;
  33768. /**
  33769. * The provided function will run before render once and will be disposed afterwards.
  33770. * A timeout delay can be provided so that the function will be executed in N ms.
  33771. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33772. * @param func The function to be executed.
  33773. * @param timeout optional delay in ms
  33774. */
  33775. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33776. /** @hidden */
  33777. _addPendingData(data: any): void;
  33778. /** @hidden */
  33779. _removePendingData(data: any): void;
  33780. /**
  33781. * Returns the number of items waiting to be loaded
  33782. * @returns the number of items waiting to be loaded
  33783. */
  33784. getWaitingItemsCount(): number;
  33785. /**
  33786. * Returns a boolean indicating if the scene is still loading data
  33787. */
  33788. readonly isLoading: boolean;
  33789. /**
  33790. * Registers a function to be executed when the scene is ready
  33791. * @param {Function} func - the function to be executed
  33792. */
  33793. executeWhenReady(func: () => void): void;
  33794. /**
  33795. * Returns a promise that resolves when the scene is ready
  33796. * @returns A promise that resolves when the scene is ready
  33797. */
  33798. whenReadyAsync(): Promise<void>;
  33799. /** @hidden */
  33800. _checkIsReady(): void;
  33801. /**
  33802. * Gets all animatable attached to the scene
  33803. */
  33804. readonly animatables: Animatable[];
  33805. /**
  33806. * Resets the last animation time frame.
  33807. * Useful to override when animations start running when loading a scene for the first time.
  33808. */
  33809. resetLastAnimationTimeFrame(): void;
  33810. /**
  33811. * Gets the current view matrix
  33812. * @returns a Matrix
  33813. */
  33814. getViewMatrix(): Matrix;
  33815. /**
  33816. * Gets the current projection matrix
  33817. * @returns a Matrix
  33818. */
  33819. getProjectionMatrix(): Matrix;
  33820. /**
  33821. * Gets the current transform matrix
  33822. * @returns a Matrix made of View * Projection
  33823. */
  33824. getTransformMatrix(): Matrix;
  33825. /**
  33826. * Sets the current transform matrix
  33827. * @param viewL defines the View matrix to use
  33828. * @param projectionL defines the Projection matrix to use
  33829. * @param viewR defines the right View matrix to use (if provided)
  33830. * @param projectionR defines the right Projection matrix to use (if provided)
  33831. */
  33832. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33833. /**
  33834. * Gets the uniform buffer used to store scene data
  33835. * @returns a UniformBuffer
  33836. */
  33837. getSceneUniformBuffer(): UniformBuffer;
  33838. /**
  33839. * Gets an unique (relatively to the current scene) Id
  33840. * @returns an unique number for the scene
  33841. */
  33842. getUniqueId(): number;
  33843. /**
  33844. * Add a mesh to the list of scene's meshes
  33845. * @param newMesh defines the mesh to add
  33846. * @param recursive if all child meshes should also be added to the scene
  33847. */
  33848. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33849. /**
  33850. * Remove a mesh for the list of scene's meshes
  33851. * @param toRemove defines the mesh to remove
  33852. * @param recursive if all child meshes should also be removed from the scene
  33853. * @returns the index where the mesh was in the mesh list
  33854. */
  33855. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33856. /**
  33857. * Add a transform node to the list of scene's transform nodes
  33858. * @param newTransformNode defines the transform node to add
  33859. */
  33860. addTransformNode(newTransformNode: TransformNode): void;
  33861. /**
  33862. * Remove a transform node for the list of scene's transform nodes
  33863. * @param toRemove defines the transform node to remove
  33864. * @returns the index where the transform node was in the transform node list
  33865. */
  33866. removeTransformNode(toRemove: TransformNode): number;
  33867. /**
  33868. * Remove a skeleton for the list of scene's skeletons
  33869. * @param toRemove defines the skeleton to remove
  33870. * @returns the index where the skeleton was in the skeleton list
  33871. */
  33872. removeSkeleton(toRemove: Skeleton): number;
  33873. /**
  33874. * Remove a morph target for the list of scene's morph targets
  33875. * @param toRemove defines the morph target to remove
  33876. * @returns the index where the morph target was in the morph target list
  33877. */
  33878. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33879. /**
  33880. * Remove a light for the list of scene's lights
  33881. * @param toRemove defines the light to remove
  33882. * @returns the index where the light was in the light list
  33883. */
  33884. removeLight(toRemove: Light): number;
  33885. /**
  33886. * Remove a camera for the list of scene's cameras
  33887. * @param toRemove defines the camera to remove
  33888. * @returns the index where the camera was in the camera list
  33889. */
  33890. removeCamera(toRemove: Camera): number;
  33891. /**
  33892. * Remove a particle system for the list of scene's particle systems
  33893. * @param toRemove defines the particle system to remove
  33894. * @returns the index where the particle system was in the particle system list
  33895. */
  33896. removeParticleSystem(toRemove: IParticleSystem): number;
  33897. /**
  33898. * Remove a animation for the list of scene's animations
  33899. * @param toRemove defines the animation to remove
  33900. * @returns the index where the animation was in the animation list
  33901. */
  33902. removeAnimation(toRemove: Animation): number;
  33903. /**
  33904. * Will stop the animation of the given target
  33905. * @param target - the target
  33906. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33907. * @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)
  33908. */
  33909. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33910. /**
  33911. * Removes the given animation group from this scene.
  33912. * @param toRemove The animation group to remove
  33913. * @returns The index of the removed animation group
  33914. */
  33915. removeAnimationGroup(toRemove: AnimationGroup): number;
  33916. /**
  33917. * Removes the given multi-material from this scene.
  33918. * @param toRemove The multi-material to remove
  33919. * @returns The index of the removed multi-material
  33920. */
  33921. removeMultiMaterial(toRemove: MultiMaterial): number;
  33922. /**
  33923. * Removes the given material from this scene.
  33924. * @param toRemove The material to remove
  33925. * @returns The index of the removed material
  33926. */
  33927. removeMaterial(toRemove: Material): number;
  33928. /**
  33929. * Removes the given action manager from this scene.
  33930. * @param toRemove The action manager to remove
  33931. * @returns The index of the removed action manager
  33932. */
  33933. removeActionManager(toRemove: AbstractActionManager): number;
  33934. /**
  33935. * Removes the given texture from this scene.
  33936. * @param toRemove The texture to remove
  33937. * @returns The index of the removed texture
  33938. */
  33939. removeTexture(toRemove: BaseTexture): number;
  33940. /**
  33941. * Adds the given light to this scene
  33942. * @param newLight The light to add
  33943. */
  33944. addLight(newLight: Light): void;
  33945. /**
  33946. * Sorts the list list based on light priorities
  33947. */
  33948. sortLightsByPriority(): void;
  33949. /**
  33950. * Adds the given camera to this scene
  33951. * @param newCamera The camera to add
  33952. */
  33953. addCamera(newCamera: Camera): void;
  33954. /**
  33955. * Adds the given skeleton to this scene
  33956. * @param newSkeleton The skeleton to add
  33957. */
  33958. addSkeleton(newSkeleton: Skeleton): void;
  33959. /**
  33960. * Adds the given particle system to this scene
  33961. * @param newParticleSystem The particle system to add
  33962. */
  33963. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33964. /**
  33965. * Adds the given animation to this scene
  33966. * @param newAnimation The animation to add
  33967. */
  33968. addAnimation(newAnimation: Animation): void;
  33969. /**
  33970. * Adds the given animation group to this scene.
  33971. * @param newAnimationGroup The animation group to add
  33972. */
  33973. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33974. /**
  33975. * Adds the given multi-material to this scene
  33976. * @param newMultiMaterial The multi-material to add
  33977. */
  33978. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33979. /**
  33980. * Adds the given material to this scene
  33981. * @param newMaterial The material to add
  33982. */
  33983. addMaterial(newMaterial: Material): void;
  33984. /**
  33985. * Adds the given morph target to this scene
  33986. * @param newMorphTargetManager The morph target to add
  33987. */
  33988. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33989. /**
  33990. * Adds the given geometry to this scene
  33991. * @param newGeometry The geometry to add
  33992. */
  33993. addGeometry(newGeometry: Geometry): void;
  33994. /**
  33995. * Adds the given action manager to this scene
  33996. * @param newActionManager The action manager to add
  33997. */
  33998. addActionManager(newActionManager: AbstractActionManager): void;
  33999. /**
  34000. * Adds the given texture to this scene.
  34001. * @param newTexture The texture to add
  34002. */
  34003. addTexture(newTexture: BaseTexture): void;
  34004. /**
  34005. * Switch active camera
  34006. * @param newCamera defines the new active camera
  34007. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34008. */
  34009. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34010. /**
  34011. * sets the active camera of the scene using its ID
  34012. * @param id defines the camera's ID
  34013. * @return the new active camera or null if none found.
  34014. */
  34015. setActiveCameraByID(id: string): Nullable<Camera>;
  34016. /**
  34017. * sets the active camera of the scene using its name
  34018. * @param name defines the camera's name
  34019. * @returns the new active camera or null if none found.
  34020. */
  34021. setActiveCameraByName(name: string): Nullable<Camera>;
  34022. /**
  34023. * get an animation group using its name
  34024. * @param name defines the material's name
  34025. * @return the animation group or null if none found.
  34026. */
  34027. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34028. /**
  34029. * Get a material using its unique id
  34030. * @param uniqueId defines the material's unique id
  34031. * @return the material or null if none found.
  34032. */
  34033. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34034. /**
  34035. * get a material using its id
  34036. * @param id defines the material's ID
  34037. * @return the material or null if none found.
  34038. */
  34039. getMaterialByID(id: string): Nullable<Material>;
  34040. /**
  34041. * Gets a material using its name
  34042. * @param name defines the material's name
  34043. * @return the material or null if none found.
  34044. */
  34045. getMaterialByName(name: string): Nullable<Material>;
  34046. /**
  34047. * Gets a camera using its id
  34048. * @param id defines the id to look for
  34049. * @returns the camera or null if not found
  34050. */
  34051. getCameraByID(id: string): Nullable<Camera>;
  34052. /**
  34053. * Gets a camera using its unique id
  34054. * @param uniqueId defines the unique id to look for
  34055. * @returns the camera or null if not found
  34056. */
  34057. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34058. /**
  34059. * Gets a camera using its name
  34060. * @param name defines the camera's name
  34061. * @return the camera or null if none found.
  34062. */
  34063. getCameraByName(name: string): Nullable<Camera>;
  34064. /**
  34065. * Gets a bone using its id
  34066. * @param id defines the bone's id
  34067. * @return the bone or null if not found
  34068. */
  34069. getBoneByID(id: string): Nullable<Bone>;
  34070. /**
  34071. * Gets a bone using its id
  34072. * @param name defines the bone's name
  34073. * @return the bone or null if not found
  34074. */
  34075. getBoneByName(name: string): Nullable<Bone>;
  34076. /**
  34077. * Gets a light node using its name
  34078. * @param name defines the the light's name
  34079. * @return the light or null if none found.
  34080. */
  34081. getLightByName(name: string): Nullable<Light>;
  34082. /**
  34083. * Gets a light node using its id
  34084. * @param id defines the light's id
  34085. * @return the light or null if none found.
  34086. */
  34087. getLightByID(id: string): Nullable<Light>;
  34088. /**
  34089. * Gets a light node using its scene-generated unique ID
  34090. * @param uniqueId defines the light's unique id
  34091. * @return the light or null if none found.
  34092. */
  34093. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34094. /**
  34095. * Gets a particle system by id
  34096. * @param id defines the particle system id
  34097. * @return the corresponding system or null if none found
  34098. */
  34099. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34100. /**
  34101. * Gets a geometry using its ID
  34102. * @param id defines the geometry's id
  34103. * @return the geometry or null if none found.
  34104. */
  34105. getGeometryByID(id: string): Nullable<Geometry>;
  34106. private _getGeometryByUniqueID;
  34107. /**
  34108. * Add a new geometry to this scene
  34109. * @param geometry defines the geometry to be added to the scene.
  34110. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34111. * @return a boolean defining if the geometry was added or not
  34112. */
  34113. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34114. /**
  34115. * Removes an existing geometry
  34116. * @param geometry defines the geometry to be removed from the scene
  34117. * @return a boolean defining if the geometry was removed or not
  34118. */
  34119. removeGeometry(geometry: Geometry): boolean;
  34120. /**
  34121. * Gets the list of geometries attached to the scene
  34122. * @returns an array of Geometry
  34123. */
  34124. getGeometries(): Geometry[];
  34125. /**
  34126. * Gets the first added mesh found of a given ID
  34127. * @param id defines the id to search for
  34128. * @return the mesh found or null if not found at all
  34129. */
  34130. getMeshByID(id: string): Nullable<AbstractMesh>;
  34131. /**
  34132. * Gets a list of meshes using their id
  34133. * @param id defines the id to search for
  34134. * @returns a list of meshes
  34135. */
  34136. getMeshesByID(id: string): Array<AbstractMesh>;
  34137. /**
  34138. * Gets the first added transform node found of a given ID
  34139. * @param id defines the id to search for
  34140. * @return the found transform node or null if not found at all.
  34141. */
  34142. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34143. /**
  34144. * Gets a transform node with its auto-generated unique id
  34145. * @param uniqueId efines the unique id to search for
  34146. * @return the found transform node or null if not found at all.
  34147. */
  34148. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34149. /**
  34150. * Gets a list of transform nodes using their id
  34151. * @param id defines the id to search for
  34152. * @returns a list of transform nodes
  34153. */
  34154. getTransformNodesByID(id: string): Array<TransformNode>;
  34155. /**
  34156. * Gets a mesh with its auto-generated unique id
  34157. * @param uniqueId defines the unique id to search for
  34158. * @return the found mesh or null if not found at all.
  34159. */
  34160. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34161. /**
  34162. * Gets a the last added mesh using a given id
  34163. * @param id defines the id to search for
  34164. * @return the found mesh or null if not found at all.
  34165. */
  34166. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34167. /**
  34168. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34169. * @param id defines the id to search for
  34170. * @return the found node or null if not found at all
  34171. */
  34172. getLastEntryByID(id: string): Nullable<Node>;
  34173. /**
  34174. * Gets a node (Mesh, Camera, Light) using a given id
  34175. * @param id defines the id to search for
  34176. * @return the found node or null if not found at all
  34177. */
  34178. getNodeByID(id: string): Nullable<Node>;
  34179. /**
  34180. * Gets a node (Mesh, Camera, Light) using a given name
  34181. * @param name defines the name to search for
  34182. * @return the found node or null if not found at all.
  34183. */
  34184. getNodeByName(name: string): Nullable<Node>;
  34185. /**
  34186. * Gets a mesh using a given name
  34187. * @param name defines the name to search for
  34188. * @return the found mesh or null if not found at all.
  34189. */
  34190. getMeshByName(name: string): Nullable<AbstractMesh>;
  34191. /**
  34192. * Gets a transform node using a given name
  34193. * @param name defines the name to search for
  34194. * @return the found transform node or null if not found at all.
  34195. */
  34196. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34197. /**
  34198. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34199. * @param id defines the id to search for
  34200. * @return the found skeleton or null if not found at all.
  34201. */
  34202. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34203. /**
  34204. * Gets a skeleton using a given auto generated unique id
  34205. * @param uniqueId defines the unique id to search for
  34206. * @return the found skeleton or null if not found at all.
  34207. */
  34208. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34209. /**
  34210. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34211. * @param id defines the id to search for
  34212. * @return the found skeleton or null if not found at all.
  34213. */
  34214. getSkeletonById(id: string): Nullable<Skeleton>;
  34215. /**
  34216. * Gets a skeleton using a given name
  34217. * @param name defines the name to search for
  34218. * @return the found skeleton or null if not found at all.
  34219. */
  34220. getSkeletonByName(name: string): Nullable<Skeleton>;
  34221. /**
  34222. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34223. * @param id defines the id to search for
  34224. * @return the found morph target manager or null if not found at all.
  34225. */
  34226. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34227. /**
  34228. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34229. * @param id defines the id to search for
  34230. * @return the found morph target or null if not found at all.
  34231. */
  34232. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34233. /**
  34234. * Gets a boolean indicating if the given mesh is active
  34235. * @param mesh defines the mesh to look for
  34236. * @returns true if the mesh is in the active list
  34237. */
  34238. isActiveMesh(mesh: AbstractMesh): boolean;
  34239. /**
  34240. * Return a unique id as a string which can serve as an identifier for the scene
  34241. */
  34242. readonly uid: string;
  34243. /**
  34244. * Add an externaly attached data from its key.
  34245. * This method call will fail and return false, if such key already exists.
  34246. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34247. * @param key the unique key that identifies the data
  34248. * @param data the data object to associate to the key for this Engine instance
  34249. * @return true if no such key were already present and the data was added successfully, false otherwise
  34250. */
  34251. addExternalData<T>(key: string, data: T): boolean;
  34252. /**
  34253. * Get an externaly attached data from its key
  34254. * @param key the unique key that identifies the data
  34255. * @return the associated data, if present (can be null), or undefined if not present
  34256. */
  34257. getExternalData<T>(key: string): Nullable<T>;
  34258. /**
  34259. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34260. * @param key the unique key that identifies the data
  34261. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34262. * @return the associated data, can be null if the factory returned null.
  34263. */
  34264. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34265. /**
  34266. * Remove an externaly attached data from the Engine instance
  34267. * @param key the unique key that identifies the data
  34268. * @return true if the data was successfully removed, false if it doesn't exist
  34269. */
  34270. removeExternalData(key: string): boolean;
  34271. private _evaluateSubMesh;
  34272. /**
  34273. * Clear the processed materials smart array preventing retention point in material dispose.
  34274. */
  34275. freeProcessedMaterials(): void;
  34276. private _preventFreeActiveMeshesAndRenderingGroups;
  34277. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34278. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34279. * when disposing several meshes in a row or a hierarchy of meshes.
  34280. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34281. */
  34282. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34283. /**
  34284. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34285. */
  34286. freeActiveMeshes(): void;
  34287. /**
  34288. * Clear the info related to rendering groups preventing retention points during dispose.
  34289. */
  34290. freeRenderingGroups(): void;
  34291. /** @hidden */
  34292. _isInIntermediateRendering(): boolean;
  34293. /**
  34294. * Lambda returning the list of potentially active meshes.
  34295. */
  34296. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34297. /**
  34298. * Lambda returning the list of potentially active sub meshes.
  34299. */
  34300. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34301. /**
  34302. * Lambda returning the list of potentially intersecting sub meshes.
  34303. */
  34304. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34305. /**
  34306. * Lambda returning the list of potentially colliding sub meshes.
  34307. */
  34308. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34309. private _activeMeshesFrozen;
  34310. /**
  34311. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34312. * @returns the current scene
  34313. */
  34314. freezeActiveMeshes(): Scene;
  34315. /**
  34316. * Use this function to restart evaluating active meshes on every frame
  34317. * @returns the current scene
  34318. */
  34319. unfreezeActiveMeshes(): Scene;
  34320. private _evaluateActiveMeshes;
  34321. private _activeMesh;
  34322. /**
  34323. * Update the transform matrix to update from the current active camera
  34324. * @param force defines a boolean used to force the update even if cache is up to date
  34325. */
  34326. updateTransformMatrix(force?: boolean): void;
  34327. private _bindFrameBuffer;
  34328. /** @hidden */
  34329. _allowPostProcessClearColor: boolean;
  34330. /** @hidden */
  34331. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34332. private _processSubCameras;
  34333. private _checkIntersections;
  34334. /** @hidden */
  34335. _advancePhysicsEngineStep(step: number): void;
  34336. /**
  34337. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34338. */
  34339. getDeterministicFrameTime: () => number;
  34340. /** @hidden */
  34341. _animate(): void;
  34342. /** Execute all animations (for a frame) */
  34343. animate(): void;
  34344. /**
  34345. * Render the scene
  34346. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34347. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34348. */
  34349. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34350. /**
  34351. * Freeze all materials
  34352. * A frozen material will not be updatable but should be faster to render
  34353. */
  34354. freezeMaterials(): void;
  34355. /**
  34356. * Unfreeze all materials
  34357. * A frozen material will not be updatable but should be faster to render
  34358. */
  34359. unfreezeMaterials(): void;
  34360. /**
  34361. * Releases all held ressources
  34362. */
  34363. dispose(): void;
  34364. /**
  34365. * Gets if the scene is already disposed
  34366. */
  34367. readonly isDisposed: boolean;
  34368. /**
  34369. * Call this function to reduce memory footprint of the scene.
  34370. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34371. */
  34372. clearCachedVertexData(): void;
  34373. /**
  34374. * This function will remove the local cached buffer data from texture.
  34375. * It will save memory but will prevent the texture from being rebuilt
  34376. */
  34377. cleanCachedTextureBuffer(): void;
  34378. /**
  34379. * Get the world extend vectors with an optional filter
  34380. *
  34381. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34382. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34383. */
  34384. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34385. min: Vector3;
  34386. max: Vector3;
  34387. };
  34388. /**
  34389. * Creates a ray that can be used to pick in the scene
  34390. * @param x defines the x coordinate of the origin (on-screen)
  34391. * @param y defines the y coordinate of the origin (on-screen)
  34392. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34393. * @param camera defines the camera to use for the picking
  34394. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34395. * @returns a Ray
  34396. */
  34397. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34398. /**
  34399. * Creates a ray that can be used to pick in the scene
  34400. * @param x defines the x coordinate of the origin (on-screen)
  34401. * @param y defines the y coordinate of the origin (on-screen)
  34402. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34403. * @param result defines the ray where to store the picking ray
  34404. * @param camera defines the camera to use for the picking
  34405. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34406. * @returns the current scene
  34407. */
  34408. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34409. /**
  34410. * Creates a ray that can be used to pick in the scene
  34411. * @param x defines the x coordinate of the origin (on-screen)
  34412. * @param y defines the y coordinate of the origin (on-screen)
  34413. * @param camera defines the camera to use for the picking
  34414. * @returns a Ray
  34415. */
  34416. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34417. /**
  34418. * Creates a ray that can be used to pick in the scene
  34419. * @param x defines the x coordinate of the origin (on-screen)
  34420. * @param y defines the y coordinate of the origin (on-screen)
  34421. * @param result defines the ray where to store the picking ray
  34422. * @param camera defines the camera to use for the picking
  34423. * @returns the current scene
  34424. */
  34425. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34426. /** Launch a ray to try to pick a mesh in the scene
  34427. * @param x position on screen
  34428. * @param y position on screen
  34429. * @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
  34430. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34431. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34433. * @returns a PickingInfo
  34434. */
  34435. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34436. /** Use the given ray to pick a mesh in the scene
  34437. * @param ray The ray to use to pick meshes
  34438. * @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
  34439. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34440. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34441. * @returns a PickingInfo
  34442. */
  34443. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34444. /**
  34445. * Launch a ray to try to pick a mesh in the scene
  34446. * @param x X position on screen
  34447. * @param y Y position on screen
  34448. * @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
  34449. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34451. * @returns an array of PickingInfo
  34452. */
  34453. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34454. /**
  34455. * Launch a ray to try to pick a mesh in the scene
  34456. * @param ray Ray to use
  34457. * @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
  34458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34459. * @returns an array of PickingInfo
  34460. */
  34461. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34462. /**
  34463. * Force the value of meshUnderPointer
  34464. * @param mesh defines the mesh to use
  34465. */
  34466. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34467. /**
  34468. * Gets the mesh under the pointer
  34469. * @returns a Mesh or null if no mesh is under the pointer
  34470. */
  34471. getPointerOverMesh(): Nullable<AbstractMesh>;
  34472. /** @hidden */
  34473. _rebuildGeometries(): void;
  34474. /** @hidden */
  34475. _rebuildTextures(): void;
  34476. private _getByTags;
  34477. /**
  34478. * Get a list of meshes by tags
  34479. * @param tagsQuery defines the tags query to use
  34480. * @param forEach defines a predicate used to filter results
  34481. * @returns an array of Mesh
  34482. */
  34483. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34484. /**
  34485. * Get a list of cameras by tags
  34486. * @param tagsQuery defines the tags query to use
  34487. * @param forEach defines a predicate used to filter results
  34488. * @returns an array of Camera
  34489. */
  34490. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34491. /**
  34492. * Get a list of lights by tags
  34493. * @param tagsQuery defines the tags query to use
  34494. * @param forEach defines a predicate used to filter results
  34495. * @returns an array of Light
  34496. */
  34497. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34498. /**
  34499. * Get a list of materials by tags
  34500. * @param tagsQuery defines the tags query to use
  34501. * @param forEach defines a predicate used to filter results
  34502. * @returns an array of Material
  34503. */
  34504. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34505. /**
  34506. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34507. * This allowed control for front to back rendering or reversly depending of the special needs.
  34508. *
  34509. * @param renderingGroupId The rendering group id corresponding to its index
  34510. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34511. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34512. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34513. */
  34514. 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;
  34515. /**
  34516. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34517. *
  34518. * @param renderingGroupId The rendering group id corresponding to its index
  34519. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34520. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34521. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34522. */
  34523. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34524. /**
  34525. * Gets the current auto clear configuration for one rendering group of the rendering
  34526. * manager.
  34527. * @param index the rendering group index to get the information for
  34528. * @returns The auto clear setup for the requested rendering group
  34529. */
  34530. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34531. private _blockMaterialDirtyMechanism;
  34532. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34533. blockMaterialDirtyMechanism: boolean;
  34534. /**
  34535. * Will flag all materials as dirty to trigger new shader compilation
  34536. * @param flag defines the flag used to specify which material part must be marked as dirty
  34537. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34538. */
  34539. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34540. /** @hidden */
  34541. _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;
  34542. /** @hidden */
  34543. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34544. }
  34545. }
  34546. declare module "babylonjs/assetContainer" {
  34547. import { AbstractScene } from "babylonjs/abstractScene";
  34548. import { Scene } from "babylonjs/scene";
  34549. import { Mesh } from "babylonjs/Meshes/mesh";
  34550. /**
  34551. * Set of assets to keep when moving a scene into an asset container.
  34552. */
  34553. export class KeepAssets extends AbstractScene {
  34554. }
  34555. /**
  34556. * Container with a set of assets that can be added or removed from a scene.
  34557. */
  34558. export class AssetContainer extends AbstractScene {
  34559. /**
  34560. * The scene the AssetContainer belongs to.
  34561. */
  34562. scene: Scene;
  34563. /**
  34564. * Instantiates an AssetContainer.
  34565. * @param scene The scene the AssetContainer belongs to.
  34566. */
  34567. constructor(scene: Scene);
  34568. /**
  34569. * Adds all the assets from the container to the scene.
  34570. */
  34571. addAllToScene(): void;
  34572. /**
  34573. * Removes all the assets in the container from the scene
  34574. */
  34575. removeAllFromScene(): void;
  34576. /**
  34577. * Disposes all the assets in the container
  34578. */
  34579. dispose(): void;
  34580. private _moveAssets;
  34581. /**
  34582. * Removes all the assets contained in the scene and adds them to the container.
  34583. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34584. */
  34585. moveAllFromScene(keepAssets?: KeepAssets): void;
  34586. /**
  34587. * 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.
  34588. * @returns the root mesh
  34589. */
  34590. createRootMesh(): Mesh;
  34591. }
  34592. }
  34593. declare module "babylonjs/abstractScene" {
  34594. import { Scene } from "babylonjs/scene";
  34595. import { Nullable } from "babylonjs/types";
  34596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34597. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34598. import { Geometry } from "babylonjs/Meshes/geometry";
  34599. import { Skeleton } from "babylonjs/Bones/skeleton";
  34600. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34601. import { AssetContainer } from "babylonjs/assetContainer";
  34602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34603. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34605. import { Material } from "babylonjs/Materials/material";
  34606. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34607. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34608. import { Camera } from "babylonjs/Cameras/camera";
  34609. import { Light } from "babylonjs/Lights/light";
  34610. import { Node } from "babylonjs/node";
  34611. import { Animation } from "babylonjs/Animations/animation";
  34612. /**
  34613. * Defines how the parser contract is defined.
  34614. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34615. */
  34616. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34617. /**
  34618. * Defines how the individual parser contract is defined.
  34619. * These parser can parse an individual asset
  34620. */
  34621. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34622. /**
  34623. * Base class of the scene acting as a container for the different elements composing a scene.
  34624. * This class is dynamically extended by the different components of the scene increasing
  34625. * flexibility and reducing coupling
  34626. */
  34627. export abstract class AbstractScene {
  34628. /**
  34629. * Stores the list of available parsers in the application.
  34630. */
  34631. private static _BabylonFileParsers;
  34632. /**
  34633. * Stores the list of available individual parsers in the application.
  34634. */
  34635. private static _IndividualBabylonFileParsers;
  34636. /**
  34637. * Adds a parser in the list of available ones
  34638. * @param name Defines the name of the parser
  34639. * @param parser Defines the parser to add
  34640. */
  34641. static AddParser(name: string, parser: BabylonFileParser): void;
  34642. /**
  34643. * Gets a general parser from the list of avaialble ones
  34644. * @param name Defines the name of the parser
  34645. * @returns the requested parser or null
  34646. */
  34647. static GetParser(name: string): Nullable<BabylonFileParser>;
  34648. /**
  34649. * Adds n individual parser in the list of available ones
  34650. * @param name Defines the name of the parser
  34651. * @param parser Defines the parser to add
  34652. */
  34653. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34654. /**
  34655. * Gets an individual parser from the list of avaialble ones
  34656. * @param name Defines the name of the parser
  34657. * @returns the requested parser or null
  34658. */
  34659. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34660. /**
  34661. * Parser json data and populate both a scene and its associated container object
  34662. * @param jsonData Defines the data to parse
  34663. * @param scene Defines the scene to parse the data for
  34664. * @param container Defines the container attached to the parsing sequence
  34665. * @param rootUrl Defines the root url of the data
  34666. */
  34667. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34668. /**
  34669. * Gets the list of root nodes (ie. nodes with no parent)
  34670. */
  34671. rootNodes: Node[];
  34672. /** All of the cameras added to this scene
  34673. * @see http://doc.babylonjs.com/babylon101/cameras
  34674. */
  34675. cameras: Camera[];
  34676. /**
  34677. * All of the lights added to this scene
  34678. * @see http://doc.babylonjs.com/babylon101/lights
  34679. */
  34680. lights: Light[];
  34681. /**
  34682. * All of the (abstract) meshes added to this scene
  34683. */
  34684. meshes: AbstractMesh[];
  34685. /**
  34686. * The list of skeletons added to the scene
  34687. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34688. */
  34689. skeletons: Skeleton[];
  34690. /**
  34691. * All of the particle systems added to this scene
  34692. * @see http://doc.babylonjs.com/babylon101/particles
  34693. */
  34694. particleSystems: IParticleSystem[];
  34695. /**
  34696. * Gets a list of Animations associated with the scene
  34697. */
  34698. animations: Animation[];
  34699. /**
  34700. * All of the animation groups added to this scene
  34701. * @see http://doc.babylonjs.com/how_to/group
  34702. */
  34703. animationGroups: AnimationGroup[];
  34704. /**
  34705. * All of the multi-materials added to this scene
  34706. * @see http://doc.babylonjs.com/how_to/multi_materials
  34707. */
  34708. multiMaterials: MultiMaterial[];
  34709. /**
  34710. * All of the materials added to this scene
  34711. * In the context of a Scene, it is not supposed to be modified manually.
  34712. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34713. * Note also that the order of the Material wihin the array is not significant and might change.
  34714. * @see http://doc.babylonjs.com/babylon101/materials
  34715. */
  34716. materials: Material[];
  34717. /**
  34718. * The list of morph target managers added to the scene
  34719. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34720. */
  34721. morphTargetManagers: MorphTargetManager[];
  34722. /**
  34723. * The list of geometries used in the scene.
  34724. */
  34725. geometries: Geometry[];
  34726. /**
  34727. * All of the tranform nodes added to this scene
  34728. * In the context of a Scene, it is not supposed to be modified manually.
  34729. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34730. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34731. * @see http://doc.babylonjs.com/how_to/transformnode
  34732. */
  34733. transformNodes: TransformNode[];
  34734. /**
  34735. * ActionManagers available on the scene.
  34736. */
  34737. actionManagers: AbstractActionManager[];
  34738. /**
  34739. * Textures to keep.
  34740. */
  34741. textures: BaseTexture[];
  34742. /**
  34743. * Environment texture for the scene
  34744. */
  34745. environmentTexture: Nullable<BaseTexture>;
  34746. }
  34747. }
  34748. declare module "babylonjs/Audio/sound" {
  34749. import { Observable } from "babylonjs/Misc/observable";
  34750. import { Vector3 } from "babylonjs/Maths/math";
  34751. import { Nullable } from "babylonjs/types";
  34752. import { Scene } from "babylonjs/scene";
  34753. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34754. /**
  34755. * Defines a sound that can be played in the application.
  34756. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34758. */
  34759. export class Sound {
  34760. /**
  34761. * The name of the sound in the scene.
  34762. */
  34763. name: string;
  34764. /**
  34765. * Does the sound autoplay once loaded.
  34766. */
  34767. autoplay: boolean;
  34768. /**
  34769. * Does the sound loop after it finishes playing once.
  34770. */
  34771. loop: boolean;
  34772. /**
  34773. * Does the sound use a custom attenuation curve to simulate the falloff
  34774. * happening when the source gets further away from the camera.
  34775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34776. */
  34777. useCustomAttenuation: boolean;
  34778. /**
  34779. * The sound track id this sound belongs to.
  34780. */
  34781. soundTrackId: number;
  34782. /**
  34783. * Is this sound currently played.
  34784. */
  34785. isPlaying: boolean;
  34786. /**
  34787. * Is this sound currently paused.
  34788. */
  34789. isPaused: boolean;
  34790. /**
  34791. * Does this sound enables spatial sound.
  34792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34793. */
  34794. spatialSound: boolean;
  34795. /**
  34796. * Define the reference distance the sound should be heard perfectly.
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34798. */
  34799. refDistance: number;
  34800. /**
  34801. * Define the roll off factor of spatial sounds.
  34802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34803. */
  34804. rolloffFactor: number;
  34805. /**
  34806. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34808. */
  34809. maxDistance: number;
  34810. /**
  34811. * Define the distance attenuation model the sound will follow.
  34812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34813. */
  34814. distanceModel: string;
  34815. /**
  34816. * @hidden
  34817. * Back Compat
  34818. **/
  34819. onended: () => any;
  34820. /**
  34821. * Observable event when the current playing sound finishes.
  34822. */
  34823. onEndedObservable: Observable<Sound>;
  34824. private _panningModel;
  34825. private _playbackRate;
  34826. private _streaming;
  34827. private _startTime;
  34828. private _startOffset;
  34829. private _position;
  34830. /** @hidden */
  34831. _positionInEmitterSpace: boolean;
  34832. private _localDirection;
  34833. private _volume;
  34834. private _isReadyToPlay;
  34835. private _isDirectional;
  34836. private _readyToPlayCallback;
  34837. private _audioBuffer;
  34838. private _soundSource;
  34839. private _streamingSource;
  34840. private _soundPanner;
  34841. private _soundGain;
  34842. private _inputAudioNode;
  34843. private _outputAudioNode;
  34844. private _coneInnerAngle;
  34845. private _coneOuterAngle;
  34846. private _coneOuterGain;
  34847. private _scene;
  34848. private _connectedTransformNode;
  34849. private _customAttenuationFunction;
  34850. private _registerFunc;
  34851. private _isOutputConnected;
  34852. private _htmlAudioElement;
  34853. private _urlType;
  34854. /** @hidden */
  34855. static _SceneComponentInitialization: (scene: Scene) => void;
  34856. /**
  34857. * Create a sound and attach it to a scene
  34858. * @param name Name of your sound
  34859. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34860. * @param scene defines the scene the sound belongs to
  34861. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34862. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34863. */
  34864. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34865. /**
  34866. * Release the sound and its associated resources
  34867. */
  34868. dispose(): void;
  34869. /**
  34870. * Gets if the sounds is ready to be played or not.
  34871. * @returns true if ready, otherwise false
  34872. */
  34873. isReady(): boolean;
  34874. private _soundLoaded;
  34875. /**
  34876. * Sets the data of the sound from an audiobuffer
  34877. * @param audioBuffer The audioBuffer containing the data
  34878. */
  34879. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34880. /**
  34881. * Updates the current sounds options such as maxdistance, loop...
  34882. * @param options A JSON object containing values named as the object properties
  34883. */
  34884. updateOptions(options: any): void;
  34885. private _createSpatialParameters;
  34886. private _updateSpatialParameters;
  34887. /**
  34888. * Switch the panning model to HRTF:
  34889. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34891. */
  34892. switchPanningModelToHRTF(): void;
  34893. /**
  34894. * Switch the panning model to Equal Power:
  34895. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34897. */
  34898. switchPanningModelToEqualPower(): void;
  34899. private _switchPanningModel;
  34900. /**
  34901. * Connect this sound to a sound track audio node like gain...
  34902. * @param soundTrackAudioNode the sound track audio node to connect to
  34903. */
  34904. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34905. /**
  34906. * Transform this sound into a directional source
  34907. * @param coneInnerAngle Size of the inner cone in degree
  34908. * @param coneOuterAngle Size of the outer cone in degree
  34909. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34910. */
  34911. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34912. /**
  34913. * Gets or sets the inner angle for the directional cone.
  34914. */
  34915. /**
  34916. * Gets or sets the inner angle for the directional cone.
  34917. */
  34918. directionalConeInnerAngle: number;
  34919. /**
  34920. * Gets or sets the outer angle for the directional cone.
  34921. */
  34922. /**
  34923. * Gets or sets the outer angle for the directional cone.
  34924. */
  34925. directionalConeOuterAngle: number;
  34926. /**
  34927. * Sets the position of the emitter if spatial sound is enabled
  34928. * @param newPosition Defines the new posisiton
  34929. */
  34930. setPosition(newPosition: Vector3): void;
  34931. /**
  34932. * Sets the local direction of the emitter if spatial sound is enabled
  34933. * @param newLocalDirection Defines the new local direction
  34934. */
  34935. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34936. private _updateDirection;
  34937. /** @hidden */
  34938. updateDistanceFromListener(): void;
  34939. /**
  34940. * Sets a new custom attenuation function for the sound.
  34941. * @param callback Defines the function used for the attenuation
  34942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34943. */
  34944. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34945. /**
  34946. * Play the sound
  34947. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34948. * @param offset (optional) Start the sound setting it at a specific time
  34949. */
  34950. play(time?: number, offset?: number): void;
  34951. private _onended;
  34952. /**
  34953. * Stop the sound
  34954. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34955. */
  34956. stop(time?: number): void;
  34957. /**
  34958. * Put the sound in pause
  34959. */
  34960. pause(): void;
  34961. /**
  34962. * Sets a dedicated volume for this sounds
  34963. * @param newVolume Define the new volume of the sound
  34964. * @param time Define in how long the sound should be at this value
  34965. */
  34966. setVolume(newVolume: number, time?: number): void;
  34967. /**
  34968. * Set the sound play back rate
  34969. * @param newPlaybackRate Define the playback rate the sound should be played at
  34970. */
  34971. setPlaybackRate(newPlaybackRate: number): void;
  34972. /**
  34973. * Gets the volume of the sound.
  34974. * @returns the volume of the sound
  34975. */
  34976. getVolume(): number;
  34977. /**
  34978. * Attach the sound to a dedicated mesh
  34979. * @param transformNode The transform node to connect the sound with
  34980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34981. */
  34982. attachToMesh(transformNode: TransformNode): void;
  34983. /**
  34984. * Detach the sound from the previously attached mesh
  34985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34986. */
  34987. detachFromMesh(): void;
  34988. private _onRegisterAfterWorldMatrixUpdate;
  34989. /**
  34990. * Clone the current sound in the scene.
  34991. * @returns the new sound clone
  34992. */
  34993. clone(): Nullable<Sound>;
  34994. /**
  34995. * Gets the current underlying audio buffer containing the data
  34996. * @returns the audio buffer
  34997. */
  34998. getAudioBuffer(): Nullable<AudioBuffer>;
  34999. /**
  35000. * Serializes the Sound in a JSON representation
  35001. * @returns the JSON representation of the sound
  35002. */
  35003. serialize(): any;
  35004. /**
  35005. * Parse a JSON representation of a sound to innstantiate in a given scene
  35006. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35007. * @param scene Define the scene the new parsed sound should be created in
  35008. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35009. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35010. * @returns the newly parsed sound
  35011. */
  35012. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35013. }
  35014. }
  35015. declare module "babylonjs/Actions/directAudioActions" {
  35016. import { Action } from "babylonjs/Actions/action";
  35017. import { Condition } from "babylonjs/Actions/condition";
  35018. import { Sound } from "babylonjs/Audio/sound";
  35019. /**
  35020. * This defines an action helpful to play a defined sound on a triggered action.
  35021. */
  35022. export class PlaySoundAction extends Action {
  35023. private _sound;
  35024. /**
  35025. * Instantiate the action
  35026. * @param triggerOptions defines the trigger options
  35027. * @param sound defines the sound to play
  35028. * @param condition defines the trigger related conditions
  35029. */
  35030. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35031. /** @hidden */
  35032. _prepare(): void;
  35033. /**
  35034. * Execute the action and play the sound.
  35035. */
  35036. execute(): void;
  35037. /**
  35038. * Serializes the actions and its related information.
  35039. * @param parent defines the object to serialize in
  35040. * @returns the serialized object
  35041. */
  35042. serialize(parent: any): any;
  35043. }
  35044. /**
  35045. * This defines an action helpful to stop a defined sound on a triggered action.
  35046. */
  35047. export class StopSoundAction extends Action {
  35048. private _sound;
  35049. /**
  35050. * Instantiate the action
  35051. * @param triggerOptions defines the trigger options
  35052. * @param sound defines the sound to stop
  35053. * @param condition defines the trigger related conditions
  35054. */
  35055. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35056. /** @hidden */
  35057. _prepare(): void;
  35058. /**
  35059. * Execute the action and stop the sound.
  35060. */
  35061. execute(): void;
  35062. /**
  35063. * Serializes the actions and its related information.
  35064. * @param parent defines the object to serialize in
  35065. * @returns the serialized object
  35066. */
  35067. serialize(parent: any): any;
  35068. }
  35069. }
  35070. declare module "babylonjs/Actions/interpolateValueAction" {
  35071. import { Action } from "babylonjs/Actions/action";
  35072. import { Condition } from "babylonjs/Actions/condition";
  35073. import { Observable } from "babylonjs/Misc/observable";
  35074. /**
  35075. * This defines an action responsible to change the value of a property
  35076. * by interpolating between its current value and the newly set one once triggered.
  35077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35078. */
  35079. export class InterpolateValueAction extends Action {
  35080. /**
  35081. * Defines the path of the property where the value should be interpolated
  35082. */
  35083. propertyPath: string;
  35084. /**
  35085. * Defines the target value at the end of the interpolation.
  35086. */
  35087. value: any;
  35088. /**
  35089. * Defines the time it will take for the property to interpolate to the value.
  35090. */
  35091. duration: number;
  35092. /**
  35093. * Defines if the other scene animations should be stopped when the action has been triggered
  35094. */
  35095. stopOtherAnimations?: boolean;
  35096. /**
  35097. * Defines a callback raised once the interpolation animation has been done.
  35098. */
  35099. onInterpolationDone?: () => void;
  35100. /**
  35101. * Observable triggered once the interpolation animation has been done.
  35102. */
  35103. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35104. private _target;
  35105. private _effectiveTarget;
  35106. private _property;
  35107. /**
  35108. * Instantiate the action
  35109. * @param triggerOptions defines the trigger options
  35110. * @param target defines the object containing the value to interpolate
  35111. * @param propertyPath defines the path to the property in the target object
  35112. * @param value defines the target value at the end of the interpolation
  35113. * @param duration deines the time it will take for the property to interpolate to the value.
  35114. * @param condition defines the trigger related conditions
  35115. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35116. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35117. */
  35118. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35119. /** @hidden */
  35120. _prepare(): void;
  35121. /**
  35122. * Execute the action starts the value interpolation.
  35123. */
  35124. execute(): void;
  35125. /**
  35126. * Serializes the actions and its related information.
  35127. * @param parent defines the object to serialize in
  35128. * @returns the serialized object
  35129. */
  35130. serialize(parent: any): any;
  35131. }
  35132. }
  35133. declare module "babylonjs/Actions/index" {
  35134. export * from "babylonjs/Actions/action";
  35135. export * from "babylonjs/Actions/actionEvent";
  35136. export * from "babylonjs/Actions/actionManager";
  35137. export * from "babylonjs/Actions/condition";
  35138. export * from "babylonjs/Actions/directActions";
  35139. export * from "babylonjs/Actions/directAudioActions";
  35140. export * from "babylonjs/Actions/interpolateValueAction";
  35141. }
  35142. declare module "babylonjs/Animations/index" {
  35143. export * from "babylonjs/Animations/animatable";
  35144. export * from "babylonjs/Animations/animation";
  35145. export * from "babylonjs/Animations/animationGroup";
  35146. export * from "babylonjs/Animations/animationPropertiesOverride";
  35147. export * from "babylonjs/Animations/easing";
  35148. export * from "babylonjs/Animations/runtimeAnimation";
  35149. export * from "babylonjs/Animations/animationEvent";
  35150. export * from "babylonjs/Animations/animationGroup";
  35151. export * from "babylonjs/Animations/animationKey";
  35152. export * from "babylonjs/Animations/animationRange";
  35153. }
  35154. declare module "babylonjs/Audio/soundTrack" {
  35155. import { Sound } from "babylonjs/Audio/sound";
  35156. import { Analyser } from "babylonjs/Audio/analyser";
  35157. import { Scene } from "babylonjs/scene";
  35158. /**
  35159. * Options allowed during the creation of a sound track.
  35160. */
  35161. export interface ISoundTrackOptions {
  35162. /**
  35163. * The volume the sound track should take during creation
  35164. */
  35165. volume?: number;
  35166. /**
  35167. * Define if the sound track is the main sound track of the scene
  35168. */
  35169. mainTrack?: boolean;
  35170. }
  35171. /**
  35172. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35173. * It will be also used in a future release to apply effects on a specific track.
  35174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35175. */
  35176. export class SoundTrack {
  35177. /**
  35178. * The unique identifier of the sound track in the scene.
  35179. */
  35180. id: number;
  35181. /**
  35182. * The list of sounds included in the sound track.
  35183. */
  35184. soundCollection: Array<Sound>;
  35185. private _outputAudioNode;
  35186. private _scene;
  35187. private _isMainTrack;
  35188. private _connectedAnalyser;
  35189. private _options;
  35190. private _isInitialized;
  35191. /**
  35192. * Creates a new sound track.
  35193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35194. * @param scene Define the scene the sound track belongs to
  35195. * @param options
  35196. */
  35197. constructor(scene: Scene, options?: ISoundTrackOptions);
  35198. private _initializeSoundTrackAudioGraph;
  35199. /**
  35200. * Release the sound track and its associated resources
  35201. */
  35202. dispose(): void;
  35203. /**
  35204. * Adds a sound to this sound track
  35205. * @param sound define the cound to add
  35206. * @ignoreNaming
  35207. */
  35208. AddSound(sound: Sound): void;
  35209. /**
  35210. * Removes a sound to this sound track
  35211. * @param sound define the cound to remove
  35212. * @ignoreNaming
  35213. */
  35214. RemoveSound(sound: Sound): void;
  35215. /**
  35216. * Set a global volume for the full sound track.
  35217. * @param newVolume Define the new volume of the sound track
  35218. */
  35219. setVolume(newVolume: number): void;
  35220. /**
  35221. * Switch the panning model to HRTF:
  35222. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. switchPanningModelToHRTF(): void;
  35226. /**
  35227. * Switch the panning model to Equal Power:
  35228. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35230. */
  35231. switchPanningModelToEqualPower(): void;
  35232. /**
  35233. * Connect the sound track to an audio analyser allowing some amazing
  35234. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35236. * @param analyser The analyser to connect to the engine
  35237. */
  35238. connectToAnalyser(analyser: Analyser): void;
  35239. }
  35240. }
  35241. declare module "babylonjs/Audio/audioSceneComponent" {
  35242. import { Sound } from "babylonjs/Audio/sound";
  35243. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35244. import { Nullable } from "babylonjs/types";
  35245. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35246. import { Scene } from "babylonjs/scene";
  35247. import { AbstractScene } from "babylonjs/abstractScene";
  35248. module "babylonjs/abstractScene" {
  35249. interface AbstractScene {
  35250. /**
  35251. * The list of sounds used in the scene.
  35252. */
  35253. sounds: Nullable<Array<Sound>>;
  35254. }
  35255. }
  35256. module "babylonjs/scene" {
  35257. interface Scene {
  35258. /**
  35259. * @hidden
  35260. * Backing field
  35261. */
  35262. _mainSoundTrack: SoundTrack;
  35263. /**
  35264. * The main sound track played by the scene.
  35265. * It cotains your primary collection of sounds.
  35266. */
  35267. mainSoundTrack: SoundTrack;
  35268. /**
  35269. * The list of sound tracks added to the scene
  35270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35271. */
  35272. soundTracks: Nullable<Array<SoundTrack>>;
  35273. /**
  35274. * Gets a sound using a given name
  35275. * @param name defines the name to search for
  35276. * @return the found sound or null if not found at all.
  35277. */
  35278. getSoundByName(name: string): Nullable<Sound>;
  35279. /**
  35280. * Gets or sets if audio support is enabled
  35281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35282. */
  35283. audioEnabled: boolean;
  35284. /**
  35285. * Gets or sets if audio will be output to headphones
  35286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35287. */
  35288. headphone: boolean;
  35289. }
  35290. }
  35291. /**
  35292. * Defines the sound scene component responsible to manage any sounds
  35293. * in a given scene.
  35294. */
  35295. export class AudioSceneComponent implements ISceneSerializableComponent {
  35296. /**
  35297. * The component name helpfull to identify the component in the list of scene components.
  35298. */
  35299. readonly name: string;
  35300. /**
  35301. * The scene the component belongs to.
  35302. */
  35303. scene: Scene;
  35304. private _audioEnabled;
  35305. /**
  35306. * Gets whether audio is enabled or not.
  35307. * Please use related enable/disable method to switch state.
  35308. */
  35309. readonly audioEnabled: boolean;
  35310. private _headphone;
  35311. /**
  35312. * Gets whether audio is outputing to headphone or not.
  35313. * Please use the according Switch methods to change output.
  35314. */
  35315. readonly headphone: boolean;
  35316. /**
  35317. * Creates a new instance of the component for the given scene
  35318. * @param scene Defines the scene to register the component in
  35319. */
  35320. constructor(scene: Scene);
  35321. /**
  35322. * Registers the component in a given scene
  35323. */
  35324. register(): void;
  35325. /**
  35326. * Rebuilds the elements related to this component in case of
  35327. * context lost for instance.
  35328. */
  35329. rebuild(): void;
  35330. /**
  35331. * Serializes the component data to the specified json object
  35332. * @param serializationObject The object to serialize to
  35333. */
  35334. serialize(serializationObject: any): void;
  35335. /**
  35336. * Adds all the element from the container to the scene
  35337. * @param container the container holding the elements
  35338. */
  35339. addFromContainer(container: AbstractScene): void;
  35340. /**
  35341. * Removes all the elements in the container from the scene
  35342. * @param container contains the elements to remove
  35343. * @param dispose if the removed element should be disposed (default: false)
  35344. */
  35345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35346. /**
  35347. * Disposes the component and the associated ressources.
  35348. */
  35349. dispose(): void;
  35350. /**
  35351. * Disables audio in the associated scene.
  35352. */
  35353. disableAudio(): void;
  35354. /**
  35355. * Enables audio in the associated scene.
  35356. */
  35357. enableAudio(): void;
  35358. /**
  35359. * Switch audio to headphone output.
  35360. */
  35361. switchAudioModeForHeadphones(): void;
  35362. /**
  35363. * Switch audio to normal speakers.
  35364. */
  35365. switchAudioModeForNormalSpeakers(): void;
  35366. private _afterRender;
  35367. }
  35368. }
  35369. declare module "babylonjs/Audio/weightedsound" {
  35370. import { Sound } from "babylonjs/Audio/sound";
  35371. /**
  35372. * Wraps one or more Sound objects and selects one with random weight for playback.
  35373. */
  35374. export class WeightedSound {
  35375. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35376. loop: boolean;
  35377. private _coneInnerAngle;
  35378. private _coneOuterAngle;
  35379. private _volume;
  35380. /** A Sound is currently playing. */
  35381. isPlaying: boolean;
  35382. /** A Sound is currently paused. */
  35383. isPaused: boolean;
  35384. private _sounds;
  35385. private _weights;
  35386. private _currentIndex?;
  35387. /**
  35388. * Creates a new WeightedSound from the list of sounds given.
  35389. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35390. * @param sounds Array of Sounds that will be selected from.
  35391. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35392. */
  35393. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35394. /**
  35395. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35396. */
  35397. /**
  35398. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35399. */
  35400. directionalConeInnerAngle: number;
  35401. /**
  35402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35404. */
  35405. /**
  35406. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35407. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35408. */
  35409. directionalConeOuterAngle: number;
  35410. /**
  35411. * Playback volume.
  35412. */
  35413. /**
  35414. * Playback volume.
  35415. */
  35416. volume: number;
  35417. private _onended;
  35418. /**
  35419. * Suspend playback
  35420. */
  35421. pause(): void;
  35422. /**
  35423. * Stop playback
  35424. */
  35425. stop(): void;
  35426. /**
  35427. * Start playback.
  35428. * @param startOffset Position the clip head at a specific time in seconds.
  35429. */
  35430. play(startOffset?: number): void;
  35431. }
  35432. }
  35433. declare module "babylonjs/Audio/index" {
  35434. export * from "babylonjs/Audio/analyser";
  35435. export * from "babylonjs/Audio/audioEngine";
  35436. export * from "babylonjs/Audio/audioSceneComponent";
  35437. export * from "babylonjs/Audio/sound";
  35438. export * from "babylonjs/Audio/soundTrack";
  35439. export * from "babylonjs/Audio/weightedsound";
  35440. }
  35441. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35442. import { Behavior } from "babylonjs/Behaviors/behavior";
  35443. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35444. import { BackEase } from "babylonjs/Animations/easing";
  35445. /**
  35446. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35448. */
  35449. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35450. /**
  35451. * Gets the name of the behavior.
  35452. */
  35453. readonly name: string;
  35454. /**
  35455. * The easing function used by animations
  35456. */
  35457. static EasingFunction: BackEase;
  35458. /**
  35459. * The easing mode used by animations
  35460. */
  35461. static EasingMode: number;
  35462. /**
  35463. * The duration of the animation, in milliseconds
  35464. */
  35465. transitionDuration: number;
  35466. /**
  35467. * Length of the distance animated by the transition when lower radius is reached
  35468. */
  35469. lowerRadiusTransitionRange: number;
  35470. /**
  35471. * Length of the distance animated by the transition when upper radius is reached
  35472. */
  35473. upperRadiusTransitionRange: number;
  35474. private _autoTransitionRange;
  35475. /**
  35476. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35477. */
  35478. /**
  35479. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35480. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35481. */
  35482. autoTransitionRange: boolean;
  35483. private _attachedCamera;
  35484. private _onAfterCheckInputsObserver;
  35485. private _onMeshTargetChangedObserver;
  35486. /**
  35487. * Initializes the behavior.
  35488. */
  35489. init(): void;
  35490. /**
  35491. * Attaches the behavior to its arc rotate camera.
  35492. * @param camera Defines the camera to attach the behavior to
  35493. */
  35494. attach(camera: ArcRotateCamera): void;
  35495. /**
  35496. * Detaches the behavior from its current arc rotate camera.
  35497. */
  35498. detach(): void;
  35499. private _radiusIsAnimating;
  35500. private _radiusBounceTransition;
  35501. private _animatables;
  35502. private _cachedWheelPrecision;
  35503. /**
  35504. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35505. * @param radiusLimit The limit to check against.
  35506. * @return Bool to indicate if at limit.
  35507. */
  35508. private _isRadiusAtLimit;
  35509. /**
  35510. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35511. * @param radiusDelta The delta by which to animate to. Can be negative.
  35512. */
  35513. private _applyBoundRadiusAnimation;
  35514. /**
  35515. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35516. */
  35517. protected _clearAnimationLocks(): void;
  35518. /**
  35519. * Stops and removes all animations that have been applied to the camera
  35520. */
  35521. stopAllAnimations(): void;
  35522. }
  35523. }
  35524. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35525. import { Behavior } from "babylonjs/Behaviors/behavior";
  35526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35527. import { ExponentialEase } from "babylonjs/Animations/easing";
  35528. import { Nullable } from "babylonjs/types";
  35529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35530. import { Vector3 } from "babylonjs/Maths/math";
  35531. /**
  35532. * 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.
  35533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35534. */
  35535. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35536. /**
  35537. * Gets the name of the behavior.
  35538. */
  35539. readonly name: string;
  35540. private _mode;
  35541. private _radiusScale;
  35542. private _positionScale;
  35543. private _defaultElevation;
  35544. private _elevationReturnTime;
  35545. private _elevationReturnWaitTime;
  35546. private _zoomStopsAnimation;
  35547. private _framingTime;
  35548. /**
  35549. * The easing function used by animations
  35550. */
  35551. static EasingFunction: ExponentialEase;
  35552. /**
  35553. * The easing mode used by animations
  35554. */
  35555. static EasingMode: number;
  35556. /**
  35557. * Sets the current mode used by the behavior
  35558. */
  35559. /**
  35560. * Gets current mode used by the behavior.
  35561. */
  35562. mode: number;
  35563. /**
  35564. * Sets the scale applied to the radius (1 by default)
  35565. */
  35566. /**
  35567. * Gets the scale applied to the radius
  35568. */
  35569. radiusScale: number;
  35570. /**
  35571. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35572. */
  35573. /**
  35574. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35575. */
  35576. positionScale: number;
  35577. /**
  35578. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35579. * behaviour is triggered, in radians.
  35580. */
  35581. /**
  35582. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35583. * behaviour is triggered, in radians.
  35584. */
  35585. defaultElevation: number;
  35586. /**
  35587. * Sets the time (in milliseconds) taken to return to the default beta position.
  35588. * Negative value indicates camera should not return to default.
  35589. */
  35590. /**
  35591. * Gets the time (in milliseconds) taken to return to the default beta position.
  35592. * Negative value indicates camera should not return to default.
  35593. */
  35594. elevationReturnTime: number;
  35595. /**
  35596. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35597. */
  35598. /**
  35599. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35600. */
  35601. elevationReturnWaitTime: number;
  35602. /**
  35603. * Sets the flag that indicates if user zooming should stop animation.
  35604. */
  35605. /**
  35606. * Gets the flag that indicates if user zooming should stop animation.
  35607. */
  35608. zoomStopsAnimation: boolean;
  35609. /**
  35610. * Sets the transition time when framing the mesh, in milliseconds
  35611. */
  35612. /**
  35613. * Gets the transition time when framing the mesh, in milliseconds
  35614. */
  35615. framingTime: number;
  35616. /**
  35617. * Define if the behavior should automatically change the configured
  35618. * camera limits and sensibilities.
  35619. */
  35620. autoCorrectCameraLimitsAndSensibility: boolean;
  35621. private _onPrePointerObservableObserver;
  35622. private _onAfterCheckInputsObserver;
  35623. private _onMeshTargetChangedObserver;
  35624. private _attachedCamera;
  35625. private _isPointerDown;
  35626. private _lastInteractionTime;
  35627. /**
  35628. * Initializes the behavior.
  35629. */
  35630. init(): void;
  35631. /**
  35632. * Attaches the behavior to its arc rotate camera.
  35633. * @param camera Defines the camera to attach the behavior to
  35634. */
  35635. attach(camera: ArcRotateCamera): void;
  35636. /**
  35637. * Detaches the behavior from its current arc rotate camera.
  35638. */
  35639. detach(): void;
  35640. private _animatables;
  35641. private _betaIsAnimating;
  35642. private _betaTransition;
  35643. private _radiusTransition;
  35644. private _vectorTransition;
  35645. /**
  35646. * Targets the given mesh and updates zoom level accordingly.
  35647. * @param mesh The mesh to target.
  35648. * @param radius Optional. If a cached radius position already exists, overrides default.
  35649. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35650. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35651. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35652. */
  35653. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35654. /**
  35655. * Targets the given mesh with its children and updates zoom level accordingly.
  35656. * @param mesh The mesh to target.
  35657. * @param radius Optional. If a cached radius position already exists, overrides default.
  35658. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35661. */
  35662. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35663. /**
  35664. * Targets the given meshes with their children and updates zoom level accordingly.
  35665. * @param meshes The mesh to target.
  35666. * @param radius Optional. If a cached radius position already exists, overrides default.
  35667. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35668. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35669. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35670. */
  35671. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35672. /**
  35673. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35674. * @param minimumWorld Determines the smaller position of the bounding box extend
  35675. * @param maximumWorld Determines the bigger position of the bounding box extend
  35676. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35677. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35678. */
  35679. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35680. /**
  35681. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35682. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35683. * frustum width.
  35684. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35685. * to fully enclose the mesh in the viewing frustum.
  35686. */
  35687. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35688. /**
  35689. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35690. * is automatically returned to its default position (expected to be above ground plane).
  35691. */
  35692. private _maintainCameraAboveGround;
  35693. /**
  35694. * Returns the frustum slope based on the canvas ratio and camera FOV
  35695. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35696. */
  35697. private _getFrustumSlope;
  35698. /**
  35699. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35700. */
  35701. private _clearAnimationLocks;
  35702. /**
  35703. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35704. */
  35705. private _applyUserInteraction;
  35706. /**
  35707. * Stops and removes all animations that have been applied to the camera
  35708. */
  35709. stopAllAnimations(): void;
  35710. /**
  35711. * Gets a value indicating if the user is moving the camera
  35712. */
  35713. readonly isUserIsMoving: boolean;
  35714. /**
  35715. * The camera can move all the way towards the mesh.
  35716. */
  35717. static IgnoreBoundsSizeMode: number;
  35718. /**
  35719. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35720. */
  35721. static FitFrustumSidesMode: number;
  35722. }
  35723. }
  35724. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35725. import { Nullable } from "babylonjs/types";
  35726. import { Camera } from "babylonjs/Cameras/camera";
  35727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35728. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35729. /**
  35730. * Base class for Camera Pointer Inputs.
  35731. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35732. * for example usage.
  35733. */
  35734. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35735. /**
  35736. * Defines the camera the input is attached to.
  35737. */
  35738. abstract camera: Camera;
  35739. /**
  35740. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35741. */
  35742. protected _altKey: boolean;
  35743. protected _ctrlKey: boolean;
  35744. protected _metaKey: boolean;
  35745. protected _shiftKey: boolean;
  35746. /**
  35747. * Which mouse buttons were pressed at time of last mouse event.
  35748. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35749. */
  35750. protected _buttonsPressed: number;
  35751. /**
  35752. * Defines the buttons associated with the input to handle camera move.
  35753. */
  35754. buttons: number[];
  35755. /**
  35756. * Attach the input controls to a specific dom element to get the input from.
  35757. * @param element Defines the element the controls should be listened from
  35758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35759. */
  35760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35761. /**
  35762. * Detach the current controls from the specified dom element.
  35763. * @param element Defines the element to stop listening the inputs from
  35764. */
  35765. detachControl(element: Nullable<HTMLElement>): void;
  35766. /**
  35767. * Gets the class name of the current input.
  35768. * @returns the class name
  35769. */
  35770. getClassName(): string;
  35771. /**
  35772. * Get the friendly name associated with the input class.
  35773. * @returns the input friendly name
  35774. */
  35775. getSimpleName(): string;
  35776. /**
  35777. * Called on pointer POINTERDOUBLETAP event.
  35778. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35779. */
  35780. protected onDoubleTap(type: string): void;
  35781. /**
  35782. * Called on pointer POINTERMOVE event if only a single touch is active.
  35783. * Override this method to provide functionality.
  35784. */
  35785. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35786. /**
  35787. * Called on pointer POINTERMOVE event if multiple touches are active.
  35788. * Override this method to provide functionality.
  35789. */
  35790. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35791. /**
  35792. * Called on JS contextmenu event.
  35793. * Override this method to provide functionality.
  35794. */
  35795. protected onContextMenu(evt: PointerEvent): void;
  35796. /**
  35797. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35798. * press.
  35799. * Override this method to provide functionality.
  35800. */
  35801. protected onButtonDown(evt: PointerEvent): void;
  35802. /**
  35803. * Called each time a new POINTERUP event occurs. Ie, for each button
  35804. * release.
  35805. * Override this method to provide functionality.
  35806. */
  35807. protected onButtonUp(evt: PointerEvent): void;
  35808. /**
  35809. * Called when window becomes inactive.
  35810. * Override this method to provide functionality.
  35811. */
  35812. protected onLostFocus(): void;
  35813. private _pointerInput;
  35814. private _observer;
  35815. private _onLostFocus;
  35816. private pointA;
  35817. private pointB;
  35818. }
  35819. }
  35820. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35821. import { Nullable } from "babylonjs/types";
  35822. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35823. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35824. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35825. /**
  35826. * Manage the pointers inputs to control an arc rotate camera.
  35827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35828. */
  35829. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35830. /**
  35831. * Defines the camera the input is attached to.
  35832. */
  35833. camera: ArcRotateCamera;
  35834. /**
  35835. * Gets the class name of the current input.
  35836. * @returns the class name
  35837. */
  35838. getClassName(): string;
  35839. /**
  35840. * Defines the buttons associated with the input to handle camera move.
  35841. */
  35842. buttons: number[];
  35843. /**
  35844. * Defines the pointer angular sensibility along the X axis or how fast is
  35845. * the camera rotating.
  35846. */
  35847. angularSensibilityX: number;
  35848. /**
  35849. * Defines the pointer angular sensibility along the Y axis or how fast is
  35850. * the camera rotating.
  35851. */
  35852. angularSensibilityY: number;
  35853. /**
  35854. * Defines the pointer pinch precision or how fast is the camera zooming.
  35855. */
  35856. pinchPrecision: number;
  35857. /**
  35858. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35859. * from 0.
  35860. * It defines the percentage of current camera.radius to use as delta when
  35861. * pinch zoom is used.
  35862. */
  35863. pinchDeltaPercentage: number;
  35864. /**
  35865. * Defines the pointer panning sensibility or how fast is the camera moving.
  35866. */
  35867. panningSensibility: number;
  35868. /**
  35869. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35870. */
  35871. multiTouchPanning: boolean;
  35872. /**
  35873. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35874. * zoom (pinch) through multitouch.
  35875. */
  35876. multiTouchPanAndZoom: boolean;
  35877. /**
  35878. * Revers pinch action direction.
  35879. */
  35880. pinchInwards: boolean;
  35881. private _isPanClick;
  35882. private _twoFingerActivityCount;
  35883. private _isPinching;
  35884. /**
  35885. * Called on pointer POINTERMOVE event if only a single touch is active.
  35886. */
  35887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35888. /**
  35889. * Called on pointer POINTERDOUBLETAP event.
  35890. */
  35891. protected onDoubleTap(type: string): void;
  35892. /**
  35893. * Called on pointer POINTERMOVE event if multiple touches are active.
  35894. */
  35895. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35896. /**
  35897. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35898. * press.
  35899. */
  35900. protected onButtonDown(evt: PointerEvent): void;
  35901. /**
  35902. * Called each time a new POINTERUP event occurs. Ie, for each button
  35903. * release.
  35904. */
  35905. protected onButtonUp(evt: PointerEvent): void;
  35906. /**
  35907. * Called when window becomes inactive.
  35908. */
  35909. protected onLostFocus(): void;
  35910. }
  35911. }
  35912. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35913. import { Nullable } from "babylonjs/types";
  35914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35915. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35916. /**
  35917. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35919. */
  35920. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35921. /**
  35922. * Defines the camera the input is attached to.
  35923. */
  35924. camera: ArcRotateCamera;
  35925. /**
  35926. * Defines the list of key codes associated with the up action (increase alpha)
  35927. */
  35928. keysUp: number[];
  35929. /**
  35930. * Defines the list of key codes associated with the down action (decrease alpha)
  35931. */
  35932. keysDown: number[];
  35933. /**
  35934. * Defines the list of key codes associated with the left action (increase beta)
  35935. */
  35936. keysLeft: number[];
  35937. /**
  35938. * Defines the list of key codes associated with the right action (decrease beta)
  35939. */
  35940. keysRight: number[];
  35941. /**
  35942. * Defines the list of key codes associated with the reset action.
  35943. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35944. */
  35945. keysReset: number[];
  35946. /**
  35947. * Defines the panning sensibility of the inputs.
  35948. * (How fast is the camera paning)
  35949. */
  35950. panningSensibility: number;
  35951. /**
  35952. * Defines the zooming sensibility of the inputs.
  35953. * (How fast is the camera zooming)
  35954. */
  35955. zoomingSensibility: number;
  35956. /**
  35957. * Defines wether maintaining the alt key down switch the movement mode from
  35958. * orientation to zoom.
  35959. */
  35960. useAltToZoom: boolean;
  35961. /**
  35962. * Rotation speed of the camera
  35963. */
  35964. angularSpeed: number;
  35965. private _keys;
  35966. private _ctrlPressed;
  35967. private _altPressed;
  35968. private _onCanvasBlurObserver;
  35969. private _onKeyboardObserver;
  35970. private _engine;
  35971. private _scene;
  35972. /**
  35973. * Attach the input controls to a specific dom element to get the input from.
  35974. * @param element Defines the element the controls should be listened from
  35975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35976. */
  35977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35978. /**
  35979. * Detach the current controls from the specified dom element.
  35980. * @param element Defines the element to stop listening the inputs from
  35981. */
  35982. detachControl(element: Nullable<HTMLElement>): void;
  35983. /**
  35984. * Update the current camera state depending on the inputs that have been used this frame.
  35985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35986. */
  35987. checkInputs(): void;
  35988. /**
  35989. * Gets the class name of the current intput.
  35990. * @returns the class name
  35991. */
  35992. getClassName(): string;
  35993. /**
  35994. * Get the friendly name associated with the input class.
  35995. * @returns the input friendly name
  35996. */
  35997. getSimpleName(): string;
  35998. }
  35999. }
  36000. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36001. import { Nullable } from "babylonjs/types";
  36002. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36003. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36004. /**
  36005. * Manage the mouse wheel inputs to control an arc rotate camera.
  36006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36007. */
  36008. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36009. /**
  36010. * Defines the camera the input is attached to.
  36011. */
  36012. camera: ArcRotateCamera;
  36013. /**
  36014. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36015. */
  36016. wheelPrecision: number;
  36017. /**
  36018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36020. */
  36021. wheelDeltaPercentage: number;
  36022. private _wheel;
  36023. private _observer;
  36024. /**
  36025. * Attach the input controls to a specific dom element to get the input from.
  36026. * @param element Defines the element the controls should be listened from
  36027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36028. */
  36029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36030. /**
  36031. * Detach the current controls from the specified dom element.
  36032. * @param element Defines the element to stop listening the inputs from
  36033. */
  36034. detachControl(element: Nullable<HTMLElement>): void;
  36035. /**
  36036. * Gets the class name of the current intput.
  36037. * @returns the class name
  36038. */
  36039. getClassName(): string;
  36040. /**
  36041. * Get the friendly name associated with the input class.
  36042. * @returns the input friendly name
  36043. */
  36044. getSimpleName(): string;
  36045. }
  36046. }
  36047. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36049. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36050. /**
  36051. * Default Inputs manager for the ArcRotateCamera.
  36052. * It groups all the default supported inputs for ease of use.
  36053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36054. */
  36055. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36056. /**
  36057. * Instantiates a new ArcRotateCameraInputsManager.
  36058. * @param camera Defines the camera the inputs belong to
  36059. */
  36060. constructor(camera: ArcRotateCamera);
  36061. /**
  36062. * Add mouse wheel input support to the input manager.
  36063. * @returns the current input manager
  36064. */
  36065. addMouseWheel(): ArcRotateCameraInputsManager;
  36066. /**
  36067. * Add pointers input support to the input manager.
  36068. * @returns the current input manager
  36069. */
  36070. addPointers(): ArcRotateCameraInputsManager;
  36071. /**
  36072. * Add keyboard input support to the input manager.
  36073. * @returns the current input manager
  36074. */
  36075. addKeyboard(): ArcRotateCameraInputsManager;
  36076. }
  36077. }
  36078. declare module "babylonjs/Cameras/arcRotateCamera" {
  36079. import { Observable } from "babylonjs/Misc/observable";
  36080. import { Nullable } from "babylonjs/types";
  36081. import { Scene } from "babylonjs/scene";
  36082. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36084. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36085. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36086. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36087. import { Camera } from "babylonjs/Cameras/camera";
  36088. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36089. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36090. import { Collider } from "babylonjs/Collisions/collider";
  36091. /**
  36092. * This represents an orbital type of camera.
  36093. *
  36094. * 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.
  36095. * 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.
  36096. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36097. */
  36098. export class ArcRotateCamera extends TargetCamera {
  36099. /**
  36100. * Defines the rotation angle of the camera along the longitudinal axis.
  36101. */
  36102. alpha: number;
  36103. /**
  36104. * Defines the rotation angle of the camera along the latitudinal axis.
  36105. */
  36106. beta: number;
  36107. /**
  36108. * Defines the radius of the camera from it s target point.
  36109. */
  36110. radius: number;
  36111. protected _target: Vector3;
  36112. protected _targetHost: Nullable<AbstractMesh>;
  36113. /**
  36114. * Defines the target point of the camera.
  36115. * The camera looks towards it form the radius distance.
  36116. */
  36117. target: Vector3;
  36118. /**
  36119. * Define the current local position of the camera in the scene
  36120. */
  36121. position: Vector3;
  36122. protected _upVector: Vector3;
  36123. protected _upToYMatrix: Matrix;
  36124. protected _YToUpMatrix: Matrix;
  36125. /**
  36126. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36127. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36128. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36129. */
  36130. upVector: Vector3;
  36131. /**
  36132. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36133. */
  36134. setMatUp(): void;
  36135. /**
  36136. * Current inertia value on the longitudinal axis.
  36137. * The bigger this number the longer it will take for the camera to stop.
  36138. */
  36139. inertialAlphaOffset: number;
  36140. /**
  36141. * Current inertia value on the latitudinal axis.
  36142. * The bigger this number the longer it will take for the camera to stop.
  36143. */
  36144. inertialBetaOffset: number;
  36145. /**
  36146. * Current inertia value on the radius axis.
  36147. * The bigger this number the longer it will take for the camera to stop.
  36148. */
  36149. inertialRadiusOffset: number;
  36150. /**
  36151. * Minimum allowed angle on the longitudinal axis.
  36152. * This can help limiting how the Camera is able to move in the scene.
  36153. */
  36154. lowerAlphaLimit: Nullable<number>;
  36155. /**
  36156. * Maximum allowed angle on the longitudinal axis.
  36157. * This can help limiting how the Camera is able to move in the scene.
  36158. */
  36159. upperAlphaLimit: Nullable<number>;
  36160. /**
  36161. * Minimum allowed angle on the latitudinal axis.
  36162. * This can help limiting how the Camera is able to move in the scene.
  36163. */
  36164. lowerBetaLimit: number;
  36165. /**
  36166. * Maximum allowed angle on the latitudinal axis.
  36167. * This can help limiting how the Camera is able to move in the scene.
  36168. */
  36169. upperBetaLimit: number;
  36170. /**
  36171. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36172. * This can help limiting how the Camera is able to move in the scene.
  36173. */
  36174. lowerRadiusLimit: Nullable<number>;
  36175. /**
  36176. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36177. * This can help limiting how the Camera is able to move in the scene.
  36178. */
  36179. upperRadiusLimit: Nullable<number>;
  36180. /**
  36181. * Defines the current inertia value used during panning of the camera along the X axis.
  36182. */
  36183. inertialPanningX: number;
  36184. /**
  36185. * Defines the current inertia value used during panning of the camera along the Y axis.
  36186. */
  36187. inertialPanningY: number;
  36188. /**
  36189. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36190. * Basically if your fingers moves away from more than this distance you will be considered
  36191. * in pinch mode.
  36192. */
  36193. pinchToPanMaxDistance: number;
  36194. /**
  36195. * Defines the maximum distance the camera can pan.
  36196. * This could help keeping the cammera always in your scene.
  36197. */
  36198. panningDistanceLimit: Nullable<number>;
  36199. /**
  36200. * Defines the target of the camera before paning.
  36201. */
  36202. panningOriginTarget: Vector3;
  36203. /**
  36204. * Defines the value of the inertia used during panning.
  36205. * 0 would mean stop inertia and one would mean no decelleration at all.
  36206. */
  36207. panningInertia: number;
  36208. /**
  36209. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36210. */
  36211. angularSensibilityX: number;
  36212. /**
  36213. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36214. */
  36215. angularSensibilityY: number;
  36216. /**
  36217. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36218. */
  36219. pinchPrecision: number;
  36220. /**
  36221. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36222. * It will be used instead of pinchDeltaPrecision if different from 0.
  36223. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36224. */
  36225. pinchDeltaPercentage: number;
  36226. /**
  36227. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36228. */
  36229. panningSensibility: number;
  36230. /**
  36231. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36232. */
  36233. keysUp: number[];
  36234. /**
  36235. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36236. */
  36237. keysDown: number[];
  36238. /**
  36239. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36240. */
  36241. keysLeft: number[];
  36242. /**
  36243. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36244. */
  36245. keysRight: number[];
  36246. /**
  36247. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36248. */
  36249. wheelPrecision: number;
  36250. /**
  36251. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36252. * It will be used instead of pinchDeltaPrecision if different from 0.
  36253. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36254. */
  36255. wheelDeltaPercentage: number;
  36256. /**
  36257. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36258. */
  36259. zoomOnFactor: number;
  36260. /**
  36261. * Defines a screen offset for the camera position.
  36262. */
  36263. targetScreenOffset: Vector2;
  36264. /**
  36265. * Allows the camera to be completely reversed.
  36266. * If false the camera can not arrive upside down.
  36267. */
  36268. allowUpsideDown: boolean;
  36269. /**
  36270. * Define if double tap/click is used to restore the previously saved state of the camera.
  36271. */
  36272. useInputToRestoreState: boolean;
  36273. /** @hidden */
  36274. _viewMatrix: Matrix;
  36275. /** @hidden */
  36276. _useCtrlForPanning: boolean;
  36277. /** @hidden */
  36278. _panningMouseButton: number;
  36279. /**
  36280. * Defines the input associated to the camera.
  36281. */
  36282. inputs: ArcRotateCameraInputsManager;
  36283. /** @hidden */
  36284. _reset: () => void;
  36285. /**
  36286. * Defines the allowed panning axis.
  36287. */
  36288. panningAxis: Vector3;
  36289. protected _localDirection: Vector3;
  36290. protected _transformedDirection: Vector3;
  36291. private _bouncingBehavior;
  36292. /**
  36293. * Gets the bouncing behavior of the camera if it has been enabled.
  36294. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36295. */
  36296. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36297. /**
  36298. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36300. */
  36301. useBouncingBehavior: boolean;
  36302. private _framingBehavior;
  36303. /**
  36304. * Gets the framing behavior of the camera if it has been enabled.
  36305. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36306. */
  36307. readonly framingBehavior: Nullable<FramingBehavior>;
  36308. /**
  36309. * Defines if the framing behavior of the camera is enabled on the camera.
  36310. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36311. */
  36312. useFramingBehavior: boolean;
  36313. private _autoRotationBehavior;
  36314. /**
  36315. * Gets the auto rotation behavior of the camera if it has been enabled.
  36316. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36317. */
  36318. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36319. /**
  36320. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36321. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36322. */
  36323. useAutoRotationBehavior: boolean;
  36324. /**
  36325. * Observable triggered when the mesh target has been changed on the camera.
  36326. */
  36327. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36328. /**
  36329. * Event raised when the camera is colliding with a mesh.
  36330. */
  36331. onCollide: (collidedMesh: AbstractMesh) => void;
  36332. /**
  36333. * Defines whether the camera should check collision with the objects oh the scene.
  36334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36335. */
  36336. checkCollisions: boolean;
  36337. /**
  36338. * Defines the collision radius of the camera.
  36339. * This simulates a sphere around the camera.
  36340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36341. */
  36342. collisionRadius: Vector3;
  36343. protected _collider: Collider;
  36344. protected _previousPosition: Vector3;
  36345. protected _collisionVelocity: Vector3;
  36346. protected _newPosition: Vector3;
  36347. protected _previousAlpha: number;
  36348. protected _previousBeta: number;
  36349. protected _previousRadius: number;
  36350. protected _collisionTriggered: boolean;
  36351. protected _targetBoundingCenter: Nullable<Vector3>;
  36352. private _computationVector;
  36353. /**
  36354. * Instantiates a new ArcRotateCamera in a given scene
  36355. * @param name Defines the name of the camera
  36356. * @param alpha Defines the camera rotation along the logitudinal axis
  36357. * @param beta Defines the camera rotation along the latitudinal axis
  36358. * @param radius Defines the camera distance from its target
  36359. * @param target Defines the camera target
  36360. * @param scene Defines the scene the camera belongs to
  36361. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36362. */
  36363. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36364. /** @hidden */
  36365. _initCache(): void;
  36366. /** @hidden */
  36367. _updateCache(ignoreParentClass?: boolean): void;
  36368. protected _getTargetPosition(): Vector3;
  36369. private _storedAlpha;
  36370. private _storedBeta;
  36371. private _storedRadius;
  36372. private _storedTarget;
  36373. /**
  36374. * Stores the current state of the camera (alpha, beta, radius and target)
  36375. * @returns the camera itself
  36376. */
  36377. storeState(): Camera;
  36378. /**
  36379. * @hidden
  36380. * Restored camera state. You must call storeState() first
  36381. */
  36382. _restoreStateValues(): boolean;
  36383. /** @hidden */
  36384. _isSynchronizedViewMatrix(): boolean;
  36385. /**
  36386. * Attached controls to the current camera.
  36387. * @param element Defines the element the controls should be listened from
  36388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36389. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36390. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36391. */
  36392. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36393. /**
  36394. * Detach the current controls from the camera.
  36395. * The camera will stop reacting to inputs.
  36396. * @param element Defines the element to stop listening the inputs from
  36397. */
  36398. detachControl(element: HTMLElement): void;
  36399. /** @hidden */
  36400. _checkInputs(): void;
  36401. protected _checkLimits(): void;
  36402. /**
  36403. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36404. */
  36405. rebuildAnglesAndRadius(): void;
  36406. /**
  36407. * Use a position to define the current camera related information like aplha, beta and radius
  36408. * @param position Defines the position to set the camera at
  36409. */
  36410. setPosition(position: Vector3): void;
  36411. /**
  36412. * Defines the target the camera should look at.
  36413. * This will automatically adapt alpha beta and radius to fit within the new target.
  36414. * @param target Defines the new target as a Vector or a mesh
  36415. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36416. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36417. */
  36418. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36419. /** @hidden */
  36420. _getViewMatrix(): Matrix;
  36421. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36422. /**
  36423. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36424. * @param meshes Defines the mesh to zoom on
  36425. * @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)
  36426. */
  36427. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36428. /**
  36429. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36430. * The target will be changed but the radius
  36431. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36432. * @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)
  36433. */
  36434. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36435. min: Vector3;
  36436. max: Vector3;
  36437. distance: number;
  36438. }, doNotUpdateMaxZ?: boolean): void;
  36439. /**
  36440. * @override
  36441. * Override Camera.createRigCamera
  36442. */
  36443. createRigCamera(name: string, cameraIndex: number): Camera;
  36444. /**
  36445. * @hidden
  36446. * @override
  36447. * Override Camera._updateRigCameras
  36448. */
  36449. _updateRigCameras(): void;
  36450. /**
  36451. * Destroy the camera and release the current resources hold by it.
  36452. */
  36453. dispose(): void;
  36454. /**
  36455. * Gets the current object class name.
  36456. * @return the class name
  36457. */
  36458. getClassName(): string;
  36459. }
  36460. }
  36461. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36462. import { Behavior } from "babylonjs/Behaviors/behavior";
  36463. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36464. /**
  36465. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36467. */
  36468. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36469. /**
  36470. * Gets the name of the behavior.
  36471. */
  36472. readonly name: string;
  36473. private _zoomStopsAnimation;
  36474. private _idleRotationSpeed;
  36475. private _idleRotationWaitTime;
  36476. private _idleRotationSpinupTime;
  36477. /**
  36478. * Sets the flag that indicates if user zooming should stop animation.
  36479. */
  36480. /**
  36481. * Gets the flag that indicates if user zooming should stop animation.
  36482. */
  36483. zoomStopsAnimation: boolean;
  36484. /**
  36485. * Sets the default speed at which the camera rotates around the model.
  36486. */
  36487. /**
  36488. * Gets the default speed at which the camera rotates around the model.
  36489. */
  36490. idleRotationSpeed: number;
  36491. /**
  36492. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36493. */
  36494. /**
  36495. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36496. */
  36497. idleRotationWaitTime: number;
  36498. /**
  36499. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36500. */
  36501. /**
  36502. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36503. */
  36504. idleRotationSpinupTime: number;
  36505. /**
  36506. * Gets a value indicating if the camera is currently rotating because of this behavior
  36507. */
  36508. readonly rotationInProgress: boolean;
  36509. private _onPrePointerObservableObserver;
  36510. private _onAfterCheckInputsObserver;
  36511. private _attachedCamera;
  36512. private _isPointerDown;
  36513. private _lastFrameTime;
  36514. private _lastInteractionTime;
  36515. private _cameraRotationSpeed;
  36516. /**
  36517. * Initializes the behavior.
  36518. */
  36519. init(): void;
  36520. /**
  36521. * Attaches the behavior to its arc rotate camera.
  36522. * @param camera Defines the camera to attach the behavior to
  36523. */
  36524. attach(camera: ArcRotateCamera): void;
  36525. /**
  36526. * Detaches the behavior from its current arc rotate camera.
  36527. */
  36528. detach(): void;
  36529. /**
  36530. * Returns true if user is scrolling.
  36531. * @return true if user is scrolling.
  36532. */
  36533. private _userIsZooming;
  36534. private _lastFrameRadius;
  36535. private _shouldAnimationStopForInteraction;
  36536. /**
  36537. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36538. */
  36539. private _applyUserInteraction;
  36540. private _userIsMoving;
  36541. }
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/index" {
  36544. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36545. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36546. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36547. }
  36548. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36549. import { Mesh } from "babylonjs/Meshes/mesh";
  36550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36551. import { Behavior } from "babylonjs/Behaviors/behavior";
  36552. /**
  36553. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36554. */
  36555. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36556. private ui;
  36557. /**
  36558. * The name of the behavior
  36559. */
  36560. name: string;
  36561. /**
  36562. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36563. */
  36564. distanceAwayFromFace: number;
  36565. /**
  36566. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36567. */
  36568. distanceAwayFromBottomOfFace: number;
  36569. private _faceVectors;
  36570. private _target;
  36571. private _scene;
  36572. private _onRenderObserver;
  36573. private _tmpMatrix;
  36574. private _tmpVector;
  36575. /**
  36576. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36577. * @param ui The transform node that should be attched to the mesh
  36578. */
  36579. constructor(ui: TransformNode);
  36580. /**
  36581. * Initializes the behavior
  36582. */
  36583. init(): void;
  36584. private _closestFace;
  36585. private _zeroVector;
  36586. private _lookAtTmpMatrix;
  36587. private _lookAtToRef;
  36588. /**
  36589. * Attaches the AttachToBoxBehavior to the passed in mesh
  36590. * @param target The mesh that the specified node will be attached to
  36591. */
  36592. attach(target: Mesh): void;
  36593. /**
  36594. * Detaches the behavior from the mesh
  36595. */
  36596. detach(): void;
  36597. }
  36598. }
  36599. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36600. import { Behavior } from "babylonjs/Behaviors/behavior";
  36601. import { Mesh } from "babylonjs/Meshes/mesh";
  36602. /**
  36603. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36604. */
  36605. export class FadeInOutBehavior implements Behavior<Mesh> {
  36606. /**
  36607. * Time in milliseconds to delay before fading in (Default: 0)
  36608. */
  36609. delay: number;
  36610. /**
  36611. * Time in milliseconds for the mesh to fade in (Default: 300)
  36612. */
  36613. fadeInTime: number;
  36614. private _millisecondsPerFrame;
  36615. private _hovered;
  36616. private _hoverValue;
  36617. private _ownerNode;
  36618. /**
  36619. * Instatiates the FadeInOutBehavior
  36620. */
  36621. constructor();
  36622. /**
  36623. * The name of the behavior
  36624. */
  36625. readonly name: string;
  36626. /**
  36627. * Initializes the behavior
  36628. */
  36629. init(): void;
  36630. /**
  36631. * Attaches the fade behavior on the passed in mesh
  36632. * @param ownerNode The mesh that will be faded in/out once attached
  36633. */
  36634. attach(ownerNode: Mesh): void;
  36635. /**
  36636. * Detaches the behavior from the mesh
  36637. */
  36638. detach(): void;
  36639. /**
  36640. * Triggers the mesh to begin fading in or out
  36641. * @param value if the object should fade in or out (true to fade in)
  36642. */
  36643. fadeIn(value: boolean): void;
  36644. private _update;
  36645. private _setAllVisibility;
  36646. }
  36647. }
  36648. declare module "babylonjs/Misc/pivotTools" {
  36649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36650. /**
  36651. * Class containing a set of static utilities functions for managing Pivots
  36652. * @hidden
  36653. */
  36654. export class PivotTools {
  36655. private static _PivotCached;
  36656. private static _OldPivotPoint;
  36657. private static _PivotTranslation;
  36658. private static _PivotTmpVector;
  36659. /** @hidden */
  36660. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36661. /** @hidden */
  36662. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36663. }
  36664. }
  36665. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36666. import { Scene } from "babylonjs/scene";
  36667. import { Vector4, Plane } from "babylonjs/Maths/math";
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. import { Nullable } from "babylonjs/types";
  36670. /**
  36671. * Class containing static functions to help procedurally build meshes
  36672. */
  36673. export class PlaneBuilder {
  36674. /**
  36675. * Creates a plane mesh
  36676. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36677. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36678. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36682. * @param name defines the name of the mesh
  36683. * @param options defines the options used to create the mesh
  36684. * @param scene defines the hosting scene
  36685. * @returns the plane mesh
  36686. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36687. */
  36688. static CreatePlane(name: string, options: {
  36689. size?: number;
  36690. width?: number;
  36691. height?: number;
  36692. sideOrientation?: number;
  36693. frontUVs?: Vector4;
  36694. backUVs?: Vector4;
  36695. updatable?: boolean;
  36696. sourcePlane?: Plane;
  36697. }, scene?: Nullable<Scene>): Mesh;
  36698. }
  36699. }
  36700. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36701. import { Behavior } from "babylonjs/Behaviors/behavior";
  36702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36703. import { Observable } from "babylonjs/Misc/observable";
  36704. import { Vector3 } from "babylonjs/Maths/math";
  36705. import { Ray } from "babylonjs/Culling/ray";
  36706. import "babylonjs/Meshes/Builders/planeBuilder";
  36707. /**
  36708. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36709. */
  36710. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36711. private static _AnyMouseID;
  36712. private _attachedNode;
  36713. private _dragPlane;
  36714. private _scene;
  36715. private _pointerObserver;
  36716. private _beforeRenderObserver;
  36717. private static _planeScene;
  36718. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36719. /**
  36720. * 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)
  36721. */
  36722. maxDragAngle: number;
  36723. /**
  36724. * @hidden
  36725. */
  36726. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36727. /**
  36728. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36729. */
  36730. currentDraggingPointerID: number;
  36731. /**
  36732. * The last position where the pointer hit the drag plane in world space
  36733. */
  36734. lastDragPosition: Vector3;
  36735. /**
  36736. * If the behavior is currently in a dragging state
  36737. */
  36738. dragging: boolean;
  36739. /**
  36740. * 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)
  36741. */
  36742. dragDeltaRatio: number;
  36743. /**
  36744. * If the drag plane orientation should be updated during the dragging (Default: true)
  36745. */
  36746. updateDragPlane: boolean;
  36747. private _debugMode;
  36748. private _moving;
  36749. /**
  36750. * Fires each time the attached mesh is dragged with the pointer
  36751. * * delta between last drag position and current drag position in world space
  36752. * * dragDistance along the drag axis
  36753. * * dragPlaneNormal normal of the current drag plane used during the drag
  36754. * * dragPlanePoint in world space where the drag intersects the drag plane
  36755. */
  36756. onDragObservable: Observable<{
  36757. delta: Vector3;
  36758. dragPlanePoint: Vector3;
  36759. dragPlaneNormal: Vector3;
  36760. dragDistance: number;
  36761. pointerId: number;
  36762. }>;
  36763. /**
  36764. * Fires each time a drag begins (eg. mouse down on mesh)
  36765. */
  36766. onDragStartObservable: Observable<{
  36767. dragPlanePoint: Vector3;
  36768. pointerId: number;
  36769. }>;
  36770. /**
  36771. * Fires each time a drag ends (eg. mouse release after drag)
  36772. */
  36773. onDragEndObservable: Observable<{
  36774. dragPlanePoint: Vector3;
  36775. pointerId: number;
  36776. }>;
  36777. /**
  36778. * If the attached mesh should be moved when dragged
  36779. */
  36780. moveAttached: boolean;
  36781. /**
  36782. * If the drag behavior will react to drag events (Default: true)
  36783. */
  36784. enabled: boolean;
  36785. /**
  36786. * If camera controls should be detached during the drag
  36787. */
  36788. detachCameraControls: boolean;
  36789. /**
  36790. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36791. */
  36792. useObjectOrienationForDragging: boolean;
  36793. private _options;
  36794. /**
  36795. * Creates a pointer drag behavior that can be attached to a mesh
  36796. * @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)
  36797. */
  36798. constructor(options?: {
  36799. dragAxis?: Vector3;
  36800. dragPlaneNormal?: Vector3;
  36801. });
  36802. /**
  36803. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36804. */
  36805. validateDrag: (targetPosition: Vector3) => boolean;
  36806. /**
  36807. * The name of the behavior
  36808. */
  36809. readonly name: string;
  36810. /**
  36811. * Initializes the behavior
  36812. */
  36813. init(): void;
  36814. private _tmpVector;
  36815. private _alternatePickedPoint;
  36816. private _worldDragAxis;
  36817. private _targetPosition;
  36818. private _attachedElement;
  36819. /**
  36820. * Attaches the drag behavior the passed in mesh
  36821. * @param ownerNode The mesh that will be dragged around once attached
  36822. */
  36823. attach(ownerNode: AbstractMesh): void;
  36824. /**
  36825. * Force relase the drag action by code.
  36826. */
  36827. releaseDrag(): void;
  36828. private _startDragRay;
  36829. private _lastPointerRay;
  36830. /**
  36831. * Simulates the start of a pointer drag event on the behavior
  36832. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36833. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36834. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36835. */
  36836. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36837. private _startDrag;
  36838. private _dragDelta;
  36839. private _moveDrag;
  36840. private _pickWithRayOnDragPlane;
  36841. private _pointA;
  36842. private _pointB;
  36843. private _pointC;
  36844. private _lineA;
  36845. private _lineB;
  36846. private _localAxis;
  36847. private _lookAt;
  36848. private _updateDragPlanePosition;
  36849. /**
  36850. * Detaches the behavior from the mesh
  36851. */
  36852. detach(): void;
  36853. }
  36854. }
  36855. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36856. import { Mesh } from "babylonjs/Meshes/mesh";
  36857. import { Behavior } from "babylonjs/Behaviors/behavior";
  36858. /**
  36859. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36860. */
  36861. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36862. private _dragBehaviorA;
  36863. private _dragBehaviorB;
  36864. private _startDistance;
  36865. private _initialScale;
  36866. private _targetScale;
  36867. private _ownerNode;
  36868. private _sceneRenderObserver;
  36869. /**
  36870. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36871. */
  36872. constructor();
  36873. /**
  36874. * The name of the behavior
  36875. */
  36876. readonly name: string;
  36877. /**
  36878. * Initializes the behavior
  36879. */
  36880. init(): void;
  36881. private _getCurrentDistance;
  36882. /**
  36883. * Attaches the scale behavior the passed in mesh
  36884. * @param ownerNode The mesh that will be scaled around once attached
  36885. */
  36886. attach(ownerNode: Mesh): void;
  36887. /**
  36888. * Detaches the behavior from the mesh
  36889. */
  36890. detach(): void;
  36891. }
  36892. }
  36893. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36894. import { Behavior } from "babylonjs/Behaviors/behavior";
  36895. import { Mesh } from "babylonjs/Meshes/mesh";
  36896. import { Observable } from "babylonjs/Misc/observable";
  36897. /**
  36898. * 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
  36899. */
  36900. export class SixDofDragBehavior implements Behavior<Mesh> {
  36901. private static _virtualScene;
  36902. private _ownerNode;
  36903. private _sceneRenderObserver;
  36904. private _scene;
  36905. private _targetPosition;
  36906. private _virtualOriginMesh;
  36907. private _virtualDragMesh;
  36908. private _pointerObserver;
  36909. private _moving;
  36910. private _startingOrientation;
  36911. /**
  36912. * 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)
  36913. */
  36914. private zDragFactor;
  36915. /**
  36916. * If the object should rotate to face the drag origin
  36917. */
  36918. rotateDraggedObject: boolean;
  36919. /**
  36920. * If the behavior is currently in a dragging state
  36921. */
  36922. dragging: boolean;
  36923. /**
  36924. * 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)
  36925. */
  36926. dragDeltaRatio: number;
  36927. /**
  36928. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36929. */
  36930. currentDraggingPointerID: number;
  36931. /**
  36932. * If camera controls should be detached during the drag
  36933. */
  36934. detachCameraControls: boolean;
  36935. /**
  36936. * Fires each time a drag starts
  36937. */
  36938. onDragStartObservable: Observable<{}>;
  36939. /**
  36940. * Fires each time a drag ends (eg. mouse release after drag)
  36941. */
  36942. onDragEndObservable: Observable<{}>;
  36943. /**
  36944. * 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
  36945. */
  36946. constructor();
  36947. /**
  36948. * The name of the behavior
  36949. */
  36950. readonly name: string;
  36951. /**
  36952. * Initializes the behavior
  36953. */
  36954. init(): void;
  36955. /**
  36956. * Attaches the scale behavior the passed in mesh
  36957. * @param ownerNode The mesh that will be scaled around once attached
  36958. */
  36959. attach(ownerNode: Mesh): void;
  36960. /**
  36961. * Detaches the behavior from the mesh
  36962. */
  36963. detach(): void;
  36964. }
  36965. }
  36966. declare module "babylonjs/Behaviors/Meshes/index" {
  36967. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36968. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36969. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36970. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36971. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36972. }
  36973. declare module "babylonjs/Behaviors/index" {
  36974. export * from "babylonjs/Behaviors/behavior";
  36975. export * from "babylonjs/Behaviors/Cameras/index";
  36976. export * from "babylonjs/Behaviors/Meshes/index";
  36977. }
  36978. declare module "babylonjs/Bones/boneIKController" {
  36979. import { Bone } from "babylonjs/Bones/bone";
  36980. import { Vector3 } from "babylonjs/Maths/math";
  36981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36982. import { Nullable } from "babylonjs/types";
  36983. /**
  36984. * Class used to apply inverse kinematics to bones
  36985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36986. */
  36987. export class BoneIKController {
  36988. private static _tmpVecs;
  36989. private static _tmpQuat;
  36990. private static _tmpMats;
  36991. /**
  36992. * Gets or sets the target mesh
  36993. */
  36994. targetMesh: AbstractMesh;
  36995. /** Gets or sets the mesh used as pole */
  36996. poleTargetMesh: AbstractMesh;
  36997. /**
  36998. * Gets or sets the bone used as pole
  36999. */
  37000. poleTargetBone: Nullable<Bone>;
  37001. /**
  37002. * Gets or sets the target position
  37003. */
  37004. targetPosition: Vector3;
  37005. /**
  37006. * Gets or sets the pole target position
  37007. */
  37008. poleTargetPosition: Vector3;
  37009. /**
  37010. * Gets or sets the pole target local offset
  37011. */
  37012. poleTargetLocalOffset: Vector3;
  37013. /**
  37014. * Gets or sets the pole angle
  37015. */
  37016. poleAngle: number;
  37017. /**
  37018. * Gets or sets the mesh associated with the controller
  37019. */
  37020. mesh: AbstractMesh;
  37021. /**
  37022. * 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)
  37023. */
  37024. slerpAmount: number;
  37025. private _bone1Quat;
  37026. private _bone1Mat;
  37027. private _bone2Ang;
  37028. private _bone1;
  37029. private _bone2;
  37030. private _bone1Length;
  37031. private _bone2Length;
  37032. private _maxAngle;
  37033. private _maxReach;
  37034. private _rightHandedSystem;
  37035. private _bendAxis;
  37036. private _slerping;
  37037. private _adjustRoll;
  37038. /**
  37039. * Gets or sets maximum allowed angle
  37040. */
  37041. maxAngle: number;
  37042. /**
  37043. * Creates a new BoneIKController
  37044. * @param mesh defines the mesh to control
  37045. * @param bone defines the bone to control
  37046. * @param options defines options to set up the controller
  37047. */
  37048. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37049. targetMesh?: AbstractMesh;
  37050. poleTargetMesh?: AbstractMesh;
  37051. poleTargetBone?: Bone;
  37052. poleTargetLocalOffset?: Vector3;
  37053. poleAngle?: number;
  37054. bendAxis?: Vector3;
  37055. maxAngle?: number;
  37056. slerpAmount?: number;
  37057. });
  37058. private _setMaxAngle;
  37059. /**
  37060. * Force the controller to update the bones
  37061. */
  37062. update(): void;
  37063. }
  37064. }
  37065. declare module "babylonjs/Bones/boneLookController" {
  37066. import { Vector3, Space } from "babylonjs/Maths/math";
  37067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37068. import { Bone } from "babylonjs/Bones/bone";
  37069. /**
  37070. * Class used to make a bone look toward a point in space
  37071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37072. */
  37073. export class BoneLookController {
  37074. private static _tmpVecs;
  37075. private static _tmpQuat;
  37076. private static _tmpMats;
  37077. /**
  37078. * The target Vector3 that the bone will look at
  37079. */
  37080. target: Vector3;
  37081. /**
  37082. * The mesh that the bone is attached to
  37083. */
  37084. mesh: AbstractMesh;
  37085. /**
  37086. * The bone that will be looking to the target
  37087. */
  37088. bone: Bone;
  37089. /**
  37090. * The up axis of the coordinate system that is used when the bone is rotated
  37091. */
  37092. upAxis: Vector3;
  37093. /**
  37094. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37095. */
  37096. upAxisSpace: Space;
  37097. /**
  37098. * Used to make an adjustment to the yaw of the bone
  37099. */
  37100. adjustYaw: number;
  37101. /**
  37102. * Used to make an adjustment to the pitch of the bone
  37103. */
  37104. adjustPitch: number;
  37105. /**
  37106. * Used to make an adjustment to the roll of the bone
  37107. */
  37108. adjustRoll: number;
  37109. /**
  37110. * 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)
  37111. */
  37112. slerpAmount: number;
  37113. private _minYaw;
  37114. private _maxYaw;
  37115. private _minPitch;
  37116. private _maxPitch;
  37117. private _minYawSin;
  37118. private _minYawCos;
  37119. private _maxYawSin;
  37120. private _maxYawCos;
  37121. private _midYawConstraint;
  37122. private _minPitchTan;
  37123. private _maxPitchTan;
  37124. private _boneQuat;
  37125. private _slerping;
  37126. private _transformYawPitch;
  37127. private _transformYawPitchInv;
  37128. private _firstFrameSkipped;
  37129. private _yawRange;
  37130. private _fowardAxis;
  37131. /**
  37132. * Gets or sets the minimum yaw angle that the bone can look to
  37133. */
  37134. minYaw: number;
  37135. /**
  37136. * Gets or sets the maximum yaw angle that the bone can look to
  37137. */
  37138. maxYaw: number;
  37139. /**
  37140. * Gets or sets the minimum pitch angle that the bone can look to
  37141. */
  37142. minPitch: number;
  37143. /**
  37144. * Gets or sets the maximum pitch angle that the bone can look to
  37145. */
  37146. maxPitch: number;
  37147. /**
  37148. * Create a BoneLookController
  37149. * @param mesh the mesh that the bone belongs to
  37150. * @param bone the bone that will be looking to the target
  37151. * @param target the target Vector3 to look at
  37152. * @param options optional settings:
  37153. * * maxYaw: the maximum angle the bone will yaw to
  37154. * * minYaw: the minimum angle the bone will yaw to
  37155. * * maxPitch: the maximum angle the bone will pitch to
  37156. * * minPitch: the minimum angle the bone will yaw to
  37157. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37158. * * upAxis: the up axis of the coordinate system
  37159. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37160. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37161. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37162. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37163. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37164. * * adjustRoll: used to make an adjustment to the roll of the bone
  37165. **/
  37166. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37167. maxYaw?: number;
  37168. minYaw?: number;
  37169. maxPitch?: number;
  37170. minPitch?: number;
  37171. slerpAmount?: number;
  37172. upAxis?: Vector3;
  37173. upAxisSpace?: Space;
  37174. yawAxis?: Vector3;
  37175. pitchAxis?: Vector3;
  37176. adjustYaw?: number;
  37177. adjustPitch?: number;
  37178. adjustRoll?: number;
  37179. });
  37180. /**
  37181. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37182. */
  37183. update(): void;
  37184. private _getAngleDiff;
  37185. private _getAngleBetween;
  37186. private _isAngleBetween;
  37187. }
  37188. }
  37189. declare module "babylonjs/Bones/index" {
  37190. export * from "babylonjs/Bones/bone";
  37191. export * from "babylonjs/Bones/boneIKController";
  37192. export * from "babylonjs/Bones/boneLookController";
  37193. export * from "babylonjs/Bones/skeleton";
  37194. }
  37195. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37196. import { Nullable } from "babylonjs/types";
  37197. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37198. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37199. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37200. /**
  37201. * Manage the gamepad inputs to control an arc rotate camera.
  37202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37203. */
  37204. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37205. /**
  37206. * Defines the camera the input is attached to.
  37207. */
  37208. camera: ArcRotateCamera;
  37209. /**
  37210. * Defines the gamepad the input is gathering event from.
  37211. */
  37212. gamepad: Nullable<Gamepad>;
  37213. /**
  37214. * Defines the gamepad rotation sensiblity.
  37215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37216. */
  37217. gamepadRotationSensibility: number;
  37218. /**
  37219. * Defines the gamepad move sensiblity.
  37220. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37221. */
  37222. gamepadMoveSensibility: number;
  37223. private _onGamepadConnectedObserver;
  37224. private _onGamepadDisconnectedObserver;
  37225. /**
  37226. * Attach the input controls to a specific dom element to get the input from.
  37227. * @param element Defines the element the controls should be listened from
  37228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37229. */
  37230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37231. /**
  37232. * Detach the current controls from the specified dom element.
  37233. * @param element Defines the element to stop listening the inputs from
  37234. */
  37235. detachControl(element: Nullable<HTMLElement>): void;
  37236. /**
  37237. * Update the current camera state depending on the inputs that have been used this frame.
  37238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37239. */
  37240. checkInputs(): void;
  37241. /**
  37242. * Gets the class name of the current intput.
  37243. * @returns the class name
  37244. */
  37245. getClassName(): string;
  37246. /**
  37247. * Get the friendly name associated with the input class.
  37248. * @returns the input friendly name
  37249. */
  37250. getSimpleName(): string;
  37251. }
  37252. }
  37253. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37254. import { Nullable } from "babylonjs/types";
  37255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37256. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37257. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37258. interface ArcRotateCameraInputsManager {
  37259. /**
  37260. * Add orientation input support to the input manager.
  37261. * @returns the current input manager
  37262. */
  37263. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37264. }
  37265. }
  37266. /**
  37267. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37269. */
  37270. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37271. /**
  37272. * Defines the camera the input is attached to.
  37273. */
  37274. camera: ArcRotateCamera;
  37275. /**
  37276. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37277. */
  37278. alphaCorrection: number;
  37279. /**
  37280. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37281. */
  37282. gammaCorrection: number;
  37283. private _alpha;
  37284. private _gamma;
  37285. private _dirty;
  37286. private _deviceOrientationHandler;
  37287. /**
  37288. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37289. */
  37290. constructor();
  37291. /**
  37292. * Attach the input controls to a specific dom element to get the input from.
  37293. * @param element Defines the element the controls should be listened from
  37294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37295. */
  37296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37297. /** @hidden */
  37298. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37299. /**
  37300. * Update the current camera state depending on the inputs that have been used this frame.
  37301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37302. */
  37303. checkInputs(): void;
  37304. /**
  37305. * Detach the current controls from the specified dom element.
  37306. * @param element Defines the element to stop listening the inputs from
  37307. */
  37308. detachControl(element: Nullable<HTMLElement>): void;
  37309. /**
  37310. * Gets the class name of the current intput.
  37311. * @returns the class name
  37312. */
  37313. getClassName(): string;
  37314. /**
  37315. * Get the friendly name associated with the input class.
  37316. * @returns the input friendly name
  37317. */
  37318. getSimpleName(): string;
  37319. }
  37320. }
  37321. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37322. import { Nullable } from "babylonjs/types";
  37323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37325. /**
  37326. * Listen to mouse events to control the camera.
  37327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37328. */
  37329. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37330. /**
  37331. * Defines the camera the input is attached to.
  37332. */
  37333. camera: FlyCamera;
  37334. /**
  37335. * Defines if touch is enabled. (Default is true.)
  37336. */
  37337. touchEnabled: boolean;
  37338. /**
  37339. * Defines the buttons associated with the input to handle camera rotation.
  37340. */
  37341. buttons: number[];
  37342. /**
  37343. * Assign buttons for Yaw control.
  37344. */
  37345. buttonsYaw: number[];
  37346. /**
  37347. * Assign buttons for Pitch control.
  37348. */
  37349. buttonsPitch: number[];
  37350. /**
  37351. * Assign buttons for Roll control.
  37352. */
  37353. buttonsRoll: number[];
  37354. /**
  37355. * Detect if any button is being pressed while mouse is moved.
  37356. * -1 = Mouse locked.
  37357. * 0 = Left button.
  37358. * 1 = Middle Button.
  37359. * 2 = Right Button.
  37360. */
  37361. activeButton: number;
  37362. /**
  37363. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37364. * Higher values reduce its sensitivity.
  37365. */
  37366. angularSensibility: number;
  37367. private _mousemoveCallback;
  37368. private _observer;
  37369. private _rollObserver;
  37370. private previousPosition;
  37371. private noPreventDefault;
  37372. private element;
  37373. /**
  37374. * Listen to mouse events to control the camera.
  37375. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37377. */
  37378. constructor(touchEnabled?: boolean);
  37379. /**
  37380. * Attach the mouse control to the HTML DOM element.
  37381. * @param element Defines the element that listens to the input events.
  37382. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37383. */
  37384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37385. /**
  37386. * Detach the current controls from the specified dom element.
  37387. * @param element Defines the element to stop listening the inputs from
  37388. */
  37389. detachControl(element: Nullable<HTMLElement>): void;
  37390. /**
  37391. * Gets the class name of the current input.
  37392. * @returns the class name.
  37393. */
  37394. getClassName(): string;
  37395. /**
  37396. * Get the friendly name associated with the input class.
  37397. * @returns the input's friendly name.
  37398. */
  37399. getSimpleName(): string;
  37400. private _pointerInput;
  37401. private _onMouseMove;
  37402. /**
  37403. * Rotate camera by mouse offset.
  37404. */
  37405. private rotateCamera;
  37406. }
  37407. }
  37408. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37409. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37410. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37411. /**
  37412. * Default Inputs manager for the FlyCamera.
  37413. * It groups all the default supported inputs for ease of use.
  37414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37415. */
  37416. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37417. /**
  37418. * Instantiates a new FlyCameraInputsManager.
  37419. * @param camera Defines the camera the inputs belong to.
  37420. */
  37421. constructor(camera: FlyCamera);
  37422. /**
  37423. * Add keyboard input support to the input manager.
  37424. * @returns the new FlyCameraKeyboardMoveInput().
  37425. */
  37426. addKeyboard(): FlyCameraInputsManager;
  37427. /**
  37428. * Add mouse input support to the input manager.
  37429. * @param touchEnabled Enable touch screen support.
  37430. * @returns the new FlyCameraMouseInput().
  37431. */
  37432. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/flyCamera" {
  37436. import { Scene } from "babylonjs/scene";
  37437. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37439. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37440. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37441. /**
  37442. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37443. * such as in a 3D Space Shooter or a Flight Simulator.
  37444. */
  37445. export class FlyCamera extends TargetCamera {
  37446. /**
  37447. * Define the collision ellipsoid of the camera.
  37448. * This is helpful for simulating a camera body, like a player's body.
  37449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37450. */
  37451. ellipsoid: Vector3;
  37452. /**
  37453. * Define an offset for the position of the ellipsoid around the camera.
  37454. * This can be helpful if the camera is attached away from the player's body center,
  37455. * such as at its head.
  37456. */
  37457. ellipsoidOffset: Vector3;
  37458. /**
  37459. * Enable or disable collisions of the camera with the rest of the scene objects.
  37460. */
  37461. checkCollisions: boolean;
  37462. /**
  37463. * Enable or disable gravity on the camera.
  37464. */
  37465. applyGravity: boolean;
  37466. /**
  37467. * Define the current direction the camera is moving to.
  37468. */
  37469. cameraDirection: Vector3;
  37470. /**
  37471. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37472. * This overrides and empties cameraRotation.
  37473. */
  37474. rotationQuaternion: Quaternion;
  37475. /**
  37476. * Track Roll to maintain the wanted Rolling when looking around.
  37477. */
  37478. _trackRoll: number;
  37479. /**
  37480. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37481. */
  37482. rollCorrect: number;
  37483. /**
  37484. * Mimic a banked turn, Rolling the camera when Yawing.
  37485. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37486. */
  37487. bankedTurn: boolean;
  37488. /**
  37489. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37490. */
  37491. bankedTurnLimit: number;
  37492. /**
  37493. * Value of 0 disables the banked Roll.
  37494. * Value of 1 is equal to the Yaw angle in radians.
  37495. */
  37496. bankedTurnMultiplier: number;
  37497. /**
  37498. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37499. */
  37500. inputs: FlyCameraInputsManager;
  37501. /**
  37502. * Gets the input sensibility for mouse input.
  37503. * Higher values reduce sensitivity.
  37504. */
  37505. /**
  37506. * Sets the input sensibility for a mouse input.
  37507. * Higher values reduce sensitivity.
  37508. */
  37509. angularSensibility: number;
  37510. /**
  37511. * Get the keys for camera movement forward.
  37512. */
  37513. /**
  37514. * Set the keys for camera movement forward.
  37515. */
  37516. keysForward: number[];
  37517. /**
  37518. * Get the keys for camera movement backward.
  37519. */
  37520. keysBackward: number[];
  37521. /**
  37522. * Get the keys for camera movement up.
  37523. */
  37524. /**
  37525. * Set the keys for camera movement up.
  37526. */
  37527. keysUp: number[];
  37528. /**
  37529. * Get the keys for camera movement down.
  37530. */
  37531. /**
  37532. * Set the keys for camera movement down.
  37533. */
  37534. keysDown: number[];
  37535. /**
  37536. * Get the keys for camera movement left.
  37537. */
  37538. /**
  37539. * Set the keys for camera movement left.
  37540. */
  37541. keysLeft: number[];
  37542. /**
  37543. * Set the keys for camera movement right.
  37544. */
  37545. /**
  37546. * Set the keys for camera movement right.
  37547. */
  37548. keysRight: number[];
  37549. /**
  37550. * Event raised when the camera collides with a mesh in the scene.
  37551. */
  37552. onCollide: (collidedMesh: AbstractMesh) => void;
  37553. private _collider;
  37554. private _needMoveForGravity;
  37555. private _oldPosition;
  37556. private _diffPosition;
  37557. private _newPosition;
  37558. /** @hidden */
  37559. _localDirection: Vector3;
  37560. /** @hidden */
  37561. _transformedDirection: Vector3;
  37562. /**
  37563. * Instantiates a FlyCamera.
  37564. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37565. * such as in a 3D Space Shooter or a Flight Simulator.
  37566. * @param name Define the name of the camera in the scene.
  37567. * @param position Define the starting position of the camera in the scene.
  37568. * @param scene Define the scene the camera belongs to.
  37569. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37570. */
  37571. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37572. /**
  37573. * Attach a control to the HTML DOM element.
  37574. * @param element Defines the element that listens to the input events.
  37575. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37576. */
  37577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37578. /**
  37579. * Detach a control from the HTML DOM element.
  37580. * The camera will stop reacting to that input.
  37581. * @param element Defines the element that listens to the input events.
  37582. */
  37583. detachControl(element: HTMLElement): void;
  37584. private _collisionMask;
  37585. /**
  37586. * Get the mask that the camera ignores in collision events.
  37587. */
  37588. /**
  37589. * Set the mask that the camera ignores in collision events.
  37590. */
  37591. collisionMask: number;
  37592. /** @hidden */
  37593. _collideWithWorld(displacement: Vector3): void;
  37594. /** @hidden */
  37595. private _onCollisionPositionChange;
  37596. /** @hidden */
  37597. _checkInputs(): void;
  37598. /** @hidden */
  37599. _decideIfNeedsToMove(): boolean;
  37600. /** @hidden */
  37601. _updatePosition(): void;
  37602. /**
  37603. * Restore the Roll to its target value at the rate specified.
  37604. * @param rate - Higher means slower restoring.
  37605. * @hidden
  37606. */
  37607. restoreRoll(rate: number): void;
  37608. /**
  37609. * Destroy the camera and release the current resources held by it.
  37610. */
  37611. dispose(): void;
  37612. /**
  37613. * Get the current object class name.
  37614. * @returns the class name.
  37615. */
  37616. getClassName(): string;
  37617. }
  37618. }
  37619. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37620. import { Nullable } from "babylonjs/types";
  37621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37622. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37623. /**
  37624. * Listen to keyboard events to control the camera.
  37625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37626. */
  37627. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37628. /**
  37629. * Defines the camera the input is attached to.
  37630. */
  37631. camera: FlyCamera;
  37632. /**
  37633. * The list of keyboard keys used to control the forward move of the camera.
  37634. */
  37635. keysForward: number[];
  37636. /**
  37637. * The list of keyboard keys used to control the backward move of the camera.
  37638. */
  37639. keysBackward: number[];
  37640. /**
  37641. * The list of keyboard keys used to control the forward move of the camera.
  37642. */
  37643. keysUp: number[];
  37644. /**
  37645. * The list of keyboard keys used to control the backward move of the camera.
  37646. */
  37647. keysDown: number[];
  37648. /**
  37649. * The list of keyboard keys used to control the right strafe move of the camera.
  37650. */
  37651. keysRight: number[];
  37652. /**
  37653. * The list of keyboard keys used to control the left strafe move of the camera.
  37654. */
  37655. keysLeft: number[];
  37656. private _keys;
  37657. private _onCanvasBlurObserver;
  37658. private _onKeyboardObserver;
  37659. private _engine;
  37660. private _scene;
  37661. /**
  37662. * Attach the input controls to a specific dom element to get the input from.
  37663. * @param element Defines the element the controls should be listened from
  37664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37665. */
  37666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37667. /**
  37668. * Detach the current controls from the specified dom element.
  37669. * @param element Defines the element to stop listening the inputs from
  37670. */
  37671. detachControl(element: Nullable<HTMLElement>): void;
  37672. /**
  37673. * Gets the class name of the current intput.
  37674. * @returns the class name
  37675. */
  37676. getClassName(): string;
  37677. /** @hidden */
  37678. _onLostFocus(e: FocusEvent): void;
  37679. /**
  37680. * Get the friendly name associated with the input class.
  37681. * @returns the input friendly name
  37682. */
  37683. getSimpleName(): string;
  37684. /**
  37685. * Update the current camera state depending on the inputs that have been used this frame.
  37686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37687. */
  37688. checkInputs(): void;
  37689. }
  37690. }
  37691. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37692. import { Nullable } from "babylonjs/types";
  37693. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37694. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37695. /**
  37696. * Manage the mouse wheel inputs to control a follow camera.
  37697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37698. */
  37699. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37700. /**
  37701. * Defines the camera the input is attached to.
  37702. */
  37703. camera: FollowCamera;
  37704. /**
  37705. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37706. */
  37707. axisControlRadius: boolean;
  37708. /**
  37709. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37710. */
  37711. axisControlHeight: boolean;
  37712. /**
  37713. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37714. */
  37715. axisControlRotation: boolean;
  37716. /**
  37717. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37718. * relation to mouseWheel events.
  37719. */
  37720. wheelPrecision: number;
  37721. /**
  37722. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37723. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37724. */
  37725. wheelDeltaPercentage: number;
  37726. private _wheel;
  37727. private _observer;
  37728. /**
  37729. * Attach the input controls to a specific dom element to get the input from.
  37730. * @param element Defines the element the controls should be listened from
  37731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37732. */
  37733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37734. /**
  37735. * Detach the current controls from the specified dom element.
  37736. * @param element Defines the element to stop listening the inputs from
  37737. */
  37738. detachControl(element: Nullable<HTMLElement>): void;
  37739. /**
  37740. * Gets the class name of the current intput.
  37741. * @returns the class name
  37742. */
  37743. getClassName(): string;
  37744. /**
  37745. * Get the friendly name associated with the input class.
  37746. * @returns the input friendly name
  37747. */
  37748. getSimpleName(): string;
  37749. }
  37750. }
  37751. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37752. import { Nullable } from "babylonjs/types";
  37753. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37754. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37755. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37756. /**
  37757. * Manage the pointers inputs to control an follow camera.
  37758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37759. */
  37760. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37761. /**
  37762. * Defines the camera the input is attached to.
  37763. */
  37764. camera: FollowCamera;
  37765. /**
  37766. * Gets the class name of the current input.
  37767. * @returns the class name
  37768. */
  37769. getClassName(): string;
  37770. /**
  37771. * Defines the pointer angular sensibility along the X axis or how fast is
  37772. * the camera rotating.
  37773. * A negative number will reverse the axis direction.
  37774. */
  37775. angularSensibilityX: number;
  37776. /**
  37777. * Defines the pointer angular sensibility along the Y axis or how fast is
  37778. * the camera rotating.
  37779. * A negative number will reverse the axis direction.
  37780. */
  37781. angularSensibilityY: number;
  37782. /**
  37783. * Defines the pointer pinch precision or how fast is the camera zooming.
  37784. * A negative number will reverse the axis direction.
  37785. */
  37786. pinchPrecision: number;
  37787. /**
  37788. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37789. * from 0.
  37790. * It defines the percentage of current camera.radius to use as delta when
  37791. * pinch zoom is used.
  37792. */
  37793. pinchDeltaPercentage: number;
  37794. /**
  37795. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37796. */
  37797. axisXControlRadius: boolean;
  37798. /**
  37799. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37800. */
  37801. axisXControlHeight: boolean;
  37802. /**
  37803. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37804. */
  37805. axisXControlRotation: boolean;
  37806. /**
  37807. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37808. */
  37809. axisYControlRadius: boolean;
  37810. /**
  37811. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37812. */
  37813. axisYControlHeight: boolean;
  37814. /**
  37815. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37816. */
  37817. axisYControlRotation: boolean;
  37818. /**
  37819. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37820. */
  37821. axisPinchControlRadius: boolean;
  37822. /**
  37823. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37824. */
  37825. axisPinchControlHeight: boolean;
  37826. /**
  37827. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37828. */
  37829. axisPinchControlRotation: boolean;
  37830. /**
  37831. * Log error messages if basic misconfiguration has occurred.
  37832. */
  37833. warningEnable: boolean;
  37834. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37835. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37836. private _warningCounter;
  37837. private _warning;
  37838. }
  37839. }
  37840. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37841. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37842. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37843. /**
  37844. * Default Inputs manager for the FollowCamera.
  37845. * It groups all the default supported inputs for ease of use.
  37846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37847. */
  37848. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37849. /**
  37850. * Instantiates a new FollowCameraInputsManager.
  37851. * @param camera Defines the camera the inputs belong to
  37852. */
  37853. constructor(camera: FollowCamera);
  37854. /**
  37855. * Add keyboard input support to the input manager.
  37856. * @returns the current input manager
  37857. */
  37858. addKeyboard(): FollowCameraInputsManager;
  37859. /**
  37860. * Add mouse wheel input support to the input manager.
  37861. * @returns the current input manager
  37862. */
  37863. addMouseWheel(): FollowCameraInputsManager;
  37864. /**
  37865. * Add pointers input support to the input manager.
  37866. * @returns the current input manager
  37867. */
  37868. addPointers(): FollowCameraInputsManager;
  37869. /**
  37870. * Add orientation input support to the input manager.
  37871. * @returns the current input manager
  37872. */
  37873. addVRDeviceOrientation(): FollowCameraInputsManager;
  37874. }
  37875. }
  37876. declare module "babylonjs/Cameras/followCamera" {
  37877. import { Nullable } from "babylonjs/types";
  37878. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37879. import { Scene } from "babylonjs/scene";
  37880. import { Vector3 } from "babylonjs/Maths/math";
  37881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37882. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37883. /**
  37884. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37885. * an arc rotate version arcFollowCamera are available.
  37886. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37887. */
  37888. export class FollowCamera extends TargetCamera {
  37889. /**
  37890. * Distance the follow camera should follow an object at
  37891. */
  37892. radius: number;
  37893. /**
  37894. * Minimum allowed distance of the camera to the axis of rotation
  37895. * (The camera can not get closer).
  37896. * This can help limiting how the Camera is able to move in the scene.
  37897. */
  37898. lowerRadiusLimit: Nullable<number>;
  37899. /**
  37900. * Maximum allowed distance of the camera to the axis of rotation
  37901. * (The camera can not get further).
  37902. * This can help limiting how the Camera is able to move in the scene.
  37903. */
  37904. upperRadiusLimit: Nullable<number>;
  37905. /**
  37906. * Define a rotation offset between the camera and the object it follows
  37907. */
  37908. rotationOffset: number;
  37909. /**
  37910. * Minimum allowed angle to camera position relative to target object.
  37911. * This can help limiting how the Camera is able to move in the scene.
  37912. */
  37913. lowerRotationOffsetLimit: Nullable<number>;
  37914. /**
  37915. * Maximum allowed angle to camera position relative to target object.
  37916. * This can help limiting how the Camera is able to move in the scene.
  37917. */
  37918. upperRotationOffsetLimit: Nullable<number>;
  37919. /**
  37920. * Define a height offset between the camera and the object it follows.
  37921. * It can help following an object from the top (like a car chaing a plane)
  37922. */
  37923. heightOffset: number;
  37924. /**
  37925. * Minimum allowed height of camera position relative to target object.
  37926. * This can help limiting how the Camera is able to move in the scene.
  37927. */
  37928. lowerHeightOffsetLimit: Nullable<number>;
  37929. /**
  37930. * Maximum allowed height of camera position relative to target object.
  37931. * This can help limiting how the Camera is able to move in the scene.
  37932. */
  37933. upperHeightOffsetLimit: Nullable<number>;
  37934. /**
  37935. * Define how fast the camera can accelerate to follow it s target.
  37936. */
  37937. cameraAcceleration: number;
  37938. /**
  37939. * Define the speed limit of the camera following an object.
  37940. */
  37941. maxCameraSpeed: number;
  37942. /**
  37943. * Define the target of the camera.
  37944. */
  37945. lockedTarget: Nullable<AbstractMesh>;
  37946. /**
  37947. * Defines the input associated with the camera.
  37948. */
  37949. inputs: FollowCameraInputsManager;
  37950. /**
  37951. * Instantiates the follow camera.
  37952. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37953. * @param name Define the name of the camera in the scene
  37954. * @param position Define the position of the camera
  37955. * @param scene Define the scene the camera belong to
  37956. * @param lockedTarget Define the target of the camera
  37957. */
  37958. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37959. private _follow;
  37960. /**
  37961. * Attached controls to the current camera.
  37962. * @param element Defines the element the controls should be listened from
  37963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37964. */
  37965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37966. /**
  37967. * Detach the current controls from the camera.
  37968. * The camera will stop reacting to inputs.
  37969. * @param element Defines the element to stop listening the inputs from
  37970. */
  37971. detachControl(element: HTMLElement): void;
  37972. /** @hidden */
  37973. _checkInputs(): void;
  37974. private _checkLimits;
  37975. /**
  37976. * Gets the camera class name.
  37977. * @returns the class name
  37978. */
  37979. getClassName(): string;
  37980. }
  37981. /**
  37982. * Arc Rotate version of the follow camera.
  37983. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37985. */
  37986. export class ArcFollowCamera extends TargetCamera {
  37987. /** The longitudinal angle of the camera */
  37988. alpha: number;
  37989. /** The latitudinal angle of the camera */
  37990. beta: number;
  37991. /** The radius of the camera from its target */
  37992. radius: number;
  37993. /** Define the camera target (the messh it should follow) */
  37994. target: Nullable<AbstractMesh>;
  37995. private _cartesianCoordinates;
  37996. /**
  37997. * Instantiates a new ArcFollowCamera
  37998. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37999. * @param name Define the name of the camera
  38000. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38001. * @param beta Define the rotation angle of the camera around the elevation axis
  38002. * @param radius Define the radius of the camera from its target point
  38003. * @param target Define the target of the camera
  38004. * @param scene Define the scene the camera belongs to
  38005. */
  38006. constructor(name: string,
  38007. /** The longitudinal angle of the camera */
  38008. alpha: number,
  38009. /** The latitudinal angle of the camera */
  38010. beta: number,
  38011. /** The radius of the camera from its target */
  38012. radius: number,
  38013. /** Define the camera target (the messh it should follow) */
  38014. target: Nullable<AbstractMesh>, scene: Scene);
  38015. private _follow;
  38016. /** @hidden */
  38017. _checkInputs(): void;
  38018. /**
  38019. * Returns the class name of the object.
  38020. * It is mostly used internally for serialization purposes.
  38021. */
  38022. getClassName(): string;
  38023. }
  38024. }
  38025. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38027. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38028. import { Nullable } from "babylonjs/types";
  38029. /**
  38030. * Manage the keyboard inputs to control the movement of a follow camera.
  38031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38032. */
  38033. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38034. /**
  38035. * Defines the camera the input is attached to.
  38036. */
  38037. camera: FollowCamera;
  38038. /**
  38039. * Defines the list of key codes associated with the up action (increase heightOffset)
  38040. */
  38041. keysHeightOffsetIncr: number[];
  38042. /**
  38043. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38044. */
  38045. keysHeightOffsetDecr: number[];
  38046. /**
  38047. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38048. */
  38049. keysHeightOffsetModifierAlt: boolean;
  38050. /**
  38051. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38052. */
  38053. keysHeightOffsetModifierCtrl: boolean;
  38054. /**
  38055. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38056. */
  38057. keysHeightOffsetModifierShift: boolean;
  38058. /**
  38059. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38060. */
  38061. keysRotationOffsetIncr: number[];
  38062. /**
  38063. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38064. */
  38065. keysRotationOffsetDecr: number[];
  38066. /**
  38067. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38068. */
  38069. keysRotationOffsetModifierAlt: boolean;
  38070. /**
  38071. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38072. */
  38073. keysRotationOffsetModifierCtrl: boolean;
  38074. /**
  38075. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38076. */
  38077. keysRotationOffsetModifierShift: boolean;
  38078. /**
  38079. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38080. */
  38081. keysRadiusIncr: number[];
  38082. /**
  38083. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38084. */
  38085. keysRadiusDecr: number[];
  38086. /**
  38087. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38088. */
  38089. keysRadiusModifierAlt: boolean;
  38090. /**
  38091. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38092. */
  38093. keysRadiusModifierCtrl: boolean;
  38094. /**
  38095. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38096. */
  38097. keysRadiusModifierShift: boolean;
  38098. /**
  38099. * Defines the rate of change of heightOffset.
  38100. */
  38101. heightSensibility: number;
  38102. /**
  38103. * Defines the rate of change of rotationOffset.
  38104. */
  38105. rotationSensibility: number;
  38106. /**
  38107. * Defines the rate of change of radius.
  38108. */
  38109. radiusSensibility: number;
  38110. private _keys;
  38111. private _ctrlPressed;
  38112. private _altPressed;
  38113. private _shiftPressed;
  38114. private _onCanvasBlurObserver;
  38115. private _onKeyboardObserver;
  38116. private _engine;
  38117. private _scene;
  38118. /**
  38119. * Attach the input controls to a specific dom element to get the input from.
  38120. * @param element Defines the element the controls should be listened from
  38121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38122. */
  38123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38124. /**
  38125. * Detach the current controls from the specified dom element.
  38126. * @param element Defines the element to stop listening the inputs from
  38127. */
  38128. detachControl(element: Nullable<HTMLElement>): void;
  38129. /**
  38130. * Update the current camera state depending on the inputs that have been used this frame.
  38131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38132. */
  38133. checkInputs(): void;
  38134. /**
  38135. * Gets the class name of the current input.
  38136. * @returns the class name
  38137. */
  38138. getClassName(): string;
  38139. /**
  38140. * Get the friendly name associated with the input class.
  38141. * @returns the input friendly name
  38142. */
  38143. getSimpleName(): string;
  38144. /**
  38145. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38146. * allow modification of the heightOffset value.
  38147. */
  38148. private _modifierHeightOffset;
  38149. /**
  38150. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38151. * allow modification of the rotationOffset value.
  38152. */
  38153. private _modifierRotationOffset;
  38154. /**
  38155. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38156. * allow modification of the radius value.
  38157. */
  38158. private _modifierRadius;
  38159. }
  38160. }
  38161. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38162. import { Nullable } from "babylonjs/types";
  38163. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38164. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38165. import { Observable } from "babylonjs/Misc/observable";
  38166. module "babylonjs/Cameras/freeCameraInputsManager" {
  38167. interface FreeCameraInputsManager {
  38168. /**
  38169. * @hidden
  38170. */
  38171. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38172. /**
  38173. * Add orientation input support to the input manager.
  38174. * @returns the current input manager
  38175. */
  38176. addDeviceOrientation(): FreeCameraInputsManager;
  38177. }
  38178. }
  38179. /**
  38180. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38181. * Screen rotation is taken into account.
  38182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38183. */
  38184. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38185. private _camera;
  38186. private _screenOrientationAngle;
  38187. private _constantTranform;
  38188. private _screenQuaternion;
  38189. private _alpha;
  38190. private _beta;
  38191. private _gamma;
  38192. /**
  38193. * @hidden
  38194. */
  38195. _onDeviceOrientationChangedObservable: Observable<void>;
  38196. /**
  38197. * Instantiates a new input
  38198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38199. */
  38200. constructor();
  38201. /**
  38202. * Define the camera controlled by the input.
  38203. */
  38204. camera: FreeCamera;
  38205. /**
  38206. * Attach the input controls to a specific dom element to get the input from.
  38207. * @param element Defines the element the controls should be listened from
  38208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38209. */
  38210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38211. private _orientationChanged;
  38212. private _deviceOrientation;
  38213. /**
  38214. * Detach the current controls from the specified dom element.
  38215. * @param element Defines the element to stop listening the inputs from
  38216. */
  38217. detachControl(element: Nullable<HTMLElement>): void;
  38218. /**
  38219. * Update the current camera state depending on the inputs that have been used this frame.
  38220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38221. */
  38222. checkInputs(): void;
  38223. /**
  38224. * Gets the class name of the current intput.
  38225. * @returns the class name
  38226. */
  38227. getClassName(): string;
  38228. /**
  38229. * Get the friendly name associated with the input class.
  38230. * @returns the input friendly name
  38231. */
  38232. getSimpleName(): string;
  38233. }
  38234. }
  38235. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38236. import { Nullable } from "babylonjs/types";
  38237. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38238. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38239. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38240. /**
  38241. * Manage the gamepad inputs to control a free camera.
  38242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38243. */
  38244. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38245. /**
  38246. * Define the camera the input is attached to.
  38247. */
  38248. camera: FreeCamera;
  38249. /**
  38250. * Define the Gamepad controlling the input
  38251. */
  38252. gamepad: Nullable<Gamepad>;
  38253. /**
  38254. * Defines the gamepad rotation sensiblity.
  38255. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38256. */
  38257. gamepadAngularSensibility: number;
  38258. /**
  38259. * Defines the gamepad move sensiblity.
  38260. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38261. */
  38262. gamepadMoveSensibility: number;
  38263. private _onGamepadConnectedObserver;
  38264. private _onGamepadDisconnectedObserver;
  38265. private _cameraTransform;
  38266. private _deltaTransform;
  38267. private _vector3;
  38268. private _vector2;
  38269. /**
  38270. * Attach the input controls to a specific dom element to get the input from.
  38271. * @param element Defines the element the controls should be listened from
  38272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38273. */
  38274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38275. /**
  38276. * Detach the current controls from the specified dom element.
  38277. * @param element Defines the element to stop listening the inputs from
  38278. */
  38279. detachControl(element: Nullable<HTMLElement>): void;
  38280. /**
  38281. * Update the current camera state depending on the inputs that have been used this frame.
  38282. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38283. */
  38284. checkInputs(): void;
  38285. /**
  38286. * Gets the class name of the current intput.
  38287. * @returns the class name
  38288. */
  38289. getClassName(): string;
  38290. /**
  38291. * Get the friendly name associated with the input class.
  38292. * @returns the input friendly name
  38293. */
  38294. getSimpleName(): string;
  38295. }
  38296. }
  38297. declare module "babylonjs/Misc/virtualJoystick" {
  38298. import { Nullable } from "babylonjs/types";
  38299. import { Vector3 } from "babylonjs/Maths/math";
  38300. /**
  38301. * Defines the potential axis of a Joystick
  38302. */
  38303. export enum JoystickAxis {
  38304. /** X axis */
  38305. X = 0,
  38306. /** Y axis */
  38307. Y = 1,
  38308. /** Z axis */
  38309. Z = 2
  38310. }
  38311. /**
  38312. * Class used to define virtual joystick (used in touch mode)
  38313. */
  38314. export class VirtualJoystick {
  38315. /**
  38316. * Gets or sets a boolean indicating that left and right values must be inverted
  38317. */
  38318. reverseLeftRight: boolean;
  38319. /**
  38320. * Gets or sets a boolean indicating that up and down values must be inverted
  38321. */
  38322. reverseUpDown: boolean;
  38323. /**
  38324. * Gets the offset value for the position (ie. the change of the position value)
  38325. */
  38326. deltaPosition: Vector3;
  38327. /**
  38328. * Gets a boolean indicating if the virtual joystick was pressed
  38329. */
  38330. pressed: boolean;
  38331. /**
  38332. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38333. */
  38334. static Canvas: Nullable<HTMLCanvasElement>;
  38335. private static _globalJoystickIndex;
  38336. private static vjCanvasContext;
  38337. private static vjCanvasWidth;
  38338. private static vjCanvasHeight;
  38339. private static halfWidth;
  38340. private _action;
  38341. private _axisTargetedByLeftAndRight;
  38342. private _axisTargetedByUpAndDown;
  38343. private _joystickSensibility;
  38344. private _inversedSensibility;
  38345. private _joystickPointerID;
  38346. private _joystickColor;
  38347. private _joystickPointerPos;
  38348. private _joystickPreviousPointerPos;
  38349. private _joystickPointerStartPos;
  38350. private _deltaJoystickVector;
  38351. private _leftJoystick;
  38352. private _touches;
  38353. private _onPointerDownHandlerRef;
  38354. private _onPointerMoveHandlerRef;
  38355. private _onPointerUpHandlerRef;
  38356. private _onResize;
  38357. /**
  38358. * Creates a new virtual joystick
  38359. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38360. */
  38361. constructor(leftJoystick?: boolean);
  38362. /**
  38363. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38364. * @param newJoystickSensibility defines the new sensibility
  38365. */
  38366. setJoystickSensibility(newJoystickSensibility: number): void;
  38367. private _onPointerDown;
  38368. private _onPointerMove;
  38369. private _onPointerUp;
  38370. /**
  38371. * Change the color of the virtual joystick
  38372. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38373. */
  38374. setJoystickColor(newColor: string): void;
  38375. /**
  38376. * Defines a callback to call when the joystick is touched
  38377. * @param action defines the callback
  38378. */
  38379. setActionOnTouch(action: () => any): void;
  38380. /**
  38381. * Defines which axis you'd like to control for left & right
  38382. * @param axis defines the axis to use
  38383. */
  38384. setAxisForLeftRight(axis: JoystickAxis): void;
  38385. /**
  38386. * Defines which axis you'd like to control for up & down
  38387. * @param axis defines the axis to use
  38388. */
  38389. setAxisForUpDown(axis: JoystickAxis): void;
  38390. private _drawVirtualJoystick;
  38391. /**
  38392. * Release internal HTML canvas
  38393. */
  38394. releaseCanvas(): void;
  38395. }
  38396. }
  38397. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38398. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38399. import { Nullable } from "babylonjs/types";
  38400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38401. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38402. module "babylonjs/Cameras/freeCameraInputsManager" {
  38403. interface FreeCameraInputsManager {
  38404. /**
  38405. * Add virtual joystick input support to the input manager.
  38406. * @returns the current input manager
  38407. */
  38408. addVirtualJoystick(): FreeCameraInputsManager;
  38409. }
  38410. }
  38411. /**
  38412. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38414. */
  38415. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38416. /**
  38417. * Defines the camera the input is attached to.
  38418. */
  38419. camera: FreeCamera;
  38420. private _leftjoystick;
  38421. private _rightjoystick;
  38422. /**
  38423. * Gets the left stick of the virtual joystick.
  38424. * @returns The virtual Joystick
  38425. */
  38426. getLeftJoystick(): VirtualJoystick;
  38427. /**
  38428. * Gets the right stick of the virtual joystick.
  38429. * @returns The virtual Joystick
  38430. */
  38431. getRightJoystick(): VirtualJoystick;
  38432. /**
  38433. * Update the current camera state depending on the inputs that have been used this frame.
  38434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38435. */
  38436. checkInputs(): void;
  38437. /**
  38438. * Attach the input controls to a specific dom element to get the input from.
  38439. * @param element Defines the element the controls should be listened from
  38440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38441. */
  38442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38443. /**
  38444. * Detach the current controls from the specified dom element.
  38445. * @param element Defines the element to stop listening the inputs from
  38446. */
  38447. detachControl(element: Nullable<HTMLElement>): void;
  38448. /**
  38449. * Gets the class name of the current intput.
  38450. * @returns the class name
  38451. */
  38452. getClassName(): string;
  38453. /**
  38454. * Get the friendly name associated with the input class.
  38455. * @returns the input friendly name
  38456. */
  38457. getSimpleName(): string;
  38458. }
  38459. }
  38460. declare module "babylonjs/Cameras/Inputs/index" {
  38461. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38462. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38463. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38464. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38465. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38466. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38467. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38468. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38469. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38470. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38471. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38472. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38473. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38474. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38475. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38476. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38477. }
  38478. declare module "babylonjs/Cameras/touchCamera" {
  38479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38480. import { Scene } from "babylonjs/scene";
  38481. import { Vector3 } from "babylonjs/Maths/math";
  38482. /**
  38483. * This represents a FPS type of camera controlled by touch.
  38484. * This is like a universal camera minus the Gamepad controls.
  38485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38486. */
  38487. export class TouchCamera extends FreeCamera {
  38488. /**
  38489. * Defines the touch sensibility for rotation.
  38490. * The higher the faster.
  38491. */
  38492. touchAngularSensibility: number;
  38493. /**
  38494. * Defines the touch sensibility for move.
  38495. * The higher the faster.
  38496. */
  38497. touchMoveSensibility: number;
  38498. /**
  38499. * Instantiates a new touch camera.
  38500. * This represents a FPS type of camera controlled by touch.
  38501. * This is like a universal camera minus the Gamepad controls.
  38502. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38503. * @param name Define the name of the camera in the scene
  38504. * @param position Define the start position of the camera in the scene
  38505. * @param scene Define the scene the camera belongs to
  38506. */
  38507. constructor(name: string, position: Vector3, scene: Scene);
  38508. /**
  38509. * Gets the current object class name.
  38510. * @return the class name
  38511. */
  38512. getClassName(): string;
  38513. /** @hidden */
  38514. _setupInputs(): void;
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38518. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38519. import { Scene } from "babylonjs/scene";
  38520. import { Vector3, Axis } from "babylonjs/Maths/math";
  38521. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38522. /**
  38523. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38524. * being tilted forward or back and left or right.
  38525. */
  38526. export class DeviceOrientationCamera extends FreeCamera {
  38527. private _initialQuaternion;
  38528. private _quaternionCache;
  38529. private _tmpDragQuaternion;
  38530. /**
  38531. * Creates a new device orientation camera
  38532. * @param name The name of the camera
  38533. * @param position The start position camera
  38534. * @param scene The scene the camera belongs to
  38535. */
  38536. constructor(name: string, position: Vector3, scene: Scene);
  38537. /**
  38538. * @hidden
  38539. * Disabled pointer input on first orientation sensor update (Default: true)
  38540. */
  38541. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38542. private _dragFactor;
  38543. /**
  38544. * Enabled turning on the y axis when the orientation sensor is active
  38545. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38546. */
  38547. enableHorizontalDragging(dragFactor?: number): void;
  38548. /**
  38549. * Gets the current instance class name ("DeviceOrientationCamera").
  38550. * This helps avoiding instanceof at run time.
  38551. * @returns the class name
  38552. */
  38553. getClassName(): string;
  38554. /**
  38555. * @hidden
  38556. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38557. */
  38558. _checkInputs(): void;
  38559. /**
  38560. * Reset the camera to its default orientation on the specified axis only.
  38561. * @param axis The axis to reset
  38562. */
  38563. resetToCurrentRotation(axis?: Axis): void;
  38564. }
  38565. }
  38566. declare module "babylonjs/Cameras/universalCamera" {
  38567. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38568. import { Scene } from "babylonjs/scene";
  38569. import { Vector3 } from "babylonjs/Maths/math";
  38570. /**
  38571. * 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,
  38572. * which still works and will still be found in many Playgrounds.
  38573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38574. */
  38575. export class UniversalCamera extends TouchCamera {
  38576. /**
  38577. * Defines the gamepad rotation sensiblity.
  38578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38579. */
  38580. gamepadAngularSensibility: number;
  38581. /**
  38582. * Defines the gamepad move sensiblity.
  38583. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38584. */
  38585. gamepadMoveSensibility: number;
  38586. /**
  38587. * 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,
  38588. * which still works and will still be found in many Playgrounds.
  38589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38590. * @param name Define the name of the camera in the scene
  38591. * @param position Define the start position of the camera in the scene
  38592. * @param scene Define the scene the camera belongs to
  38593. */
  38594. constructor(name: string, position: Vector3, scene: Scene);
  38595. /**
  38596. * Gets the current object class name.
  38597. * @return the class name
  38598. */
  38599. getClassName(): string;
  38600. }
  38601. }
  38602. declare module "babylonjs/Cameras/gamepadCamera" {
  38603. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38604. import { Scene } from "babylonjs/scene";
  38605. import { Vector3 } from "babylonjs/Maths/math";
  38606. /**
  38607. * This represents a FPS type of camera. This is only here for back compat purpose.
  38608. * Please use the UniversalCamera instead as both are identical.
  38609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38610. */
  38611. export class GamepadCamera extends UniversalCamera {
  38612. /**
  38613. * Instantiates a new Gamepad Camera
  38614. * This represents a FPS type of camera. This is only here for back compat purpose.
  38615. * Please use the UniversalCamera instead as both are identical.
  38616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38617. * @param name Define the name of the camera in the scene
  38618. * @param position Define the start position of the camera in the scene
  38619. * @param scene Define the scene the camera belongs to
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene);
  38622. /**
  38623. * Gets the current object class name.
  38624. * @return the class name
  38625. */
  38626. getClassName(): string;
  38627. }
  38628. }
  38629. declare module "babylonjs/Shaders/pass.fragment" {
  38630. /** @hidden */
  38631. export var passPixelShader: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module "babylonjs/Shaders/passCube.fragment" {
  38637. /** @hidden */
  38638. export var passCubePixelShader: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module "babylonjs/PostProcesses/passPostProcess" {
  38644. import { Nullable } from "babylonjs/types";
  38645. import { Camera } from "babylonjs/Cameras/camera";
  38646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38647. import { Engine } from "babylonjs/Engines/engine";
  38648. import "babylonjs/Shaders/pass.fragment";
  38649. import "babylonjs/Shaders/passCube.fragment";
  38650. /**
  38651. * PassPostProcess which produces an output the same as it's input
  38652. */
  38653. export class PassPostProcess extends PostProcess {
  38654. /**
  38655. * Creates the PassPostProcess
  38656. * @param name The name of the effect.
  38657. * @param options The required width/height ratio to downsize to before computing the render pass.
  38658. * @param camera The camera to apply the render pass to.
  38659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38660. * @param engine The engine which the post process will be applied. (default: current engine)
  38661. * @param reusable If the post process can be reused on the same frame. (default: false)
  38662. * @param textureType The type of texture to be used when performing the post processing.
  38663. * @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)
  38664. */
  38665. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38666. }
  38667. /**
  38668. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38669. */
  38670. export class PassCubePostProcess extends PostProcess {
  38671. private _face;
  38672. /**
  38673. * Gets or sets the cube face to display.
  38674. * * 0 is +X
  38675. * * 1 is -X
  38676. * * 2 is +Y
  38677. * * 3 is -Y
  38678. * * 4 is +Z
  38679. * * 5 is -Z
  38680. */
  38681. face: number;
  38682. /**
  38683. * Creates the PassCubePostProcess
  38684. * @param name The name of the effect.
  38685. * @param options The required width/height ratio to downsize to before computing the render pass.
  38686. * @param camera The camera to apply the render pass to.
  38687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38688. * @param engine The engine which the post process will be applied. (default: current engine)
  38689. * @param reusable If the post process can be reused on the same frame. (default: false)
  38690. * @param textureType The type of texture to be used when performing the post processing.
  38691. * @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)
  38692. */
  38693. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38694. }
  38695. }
  38696. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38697. /** @hidden */
  38698. export var anaglyphPixelShader: {
  38699. name: string;
  38700. shader: string;
  38701. };
  38702. }
  38703. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38704. import { Engine } from "babylonjs/Engines/engine";
  38705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38706. import { Camera } from "babylonjs/Cameras/camera";
  38707. import "babylonjs/Shaders/anaglyph.fragment";
  38708. /**
  38709. * Postprocess used to generate anaglyphic rendering
  38710. */
  38711. export class AnaglyphPostProcess extends PostProcess {
  38712. private _passedProcess;
  38713. /**
  38714. * Creates a new AnaglyphPostProcess
  38715. * @param name defines postprocess name
  38716. * @param options defines creation options or target ratio scale
  38717. * @param rigCameras defines cameras using this postprocess
  38718. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38719. * @param engine defines hosting engine
  38720. * @param reusable defines if the postprocess will be reused multiple times per frame
  38721. */
  38722. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38723. }
  38724. }
  38725. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38726. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38727. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38728. import { Scene } from "babylonjs/scene";
  38729. import { Vector3 } from "babylonjs/Maths/math";
  38730. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38731. /**
  38732. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38733. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38734. */
  38735. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38736. /**
  38737. * Creates a new AnaglyphArcRotateCamera
  38738. * @param name defines camera name
  38739. * @param alpha defines alpha angle (in radians)
  38740. * @param beta defines beta angle (in radians)
  38741. * @param radius defines radius
  38742. * @param target defines camera target
  38743. * @param interaxialDistance defines distance between each color axis
  38744. * @param scene defines the hosting scene
  38745. */
  38746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38747. /**
  38748. * Gets camera class name
  38749. * @returns AnaglyphArcRotateCamera
  38750. */
  38751. getClassName(): string;
  38752. }
  38753. }
  38754. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38755. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38756. import { Scene } from "babylonjs/scene";
  38757. import { Vector3 } from "babylonjs/Maths/math";
  38758. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38759. /**
  38760. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38761. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38762. */
  38763. export class AnaglyphFreeCamera extends FreeCamera {
  38764. /**
  38765. * Creates a new AnaglyphFreeCamera
  38766. * @param name defines camera name
  38767. * @param position defines initial position
  38768. * @param interaxialDistance defines distance between each color axis
  38769. * @param scene defines the hosting scene
  38770. */
  38771. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38772. /**
  38773. * Gets camera class name
  38774. * @returns AnaglyphFreeCamera
  38775. */
  38776. getClassName(): string;
  38777. }
  38778. }
  38779. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38780. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38781. import { Scene } from "babylonjs/scene";
  38782. import { Vector3 } from "babylonjs/Maths/math";
  38783. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38784. /**
  38785. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38786. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38787. */
  38788. export class AnaglyphGamepadCamera extends GamepadCamera {
  38789. /**
  38790. * Creates a new AnaglyphGamepadCamera
  38791. * @param name defines camera name
  38792. * @param position defines initial position
  38793. * @param interaxialDistance defines distance between each color axis
  38794. * @param scene defines the hosting scene
  38795. */
  38796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38797. /**
  38798. * Gets camera class name
  38799. * @returns AnaglyphGamepadCamera
  38800. */
  38801. getClassName(): string;
  38802. }
  38803. }
  38804. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38805. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38806. import { Scene } from "babylonjs/scene";
  38807. import { Vector3 } from "babylonjs/Maths/math";
  38808. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38809. /**
  38810. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38811. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38812. */
  38813. export class AnaglyphUniversalCamera extends UniversalCamera {
  38814. /**
  38815. * Creates a new AnaglyphUniversalCamera
  38816. * @param name defines camera name
  38817. * @param position defines initial position
  38818. * @param interaxialDistance defines distance between each color axis
  38819. * @param scene defines the hosting scene
  38820. */
  38821. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38822. /**
  38823. * Gets camera class name
  38824. * @returns AnaglyphUniversalCamera
  38825. */
  38826. getClassName(): string;
  38827. }
  38828. }
  38829. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38830. /** @hidden */
  38831. export var stereoscopicInterlacePixelShader: {
  38832. name: string;
  38833. shader: string;
  38834. };
  38835. }
  38836. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38837. import { Camera } from "babylonjs/Cameras/camera";
  38838. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38839. import { Engine } from "babylonjs/Engines/engine";
  38840. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38841. /**
  38842. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38843. */
  38844. export class StereoscopicInterlacePostProcess extends PostProcess {
  38845. private _stepSize;
  38846. private _passedProcess;
  38847. /**
  38848. * Initializes a StereoscopicInterlacePostProcess
  38849. * @param name The name of the effect.
  38850. * @param rigCameras The rig cameras to be appled to the post process
  38851. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38853. * @param engine The engine which the post process will be applied. (default: current engine)
  38854. * @param reusable If the post process can be reused on the same frame. (default: false)
  38855. */
  38856. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38857. }
  38858. }
  38859. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38860. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38862. import { Scene } from "babylonjs/scene";
  38863. import { Vector3 } from "babylonjs/Maths/math";
  38864. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38865. /**
  38866. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38867. * @see http://doc.babylonjs.com/features/cameras
  38868. */
  38869. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38870. /**
  38871. * Creates a new StereoscopicArcRotateCamera
  38872. * @param name defines camera name
  38873. * @param alpha defines alpha angle (in radians)
  38874. * @param beta defines beta angle (in radians)
  38875. * @param radius defines radius
  38876. * @param target defines camera target
  38877. * @param interaxialDistance defines distance between each color axis
  38878. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38879. * @param scene defines the hosting scene
  38880. */
  38881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38882. /**
  38883. * Gets camera class name
  38884. * @returns StereoscopicArcRotateCamera
  38885. */
  38886. getClassName(): string;
  38887. }
  38888. }
  38889. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38891. import { Scene } from "babylonjs/scene";
  38892. import { Vector3 } from "babylonjs/Maths/math";
  38893. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38894. /**
  38895. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38896. * @see http://doc.babylonjs.com/features/cameras
  38897. */
  38898. export class StereoscopicFreeCamera extends FreeCamera {
  38899. /**
  38900. * Creates a new StereoscopicFreeCamera
  38901. * @param name defines camera name
  38902. * @param position defines initial position
  38903. * @param interaxialDistance defines distance between each color axis
  38904. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38905. * @param scene defines the hosting scene
  38906. */
  38907. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38908. /**
  38909. * Gets camera class name
  38910. * @returns StereoscopicFreeCamera
  38911. */
  38912. getClassName(): string;
  38913. }
  38914. }
  38915. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38916. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38917. import { Scene } from "babylonjs/scene";
  38918. import { Vector3 } from "babylonjs/Maths/math";
  38919. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38920. /**
  38921. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38922. * @see http://doc.babylonjs.com/features/cameras
  38923. */
  38924. export class StereoscopicGamepadCamera extends GamepadCamera {
  38925. /**
  38926. * Creates a new StereoscopicGamepadCamera
  38927. * @param name defines camera name
  38928. * @param position defines initial position
  38929. * @param interaxialDistance defines distance between each color axis
  38930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38931. * @param scene defines the hosting scene
  38932. */
  38933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38934. /**
  38935. * Gets camera class name
  38936. * @returns StereoscopicGamepadCamera
  38937. */
  38938. getClassName(): string;
  38939. }
  38940. }
  38941. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38942. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38943. import { Scene } from "babylonjs/scene";
  38944. import { Vector3 } from "babylonjs/Maths/math";
  38945. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38946. /**
  38947. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38948. * @see http://doc.babylonjs.com/features/cameras
  38949. */
  38950. export class StereoscopicUniversalCamera extends UniversalCamera {
  38951. /**
  38952. * Creates a new StereoscopicUniversalCamera
  38953. * @param name defines camera name
  38954. * @param position defines initial position
  38955. * @param interaxialDistance defines distance between each color axis
  38956. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38957. * @param scene defines the hosting scene
  38958. */
  38959. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38960. /**
  38961. * Gets camera class name
  38962. * @returns StereoscopicUniversalCamera
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38971. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38975. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38976. }
  38977. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38979. import { Scene } from "babylonjs/scene";
  38980. import { Vector3 } from "babylonjs/Maths/math";
  38981. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38982. /**
  38983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38984. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38985. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38986. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38987. */
  38988. export class VirtualJoysticksCamera extends FreeCamera {
  38989. /**
  38990. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38991. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38992. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38993. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38994. * @param name Define the name of the camera in the scene
  38995. * @param position Define the start position of the camera in the scene
  38996. * @param scene Define the scene the camera belongs to
  38997. */
  38998. constructor(name: string, position: Vector3, scene: Scene);
  38999. /**
  39000. * Gets the current object class name.
  39001. * @return the class name
  39002. */
  39003. getClassName(): string;
  39004. }
  39005. }
  39006. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39007. import { Matrix } from "babylonjs/Maths/math";
  39008. /**
  39009. * This represents all the required metrics to create a VR camera.
  39010. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39011. */
  39012. export class VRCameraMetrics {
  39013. /**
  39014. * Define the horizontal resolution off the screen.
  39015. */
  39016. hResolution: number;
  39017. /**
  39018. * Define the vertical resolution off the screen.
  39019. */
  39020. vResolution: number;
  39021. /**
  39022. * Define the horizontal screen size.
  39023. */
  39024. hScreenSize: number;
  39025. /**
  39026. * Define the vertical screen size.
  39027. */
  39028. vScreenSize: number;
  39029. /**
  39030. * Define the vertical screen center position.
  39031. */
  39032. vScreenCenter: number;
  39033. /**
  39034. * Define the distance of the eyes to the screen.
  39035. */
  39036. eyeToScreenDistance: number;
  39037. /**
  39038. * Define the distance between both lenses
  39039. */
  39040. lensSeparationDistance: number;
  39041. /**
  39042. * Define the distance between both viewer's eyes.
  39043. */
  39044. interpupillaryDistance: number;
  39045. /**
  39046. * Define the distortion factor of the VR postprocess.
  39047. * Please, touch with care.
  39048. */
  39049. distortionK: number[];
  39050. /**
  39051. * Define the chromatic aberration correction factors for the VR post process.
  39052. */
  39053. chromaAbCorrection: number[];
  39054. /**
  39055. * Define the scale factor of the post process.
  39056. * The smaller the better but the slower.
  39057. */
  39058. postProcessScaleFactor: number;
  39059. /**
  39060. * Define an offset for the lens center.
  39061. */
  39062. lensCenterOffset: number;
  39063. /**
  39064. * Define if the current vr camera should compensate the distortion of the lense or not.
  39065. */
  39066. compensateDistortion: boolean;
  39067. /**
  39068. * Defines if multiview should be enabled when rendering (Default: false)
  39069. */
  39070. multiviewEnabled: boolean;
  39071. /**
  39072. * Gets the rendering aspect ratio based on the provided resolutions.
  39073. */
  39074. readonly aspectRatio: number;
  39075. /**
  39076. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39077. */
  39078. readonly aspectRatioFov: number;
  39079. /**
  39080. * @hidden
  39081. */
  39082. readonly leftHMatrix: Matrix;
  39083. /**
  39084. * @hidden
  39085. */
  39086. readonly rightHMatrix: Matrix;
  39087. /**
  39088. * @hidden
  39089. */
  39090. readonly leftPreViewMatrix: Matrix;
  39091. /**
  39092. * @hidden
  39093. */
  39094. readonly rightPreViewMatrix: Matrix;
  39095. /**
  39096. * Get the default VRMetrics based on the most generic setup.
  39097. * @returns the default vr metrics
  39098. */
  39099. static GetDefault(): VRCameraMetrics;
  39100. }
  39101. }
  39102. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39103. /** @hidden */
  39104. export var vrDistortionCorrectionPixelShader: {
  39105. name: string;
  39106. shader: string;
  39107. };
  39108. }
  39109. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39110. import { Camera } from "babylonjs/Cameras/camera";
  39111. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39113. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39114. /**
  39115. * VRDistortionCorrectionPostProcess used for mobile VR
  39116. */
  39117. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39118. private _isRightEye;
  39119. private _distortionFactors;
  39120. private _postProcessScaleFactor;
  39121. private _lensCenterOffset;
  39122. private _scaleIn;
  39123. private _scaleFactor;
  39124. private _lensCenter;
  39125. /**
  39126. * Initializes the VRDistortionCorrectionPostProcess
  39127. * @param name The name of the effect.
  39128. * @param camera The camera to apply the render pass to.
  39129. * @param isRightEye If this is for the right eye distortion
  39130. * @param vrMetrics All the required metrics for the VR camera
  39131. */
  39132. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39133. }
  39134. }
  39135. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39136. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39138. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39139. import { Scene } from "babylonjs/scene";
  39140. import { Vector3 } from "babylonjs/Maths/math";
  39141. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39142. import "babylonjs/Cameras/RigModes/vrRigMode";
  39143. /**
  39144. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39145. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39146. */
  39147. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39148. /**
  39149. * Creates a new VRDeviceOrientationArcRotateCamera
  39150. * @param name defines camera name
  39151. * @param alpha defines the camera rotation along the logitudinal axis
  39152. * @param beta defines the camera rotation along the latitudinal axis
  39153. * @param radius defines the camera distance from its target
  39154. * @param target defines the camera target
  39155. * @param scene defines the scene the camera belongs to
  39156. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39157. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39158. */
  39159. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39160. /**
  39161. * Gets camera class name
  39162. * @returns VRDeviceOrientationArcRotateCamera
  39163. */
  39164. getClassName(): string;
  39165. }
  39166. }
  39167. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39168. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39169. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39170. import { Scene } from "babylonjs/scene";
  39171. import { Vector3 } from "babylonjs/Maths/math";
  39172. import "babylonjs/Cameras/RigModes/vrRigMode";
  39173. /**
  39174. * Camera used to simulate VR rendering (based on FreeCamera)
  39175. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39176. */
  39177. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39178. /**
  39179. * Creates a new VRDeviceOrientationFreeCamera
  39180. * @param name defines camera name
  39181. * @param position defines the start position of the camera
  39182. * @param scene defines the scene the camera belongs to
  39183. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39184. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39185. */
  39186. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39187. /**
  39188. * Gets camera class name
  39189. * @returns VRDeviceOrientationFreeCamera
  39190. */
  39191. getClassName(): string;
  39192. }
  39193. }
  39194. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39195. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39196. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39197. import { Scene } from "babylonjs/scene";
  39198. import { Vector3 } from "babylonjs/Maths/math";
  39199. /**
  39200. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39201. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39202. */
  39203. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39204. /**
  39205. * Creates a new VRDeviceOrientationGamepadCamera
  39206. * @param name defines camera name
  39207. * @param position defines the start position of the camera
  39208. * @param scene defines the scene the camera belongs to
  39209. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39210. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39211. */
  39212. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39213. /**
  39214. * Gets camera class name
  39215. * @returns VRDeviceOrientationGamepadCamera
  39216. */
  39217. getClassName(): string;
  39218. }
  39219. }
  39220. declare module "babylonjs/Gamepads/xboxGamepad" {
  39221. import { Observable } from "babylonjs/Misc/observable";
  39222. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39223. /**
  39224. * Defines supported buttons for XBox360 compatible gamepads
  39225. */
  39226. export enum Xbox360Button {
  39227. /** A */
  39228. A = 0,
  39229. /** B */
  39230. B = 1,
  39231. /** X */
  39232. X = 2,
  39233. /** Y */
  39234. Y = 3,
  39235. /** Start */
  39236. Start = 4,
  39237. /** Back */
  39238. Back = 5,
  39239. /** Left button */
  39240. LB = 6,
  39241. /** Right button */
  39242. RB = 7,
  39243. /** Left stick */
  39244. LeftStick = 8,
  39245. /** Right stick */
  39246. RightStick = 9
  39247. }
  39248. /** Defines values for XBox360 DPad */
  39249. export enum Xbox360Dpad {
  39250. /** Up */
  39251. Up = 0,
  39252. /** Down */
  39253. Down = 1,
  39254. /** Left */
  39255. Left = 2,
  39256. /** Right */
  39257. Right = 3
  39258. }
  39259. /**
  39260. * Defines a XBox360 gamepad
  39261. */
  39262. export class Xbox360Pad extends Gamepad {
  39263. private _leftTrigger;
  39264. private _rightTrigger;
  39265. private _onlefttriggerchanged;
  39266. private _onrighttriggerchanged;
  39267. private _onbuttondown;
  39268. private _onbuttonup;
  39269. private _ondpaddown;
  39270. private _ondpadup;
  39271. /** Observable raised when a button is pressed */
  39272. onButtonDownObservable: Observable<Xbox360Button>;
  39273. /** Observable raised when a button is released */
  39274. onButtonUpObservable: Observable<Xbox360Button>;
  39275. /** Observable raised when a pad is pressed */
  39276. onPadDownObservable: Observable<Xbox360Dpad>;
  39277. /** Observable raised when a pad is released */
  39278. onPadUpObservable: Observable<Xbox360Dpad>;
  39279. private _buttonA;
  39280. private _buttonB;
  39281. private _buttonX;
  39282. private _buttonY;
  39283. private _buttonBack;
  39284. private _buttonStart;
  39285. private _buttonLB;
  39286. private _buttonRB;
  39287. private _buttonLeftStick;
  39288. private _buttonRightStick;
  39289. private _dPadUp;
  39290. private _dPadDown;
  39291. private _dPadLeft;
  39292. private _dPadRight;
  39293. private _isXboxOnePad;
  39294. /**
  39295. * Creates a new XBox360 gamepad object
  39296. * @param id defines the id of this gamepad
  39297. * @param index defines its index
  39298. * @param gamepad defines the internal HTML gamepad object
  39299. * @param xboxOne defines if it is a XBox One gamepad
  39300. */
  39301. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39302. /**
  39303. * Defines the callback to call when left trigger is pressed
  39304. * @param callback defines the callback to use
  39305. */
  39306. onlefttriggerchanged(callback: (value: number) => void): void;
  39307. /**
  39308. * Defines the callback to call when right trigger is pressed
  39309. * @param callback defines the callback to use
  39310. */
  39311. onrighttriggerchanged(callback: (value: number) => void): void;
  39312. /**
  39313. * Gets the left trigger value
  39314. */
  39315. /**
  39316. * Sets the left trigger value
  39317. */
  39318. leftTrigger: number;
  39319. /**
  39320. * Gets the right trigger value
  39321. */
  39322. /**
  39323. * Sets the right trigger value
  39324. */
  39325. rightTrigger: number;
  39326. /**
  39327. * Defines the callback to call when a button is pressed
  39328. * @param callback defines the callback to use
  39329. */
  39330. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39331. /**
  39332. * Defines the callback to call when a button is released
  39333. * @param callback defines the callback to use
  39334. */
  39335. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39336. /**
  39337. * Defines the callback to call when a pad is pressed
  39338. * @param callback defines the callback to use
  39339. */
  39340. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39341. /**
  39342. * Defines the callback to call when a pad is released
  39343. * @param callback defines the callback to use
  39344. */
  39345. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39346. private _setButtonValue;
  39347. private _setDPadValue;
  39348. /**
  39349. * Gets the value of the `A` button
  39350. */
  39351. /**
  39352. * Sets the value of the `A` button
  39353. */
  39354. buttonA: number;
  39355. /**
  39356. * Gets the value of the `B` button
  39357. */
  39358. /**
  39359. * Sets the value of the `B` button
  39360. */
  39361. buttonB: number;
  39362. /**
  39363. * Gets the value of the `X` button
  39364. */
  39365. /**
  39366. * Sets the value of the `X` button
  39367. */
  39368. buttonX: number;
  39369. /**
  39370. * Gets the value of the `Y` button
  39371. */
  39372. /**
  39373. * Sets the value of the `Y` button
  39374. */
  39375. buttonY: number;
  39376. /**
  39377. * Gets the value of the `Start` button
  39378. */
  39379. /**
  39380. * Sets the value of the `Start` button
  39381. */
  39382. buttonStart: number;
  39383. /**
  39384. * Gets the value of the `Back` button
  39385. */
  39386. /**
  39387. * Sets the value of the `Back` button
  39388. */
  39389. buttonBack: number;
  39390. /**
  39391. * Gets the value of the `Left` button
  39392. */
  39393. /**
  39394. * Sets the value of the `Left` button
  39395. */
  39396. buttonLB: number;
  39397. /**
  39398. * Gets the value of the `Right` button
  39399. */
  39400. /**
  39401. * Sets the value of the `Right` button
  39402. */
  39403. buttonRB: number;
  39404. /**
  39405. * Gets the value of the Left joystick
  39406. */
  39407. /**
  39408. * Sets the value of the Left joystick
  39409. */
  39410. buttonLeftStick: number;
  39411. /**
  39412. * Gets the value of the Right joystick
  39413. */
  39414. /**
  39415. * Sets the value of the Right joystick
  39416. */
  39417. buttonRightStick: number;
  39418. /**
  39419. * Gets the value of D-pad up
  39420. */
  39421. /**
  39422. * Sets the value of D-pad up
  39423. */
  39424. dPadUp: number;
  39425. /**
  39426. * Gets the value of D-pad down
  39427. */
  39428. /**
  39429. * Sets the value of D-pad down
  39430. */
  39431. dPadDown: number;
  39432. /**
  39433. * Gets the value of D-pad left
  39434. */
  39435. /**
  39436. * Sets the value of D-pad left
  39437. */
  39438. dPadLeft: number;
  39439. /**
  39440. * Gets the value of D-pad right
  39441. */
  39442. /**
  39443. * Sets the value of D-pad right
  39444. */
  39445. dPadRight: number;
  39446. /**
  39447. * Force the gamepad to synchronize with device values
  39448. */
  39449. update(): void;
  39450. /**
  39451. * Disposes the gamepad
  39452. */
  39453. dispose(): void;
  39454. }
  39455. }
  39456. declare module "babylonjs/Materials/pushMaterial" {
  39457. import { Nullable } from "babylonjs/types";
  39458. import { Scene } from "babylonjs/scene";
  39459. import { Matrix } from "babylonjs/Maths/math";
  39460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39461. import { Mesh } from "babylonjs/Meshes/mesh";
  39462. import { Material } from "babylonjs/Materials/material";
  39463. import { Effect } from "babylonjs/Materials/effect";
  39464. /**
  39465. * Base class of materials working in push mode in babylon JS
  39466. * @hidden
  39467. */
  39468. export class PushMaterial extends Material {
  39469. protected _activeEffect: Effect;
  39470. protected _normalMatrix: Matrix;
  39471. /**
  39472. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39473. * This means that the material can keep using a previous shader while a new one is being compiled.
  39474. * This is mostly used when shader parallel compilation is supported (true by default)
  39475. */
  39476. allowShaderHotSwapping: boolean;
  39477. constructor(name: string, scene: Scene);
  39478. getEffect(): Effect;
  39479. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39480. /**
  39481. * Binds the given world matrix to the active effect
  39482. *
  39483. * @param world the matrix to bind
  39484. */
  39485. bindOnlyWorldMatrix(world: Matrix): void;
  39486. /**
  39487. * Binds the given normal matrix to the active effect
  39488. *
  39489. * @param normalMatrix the matrix to bind
  39490. */
  39491. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39492. bind(world: Matrix, mesh?: Mesh): void;
  39493. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39494. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39495. }
  39496. }
  39497. declare module "babylonjs/Materials/materialFlags" {
  39498. /**
  39499. * This groups all the flags used to control the materials channel.
  39500. */
  39501. export class MaterialFlags {
  39502. private static _DiffuseTextureEnabled;
  39503. /**
  39504. * Are diffuse textures enabled in the application.
  39505. */
  39506. static DiffuseTextureEnabled: boolean;
  39507. private static _AmbientTextureEnabled;
  39508. /**
  39509. * Are ambient textures enabled in the application.
  39510. */
  39511. static AmbientTextureEnabled: boolean;
  39512. private static _OpacityTextureEnabled;
  39513. /**
  39514. * Are opacity textures enabled in the application.
  39515. */
  39516. static OpacityTextureEnabled: boolean;
  39517. private static _ReflectionTextureEnabled;
  39518. /**
  39519. * Are reflection textures enabled in the application.
  39520. */
  39521. static ReflectionTextureEnabled: boolean;
  39522. private static _EmissiveTextureEnabled;
  39523. /**
  39524. * Are emissive textures enabled in the application.
  39525. */
  39526. static EmissiveTextureEnabled: boolean;
  39527. private static _SpecularTextureEnabled;
  39528. /**
  39529. * Are specular textures enabled in the application.
  39530. */
  39531. static SpecularTextureEnabled: boolean;
  39532. private static _BumpTextureEnabled;
  39533. /**
  39534. * Are bump textures enabled in the application.
  39535. */
  39536. static BumpTextureEnabled: boolean;
  39537. private static _LightmapTextureEnabled;
  39538. /**
  39539. * Are lightmap textures enabled in the application.
  39540. */
  39541. static LightmapTextureEnabled: boolean;
  39542. private static _RefractionTextureEnabled;
  39543. /**
  39544. * Are refraction textures enabled in the application.
  39545. */
  39546. static RefractionTextureEnabled: boolean;
  39547. private static _ColorGradingTextureEnabled;
  39548. /**
  39549. * Are color grading textures enabled in the application.
  39550. */
  39551. static ColorGradingTextureEnabled: boolean;
  39552. private static _FresnelEnabled;
  39553. /**
  39554. * Are fresnels enabled in the application.
  39555. */
  39556. static FresnelEnabled: boolean;
  39557. private static _ClearCoatTextureEnabled;
  39558. /**
  39559. * Are clear coat textures enabled in the application.
  39560. */
  39561. static ClearCoatTextureEnabled: boolean;
  39562. private static _ClearCoatBumpTextureEnabled;
  39563. /**
  39564. * Are clear coat bump textures enabled in the application.
  39565. */
  39566. static ClearCoatBumpTextureEnabled: boolean;
  39567. private static _ClearCoatTintTextureEnabled;
  39568. /**
  39569. * Are clear coat tint textures enabled in the application.
  39570. */
  39571. static ClearCoatTintTextureEnabled: boolean;
  39572. private static _SheenTextureEnabled;
  39573. /**
  39574. * Are sheen textures enabled in the application.
  39575. */
  39576. static SheenTextureEnabled: boolean;
  39577. private static _AnisotropicTextureEnabled;
  39578. /**
  39579. * Are anisotropic textures enabled in the application.
  39580. */
  39581. static AnisotropicTextureEnabled: boolean;
  39582. private static _ThicknessTextureEnabled;
  39583. /**
  39584. * Are thickness textures enabled in the application.
  39585. */
  39586. static ThicknessTextureEnabled: boolean;
  39587. }
  39588. }
  39589. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39590. /** @hidden */
  39591. export var defaultFragmentDeclaration: {
  39592. name: string;
  39593. shader: string;
  39594. };
  39595. }
  39596. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39597. /** @hidden */
  39598. export var defaultUboDeclaration: {
  39599. name: string;
  39600. shader: string;
  39601. };
  39602. }
  39603. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39604. /** @hidden */
  39605. export var lightFragmentDeclaration: {
  39606. name: string;
  39607. shader: string;
  39608. };
  39609. }
  39610. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39611. /** @hidden */
  39612. export var lightUboDeclaration: {
  39613. name: string;
  39614. shader: string;
  39615. };
  39616. }
  39617. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39618. /** @hidden */
  39619. export var lightsFragmentFunctions: {
  39620. name: string;
  39621. shader: string;
  39622. };
  39623. }
  39624. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39625. /** @hidden */
  39626. export var shadowsFragmentFunctions: {
  39627. name: string;
  39628. shader: string;
  39629. };
  39630. }
  39631. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39632. /** @hidden */
  39633. export var fresnelFunction: {
  39634. name: string;
  39635. shader: string;
  39636. };
  39637. }
  39638. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39639. /** @hidden */
  39640. export var reflectionFunction: {
  39641. name: string;
  39642. shader: string;
  39643. };
  39644. }
  39645. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39646. /** @hidden */
  39647. export var bumpFragmentFunctions: {
  39648. name: string;
  39649. shader: string;
  39650. };
  39651. }
  39652. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39653. /** @hidden */
  39654. export var logDepthDeclaration: {
  39655. name: string;
  39656. shader: string;
  39657. };
  39658. }
  39659. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39660. /** @hidden */
  39661. export var bumpFragment: {
  39662. name: string;
  39663. shader: string;
  39664. };
  39665. }
  39666. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39667. /** @hidden */
  39668. export var depthPrePass: {
  39669. name: string;
  39670. shader: string;
  39671. };
  39672. }
  39673. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39674. /** @hidden */
  39675. export var lightFragment: {
  39676. name: string;
  39677. shader: string;
  39678. };
  39679. }
  39680. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39681. /** @hidden */
  39682. export var logDepthFragment: {
  39683. name: string;
  39684. shader: string;
  39685. };
  39686. }
  39687. declare module "babylonjs/Shaders/default.fragment" {
  39688. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39689. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39690. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39691. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39692. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39693. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39694. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39695. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39696. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39697. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39698. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39699. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39700. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39701. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39702. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39704. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39705. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39706. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39707. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39708. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39709. /** @hidden */
  39710. export var defaultPixelShader: {
  39711. name: string;
  39712. shader: string;
  39713. };
  39714. }
  39715. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39716. /** @hidden */
  39717. export var defaultVertexDeclaration: {
  39718. name: string;
  39719. shader: string;
  39720. };
  39721. }
  39722. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39723. /** @hidden */
  39724. export var bumpVertexDeclaration: {
  39725. name: string;
  39726. shader: string;
  39727. };
  39728. }
  39729. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39730. /** @hidden */
  39731. export var bumpVertex: {
  39732. name: string;
  39733. shader: string;
  39734. };
  39735. }
  39736. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39737. /** @hidden */
  39738. export var fogVertex: {
  39739. name: string;
  39740. shader: string;
  39741. };
  39742. }
  39743. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39744. /** @hidden */
  39745. export var shadowsVertex: {
  39746. name: string;
  39747. shader: string;
  39748. };
  39749. }
  39750. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39751. /** @hidden */
  39752. export var pointCloudVertex: {
  39753. name: string;
  39754. shader: string;
  39755. };
  39756. }
  39757. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39758. /** @hidden */
  39759. export var logDepthVertex: {
  39760. name: string;
  39761. shader: string;
  39762. };
  39763. }
  39764. declare module "babylonjs/Shaders/default.vertex" {
  39765. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39766. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39768. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39769. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39770. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39772. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39773. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39774. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39775. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39777. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39779. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39780. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39781. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39782. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39783. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39784. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39785. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39786. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39787. /** @hidden */
  39788. export var defaultVertexShader: {
  39789. name: string;
  39790. shader: string;
  39791. };
  39792. }
  39793. declare module "babylonjs/Materials/standardMaterial" {
  39794. import { SmartArray } from "babylonjs/Misc/smartArray";
  39795. import { IAnimatable } from "babylonjs/Misc/tools";
  39796. import { Nullable } from "babylonjs/types";
  39797. import { Scene } from "babylonjs/scene";
  39798. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39801. import { Mesh } from "babylonjs/Meshes/mesh";
  39802. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39803. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39804. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39805. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39806. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39809. import "babylonjs/Shaders/default.fragment";
  39810. import "babylonjs/Shaders/default.vertex";
  39811. /** @hidden */
  39812. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39813. MAINUV1: boolean;
  39814. MAINUV2: boolean;
  39815. DIFFUSE: boolean;
  39816. DIFFUSEDIRECTUV: number;
  39817. AMBIENT: boolean;
  39818. AMBIENTDIRECTUV: number;
  39819. OPACITY: boolean;
  39820. OPACITYDIRECTUV: number;
  39821. OPACITYRGB: boolean;
  39822. REFLECTION: boolean;
  39823. EMISSIVE: boolean;
  39824. EMISSIVEDIRECTUV: number;
  39825. SPECULAR: boolean;
  39826. SPECULARDIRECTUV: number;
  39827. BUMP: boolean;
  39828. BUMPDIRECTUV: number;
  39829. PARALLAX: boolean;
  39830. PARALLAXOCCLUSION: boolean;
  39831. SPECULAROVERALPHA: boolean;
  39832. CLIPPLANE: boolean;
  39833. CLIPPLANE2: boolean;
  39834. CLIPPLANE3: boolean;
  39835. CLIPPLANE4: boolean;
  39836. ALPHATEST: boolean;
  39837. DEPTHPREPASS: boolean;
  39838. ALPHAFROMDIFFUSE: boolean;
  39839. POINTSIZE: boolean;
  39840. FOG: boolean;
  39841. SPECULARTERM: boolean;
  39842. DIFFUSEFRESNEL: boolean;
  39843. OPACITYFRESNEL: boolean;
  39844. REFLECTIONFRESNEL: boolean;
  39845. REFRACTIONFRESNEL: boolean;
  39846. EMISSIVEFRESNEL: boolean;
  39847. FRESNEL: boolean;
  39848. NORMAL: boolean;
  39849. UV1: boolean;
  39850. UV2: boolean;
  39851. VERTEXCOLOR: boolean;
  39852. VERTEXALPHA: boolean;
  39853. NUM_BONE_INFLUENCERS: number;
  39854. BonesPerMesh: number;
  39855. BONETEXTURE: boolean;
  39856. INSTANCES: boolean;
  39857. GLOSSINESS: boolean;
  39858. ROUGHNESS: boolean;
  39859. EMISSIVEASILLUMINATION: boolean;
  39860. LINKEMISSIVEWITHDIFFUSE: boolean;
  39861. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39862. LIGHTMAP: boolean;
  39863. LIGHTMAPDIRECTUV: number;
  39864. OBJECTSPACE_NORMALMAP: boolean;
  39865. USELIGHTMAPASSHADOWMAP: boolean;
  39866. REFLECTIONMAP_3D: boolean;
  39867. REFLECTIONMAP_SPHERICAL: boolean;
  39868. REFLECTIONMAP_PLANAR: boolean;
  39869. REFLECTIONMAP_CUBIC: boolean;
  39870. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39871. REFLECTIONMAP_PROJECTION: boolean;
  39872. REFLECTIONMAP_SKYBOX: boolean;
  39873. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39874. REFLECTIONMAP_EXPLICIT: boolean;
  39875. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39876. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39877. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39878. INVERTCUBICMAP: boolean;
  39879. LOGARITHMICDEPTH: boolean;
  39880. REFRACTION: boolean;
  39881. REFRACTIONMAP_3D: boolean;
  39882. REFLECTIONOVERALPHA: boolean;
  39883. TWOSIDEDLIGHTING: boolean;
  39884. SHADOWFLOAT: boolean;
  39885. MORPHTARGETS: boolean;
  39886. MORPHTARGETS_NORMAL: boolean;
  39887. MORPHTARGETS_TANGENT: boolean;
  39888. NUM_MORPH_INFLUENCERS: number;
  39889. NONUNIFORMSCALING: boolean;
  39890. PREMULTIPLYALPHA: boolean;
  39891. IMAGEPROCESSING: boolean;
  39892. VIGNETTE: boolean;
  39893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39894. VIGNETTEBLENDMODEOPAQUE: boolean;
  39895. TONEMAPPING: boolean;
  39896. TONEMAPPING_ACES: boolean;
  39897. CONTRAST: boolean;
  39898. COLORCURVES: boolean;
  39899. COLORGRADING: boolean;
  39900. COLORGRADING3D: boolean;
  39901. SAMPLER3DGREENDEPTH: boolean;
  39902. SAMPLER3DBGRMAP: boolean;
  39903. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39904. MULTIVIEW: boolean;
  39905. /**
  39906. * If the reflection texture on this material is in linear color space
  39907. * @hidden
  39908. */
  39909. IS_REFLECTION_LINEAR: boolean;
  39910. /**
  39911. * If the refraction texture on this material is in linear color space
  39912. * @hidden
  39913. */
  39914. IS_REFRACTION_LINEAR: boolean;
  39915. EXPOSURE: boolean;
  39916. constructor();
  39917. setReflectionMode(modeToEnable: string): void;
  39918. }
  39919. /**
  39920. * This is the default material used in Babylon. It is the best trade off between quality
  39921. * and performances.
  39922. * @see http://doc.babylonjs.com/babylon101/materials
  39923. */
  39924. export class StandardMaterial extends PushMaterial {
  39925. private _diffuseTexture;
  39926. /**
  39927. * The basic texture of the material as viewed under a light.
  39928. */
  39929. diffuseTexture: Nullable<BaseTexture>;
  39930. private _ambientTexture;
  39931. /**
  39932. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39933. */
  39934. ambientTexture: Nullable<BaseTexture>;
  39935. private _opacityTexture;
  39936. /**
  39937. * Define the transparency of the material from a texture.
  39938. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39939. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39940. */
  39941. opacityTexture: Nullable<BaseTexture>;
  39942. private _reflectionTexture;
  39943. /**
  39944. * Define the texture used to display the reflection.
  39945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39946. */
  39947. reflectionTexture: Nullable<BaseTexture>;
  39948. private _emissiveTexture;
  39949. /**
  39950. * Define texture of the material as if self lit.
  39951. * This will be mixed in the final result even in the absence of light.
  39952. */
  39953. emissiveTexture: Nullable<BaseTexture>;
  39954. private _specularTexture;
  39955. /**
  39956. * Define how the color and intensity of the highlight given by the light in the material.
  39957. */
  39958. specularTexture: Nullable<BaseTexture>;
  39959. private _bumpTexture;
  39960. /**
  39961. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39962. * 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.
  39963. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39964. */
  39965. bumpTexture: Nullable<BaseTexture>;
  39966. private _lightmapTexture;
  39967. /**
  39968. * Complex lighting can be computationally expensive to compute at runtime.
  39969. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39970. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39971. */
  39972. lightmapTexture: Nullable<BaseTexture>;
  39973. private _refractionTexture;
  39974. /**
  39975. * Define the texture used to display the refraction.
  39976. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39977. */
  39978. refractionTexture: Nullable<BaseTexture>;
  39979. /**
  39980. * The color of the material lit by the environmental background lighting.
  39981. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39982. */
  39983. ambientColor: Color3;
  39984. /**
  39985. * The basic color of the material as viewed under a light.
  39986. */
  39987. diffuseColor: Color3;
  39988. /**
  39989. * Define how the color and intensity of the highlight given by the light in the material.
  39990. */
  39991. specularColor: Color3;
  39992. /**
  39993. * Define the color of the material as if self lit.
  39994. * This will be mixed in the final result even in the absence of light.
  39995. */
  39996. emissiveColor: Color3;
  39997. /**
  39998. * Defines how sharp are the highlights in the material.
  39999. * The bigger the value the sharper giving a more glossy feeling to the result.
  40000. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40001. */
  40002. specularPower: number;
  40003. private _useAlphaFromDiffuseTexture;
  40004. /**
  40005. * Does the transparency come from the diffuse texture alpha channel.
  40006. */
  40007. useAlphaFromDiffuseTexture: boolean;
  40008. private _useEmissiveAsIllumination;
  40009. /**
  40010. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40011. */
  40012. useEmissiveAsIllumination: boolean;
  40013. private _linkEmissiveWithDiffuse;
  40014. /**
  40015. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40016. * the emissive level when the final color is close to one.
  40017. */
  40018. linkEmissiveWithDiffuse: boolean;
  40019. private _useSpecularOverAlpha;
  40020. /**
  40021. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40022. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40023. */
  40024. useSpecularOverAlpha: boolean;
  40025. private _useReflectionOverAlpha;
  40026. /**
  40027. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40028. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40029. */
  40030. useReflectionOverAlpha: boolean;
  40031. private _disableLighting;
  40032. /**
  40033. * Does lights from the scene impacts this material.
  40034. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40035. */
  40036. disableLighting: boolean;
  40037. private _useObjectSpaceNormalMap;
  40038. /**
  40039. * Allows using an object space normal map (instead of tangent space).
  40040. */
  40041. useObjectSpaceNormalMap: boolean;
  40042. private _useParallax;
  40043. /**
  40044. * Is parallax enabled or not.
  40045. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40046. */
  40047. useParallax: boolean;
  40048. private _useParallaxOcclusion;
  40049. /**
  40050. * Is parallax occlusion enabled or not.
  40051. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40052. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40053. */
  40054. useParallaxOcclusion: boolean;
  40055. /**
  40056. * 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.
  40057. */
  40058. parallaxScaleBias: number;
  40059. private _roughness;
  40060. /**
  40061. * Helps to define how blurry the reflections should appears in the material.
  40062. */
  40063. roughness: number;
  40064. /**
  40065. * In case of refraction, define the value of the indice of refraction.
  40066. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40067. */
  40068. indexOfRefraction: number;
  40069. /**
  40070. * Invert the refraction texture alongside the y axis.
  40071. * It can be useful with procedural textures or probe for instance.
  40072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40073. */
  40074. invertRefractionY: boolean;
  40075. /**
  40076. * Defines the alpha limits in alpha test mode.
  40077. */
  40078. alphaCutOff: number;
  40079. private _useLightmapAsShadowmap;
  40080. /**
  40081. * In case of light mapping, define whether the map contains light or shadow informations.
  40082. */
  40083. useLightmapAsShadowmap: boolean;
  40084. private _diffuseFresnelParameters;
  40085. /**
  40086. * Define the diffuse fresnel parameters of the material.
  40087. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40088. */
  40089. diffuseFresnelParameters: FresnelParameters;
  40090. private _opacityFresnelParameters;
  40091. /**
  40092. * Define the opacity fresnel parameters of the material.
  40093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40094. */
  40095. opacityFresnelParameters: FresnelParameters;
  40096. private _reflectionFresnelParameters;
  40097. /**
  40098. * Define the reflection fresnel parameters of the material.
  40099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40100. */
  40101. reflectionFresnelParameters: FresnelParameters;
  40102. private _refractionFresnelParameters;
  40103. /**
  40104. * Define the refraction fresnel parameters of the material.
  40105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40106. */
  40107. refractionFresnelParameters: FresnelParameters;
  40108. private _emissiveFresnelParameters;
  40109. /**
  40110. * Define the emissive fresnel parameters of the material.
  40111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40112. */
  40113. emissiveFresnelParameters: FresnelParameters;
  40114. private _useReflectionFresnelFromSpecular;
  40115. /**
  40116. * If true automatically deducts the fresnels values from the material specularity.
  40117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40118. */
  40119. useReflectionFresnelFromSpecular: boolean;
  40120. private _useGlossinessFromSpecularMapAlpha;
  40121. /**
  40122. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40123. */
  40124. useGlossinessFromSpecularMapAlpha: boolean;
  40125. private _maxSimultaneousLights;
  40126. /**
  40127. * Defines the maximum number of lights that can be used in the material
  40128. */
  40129. maxSimultaneousLights: number;
  40130. private _invertNormalMapX;
  40131. /**
  40132. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40133. */
  40134. invertNormalMapX: boolean;
  40135. private _invertNormalMapY;
  40136. /**
  40137. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40138. */
  40139. invertNormalMapY: boolean;
  40140. private _twoSidedLighting;
  40141. /**
  40142. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40143. */
  40144. twoSidedLighting: boolean;
  40145. /**
  40146. * Default configuration related to image processing available in the standard Material.
  40147. */
  40148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40149. /**
  40150. * Gets the image processing configuration used either in this material.
  40151. */
  40152. /**
  40153. * Sets the Default image processing configuration used either in the this material.
  40154. *
  40155. * If sets to null, the scene one is in use.
  40156. */
  40157. imageProcessingConfiguration: ImageProcessingConfiguration;
  40158. /**
  40159. * Keep track of the image processing observer to allow dispose and replace.
  40160. */
  40161. private _imageProcessingObserver;
  40162. /**
  40163. * Attaches a new image processing configuration to the Standard Material.
  40164. * @param configuration
  40165. */
  40166. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40167. /**
  40168. * Gets wether the color curves effect is enabled.
  40169. */
  40170. /**
  40171. * Sets wether the color curves effect is enabled.
  40172. */
  40173. cameraColorCurvesEnabled: boolean;
  40174. /**
  40175. * Gets wether the color grading effect is enabled.
  40176. */
  40177. /**
  40178. * Gets wether the color grading effect is enabled.
  40179. */
  40180. cameraColorGradingEnabled: boolean;
  40181. /**
  40182. * Gets wether tonemapping is enabled or not.
  40183. */
  40184. /**
  40185. * Sets wether tonemapping is enabled or not
  40186. */
  40187. cameraToneMappingEnabled: boolean;
  40188. /**
  40189. * The camera exposure used on this material.
  40190. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40191. * This corresponds to a photographic exposure.
  40192. */
  40193. /**
  40194. * The camera exposure used on this material.
  40195. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40196. * This corresponds to a photographic exposure.
  40197. */
  40198. cameraExposure: number;
  40199. /**
  40200. * Gets The camera contrast used on this material.
  40201. */
  40202. /**
  40203. * Sets The camera contrast used on this material.
  40204. */
  40205. cameraContrast: number;
  40206. /**
  40207. * Gets the Color Grading 2D Lookup Texture.
  40208. */
  40209. /**
  40210. * Sets the Color Grading 2D Lookup Texture.
  40211. */
  40212. cameraColorGradingTexture: Nullable<BaseTexture>;
  40213. /**
  40214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40216. * 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;
  40217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40218. */
  40219. /**
  40220. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40221. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40222. * 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;
  40223. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40224. */
  40225. cameraColorCurves: Nullable<ColorCurves>;
  40226. /**
  40227. * Custom callback helping to override the default shader used in the material.
  40228. */
  40229. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40230. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40231. protected _worldViewProjectionMatrix: Matrix;
  40232. protected _globalAmbientColor: Color3;
  40233. protected _useLogarithmicDepth: boolean;
  40234. /**
  40235. * Instantiates a new standard material.
  40236. * This is the default material used in Babylon. It is the best trade off between quality
  40237. * and performances.
  40238. * @see http://doc.babylonjs.com/babylon101/materials
  40239. * @param name Define the name of the material in the scene
  40240. * @param scene Define the scene the material belong to
  40241. */
  40242. constructor(name: string, scene: Scene);
  40243. /**
  40244. * Gets a boolean indicating that current material needs to register RTT
  40245. */
  40246. readonly hasRenderTargetTextures: boolean;
  40247. /**
  40248. * Gets the current class name of the material e.g. "StandardMaterial"
  40249. * Mainly use in serialization.
  40250. * @returns the class name
  40251. */
  40252. getClassName(): string;
  40253. /**
  40254. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40255. * You can try switching to logarithmic depth.
  40256. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40257. */
  40258. useLogarithmicDepth: boolean;
  40259. /**
  40260. * Specifies if the material will require alpha blending
  40261. * @returns a boolean specifying if alpha blending is needed
  40262. */
  40263. needAlphaBlending(): boolean;
  40264. /**
  40265. * Specifies if this material should be rendered in alpha test mode
  40266. * @returns a boolean specifying if an alpha test is needed.
  40267. */
  40268. needAlphaTesting(): boolean;
  40269. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40270. /**
  40271. * Get the texture used for alpha test purpose.
  40272. * @returns the diffuse texture in case of the standard material.
  40273. */
  40274. getAlphaTestTexture(): Nullable<BaseTexture>;
  40275. /**
  40276. * Get if the submesh is ready to be used and all its information available.
  40277. * Child classes can use it to update shaders
  40278. * @param mesh defines the mesh to check
  40279. * @param subMesh defines which submesh to check
  40280. * @param useInstances specifies that instances should be used
  40281. * @returns a boolean indicating that the submesh is ready or not
  40282. */
  40283. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40284. /**
  40285. * Builds the material UBO layouts.
  40286. * Used internally during the effect preparation.
  40287. */
  40288. buildUniformLayout(): void;
  40289. /**
  40290. * Unbinds the material from the mesh
  40291. */
  40292. unbind(): void;
  40293. /**
  40294. * Binds the submesh to this material by preparing the effect and shader to draw
  40295. * @param world defines the world transformation matrix
  40296. * @param mesh defines the mesh containing the submesh
  40297. * @param subMesh defines the submesh to bind the material to
  40298. */
  40299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40300. /**
  40301. * Get the list of animatables in the material.
  40302. * @returns the list of animatables object used in the material
  40303. */
  40304. getAnimatables(): IAnimatable[];
  40305. /**
  40306. * Gets the active textures from the material
  40307. * @returns an array of textures
  40308. */
  40309. getActiveTextures(): BaseTexture[];
  40310. /**
  40311. * Specifies if the material uses a texture
  40312. * @param texture defines the texture to check against the material
  40313. * @returns a boolean specifying if the material uses the texture
  40314. */
  40315. hasTexture(texture: BaseTexture): boolean;
  40316. /**
  40317. * Disposes the material
  40318. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40319. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40320. */
  40321. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40322. /**
  40323. * Makes a duplicate of the material, and gives it a new name
  40324. * @param name defines the new name for the duplicated material
  40325. * @returns the cloned material
  40326. */
  40327. clone(name: string): StandardMaterial;
  40328. /**
  40329. * Serializes this material in a JSON representation
  40330. * @returns the serialized material object
  40331. */
  40332. serialize(): any;
  40333. /**
  40334. * Creates a standard material from parsed material data
  40335. * @param source defines the JSON representation of the material
  40336. * @param scene defines the hosting scene
  40337. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40338. * @returns a new standard material
  40339. */
  40340. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40341. /**
  40342. * Are diffuse textures enabled in the application.
  40343. */
  40344. static DiffuseTextureEnabled: boolean;
  40345. /**
  40346. * Are ambient textures enabled in the application.
  40347. */
  40348. static AmbientTextureEnabled: boolean;
  40349. /**
  40350. * Are opacity textures enabled in the application.
  40351. */
  40352. static OpacityTextureEnabled: boolean;
  40353. /**
  40354. * Are reflection textures enabled in the application.
  40355. */
  40356. static ReflectionTextureEnabled: boolean;
  40357. /**
  40358. * Are emissive textures enabled in the application.
  40359. */
  40360. static EmissiveTextureEnabled: boolean;
  40361. /**
  40362. * Are specular textures enabled in the application.
  40363. */
  40364. static SpecularTextureEnabled: boolean;
  40365. /**
  40366. * Are bump textures enabled in the application.
  40367. */
  40368. static BumpTextureEnabled: boolean;
  40369. /**
  40370. * Are lightmap textures enabled in the application.
  40371. */
  40372. static LightmapTextureEnabled: boolean;
  40373. /**
  40374. * Are refraction textures enabled in the application.
  40375. */
  40376. static RefractionTextureEnabled: boolean;
  40377. /**
  40378. * Are color grading textures enabled in the application.
  40379. */
  40380. static ColorGradingTextureEnabled: boolean;
  40381. /**
  40382. * Are fresnels enabled in the application.
  40383. */
  40384. static FresnelEnabled: boolean;
  40385. }
  40386. }
  40387. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40388. import { Scene } from "babylonjs/scene";
  40389. import { Texture } from "babylonjs/Materials/Textures/texture";
  40390. /**
  40391. * A class extending Texture allowing drawing on a texture
  40392. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40393. */
  40394. export class DynamicTexture extends Texture {
  40395. private _generateMipMaps;
  40396. private _canvas;
  40397. private _context;
  40398. private _engine;
  40399. /**
  40400. * Creates a DynamicTexture
  40401. * @param name defines the name of the texture
  40402. * @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
  40403. * @param scene defines the scene where you want the texture
  40404. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40405. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40406. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40407. */
  40408. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40409. /**
  40410. * Get the current class name of the texture useful for serialization or dynamic coding.
  40411. * @returns "DynamicTexture"
  40412. */
  40413. getClassName(): string;
  40414. /**
  40415. * Gets the current state of canRescale
  40416. */
  40417. readonly canRescale: boolean;
  40418. private _recreate;
  40419. /**
  40420. * Scales the texture
  40421. * @param ratio the scale factor to apply to both width and height
  40422. */
  40423. scale(ratio: number): void;
  40424. /**
  40425. * Resizes the texture
  40426. * @param width the new width
  40427. * @param height the new height
  40428. */
  40429. scaleTo(width: number, height: number): void;
  40430. /**
  40431. * Gets the context of the canvas used by the texture
  40432. * @returns the canvas context of the dynamic texture
  40433. */
  40434. getContext(): CanvasRenderingContext2D;
  40435. /**
  40436. * Clears the texture
  40437. */
  40438. clear(): void;
  40439. /**
  40440. * Updates the texture
  40441. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40442. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40443. */
  40444. update(invertY?: boolean, premulAlpha?: boolean): void;
  40445. /**
  40446. * Draws text onto the texture
  40447. * @param text defines the text to be drawn
  40448. * @param x defines the placement of the text from the left
  40449. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40450. * @param font defines the font to be used with font-style, font-size, font-name
  40451. * @param color defines the color used for the text
  40452. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40453. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40454. * @param update defines whether texture is immediately update (default is true)
  40455. */
  40456. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40457. /**
  40458. * Clones the texture
  40459. * @returns the clone of the texture.
  40460. */
  40461. clone(): DynamicTexture;
  40462. /**
  40463. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40464. * @returns a serialized dynamic texture object
  40465. */
  40466. serialize(): any;
  40467. /** @hidden */
  40468. _rebuild(): void;
  40469. }
  40470. }
  40471. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40474. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40475. /** @hidden */
  40476. export var imageProcessingPixelShader: {
  40477. name: string;
  40478. shader: string;
  40479. };
  40480. }
  40481. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40482. import { Nullable } from "babylonjs/types";
  40483. import { Color4 } from "babylonjs/Maths/math";
  40484. import { Camera } from "babylonjs/Cameras/camera";
  40485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40486. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40487. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40489. import { Engine } from "babylonjs/Engines/engine";
  40490. import "babylonjs/Shaders/imageProcessing.fragment";
  40491. import "babylonjs/Shaders/postprocess.vertex";
  40492. /**
  40493. * ImageProcessingPostProcess
  40494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40495. */
  40496. export class ImageProcessingPostProcess extends PostProcess {
  40497. /**
  40498. * Default configuration related to image processing available in the PBR Material.
  40499. */
  40500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40501. /**
  40502. * Gets the image processing configuration used either in this material.
  40503. */
  40504. /**
  40505. * Sets the Default image processing configuration used either in the this material.
  40506. *
  40507. * If sets to null, the scene one is in use.
  40508. */
  40509. imageProcessingConfiguration: ImageProcessingConfiguration;
  40510. /**
  40511. * Keep track of the image processing observer to allow dispose and replace.
  40512. */
  40513. private _imageProcessingObserver;
  40514. /**
  40515. * Attaches a new image processing configuration to the PBR Material.
  40516. * @param configuration
  40517. */
  40518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40519. /**
  40520. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40521. */
  40522. /**
  40523. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40524. */
  40525. colorCurves: Nullable<ColorCurves>;
  40526. /**
  40527. * Gets wether the color curves effect is enabled.
  40528. */
  40529. /**
  40530. * Sets wether the color curves effect is enabled.
  40531. */
  40532. colorCurvesEnabled: boolean;
  40533. /**
  40534. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40535. */
  40536. /**
  40537. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40538. */
  40539. colorGradingTexture: Nullable<BaseTexture>;
  40540. /**
  40541. * Gets wether the color grading effect is enabled.
  40542. */
  40543. /**
  40544. * Gets wether the color grading effect is enabled.
  40545. */
  40546. colorGradingEnabled: boolean;
  40547. /**
  40548. * Gets exposure used in the effect.
  40549. */
  40550. /**
  40551. * Sets exposure used in the effect.
  40552. */
  40553. exposure: number;
  40554. /**
  40555. * Gets wether tonemapping is enabled or not.
  40556. */
  40557. /**
  40558. * Sets wether tonemapping is enabled or not
  40559. */
  40560. toneMappingEnabled: boolean;
  40561. /**
  40562. * Gets the type of tone mapping effect.
  40563. */
  40564. /**
  40565. * Sets the type of tone mapping effect.
  40566. */
  40567. toneMappingType: number;
  40568. /**
  40569. * Gets contrast used in the effect.
  40570. */
  40571. /**
  40572. * Sets contrast used in the effect.
  40573. */
  40574. contrast: number;
  40575. /**
  40576. * Gets Vignette stretch size.
  40577. */
  40578. /**
  40579. * Sets Vignette stretch size.
  40580. */
  40581. vignetteStretch: number;
  40582. /**
  40583. * Gets Vignette centre X Offset.
  40584. */
  40585. /**
  40586. * Sets Vignette centre X Offset.
  40587. */
  40588. vignetteCentreX: number;
  40589. /**
  40590. * Gets Vignette centre Y Offset.
  40591. */
  40592. /**
  40593. * Sets Vignette centre Y Offset.
  40594. */
  40595. vignetteCentreY: number;
  40596. /**
  40597. * Gets Vignette weight or intensity of the vignette effect.
  40598. */
  40599. /**
  40600. * Sets Vignette weight or intensity of the vignette effect.
  40601. */
  40602. vignetteWeight: number;
  40603. /**
  40604. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40605. * if vignetteEnabled is set to true.
  40606. */
  40607. /**
  40608. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40609. * if vignetteEnabled is set to true.
  40610. */
  40611. vignetteColor: Color4;
  40612. /**
  40613. * Gets Camera field of view used by the Vignette effect.
  40614. */
  40615. /**
  40616. * Sets Camera field of view used by the Vignette effect.
  40617. */
  40618. vignetteCameraFov: number;
  40619. /**
  40620. * Gets the vignette blend mode allowing different kind of effect.
  40621. */
  40622. /**
  40623. * Sets the vignette blend mode allowing different kind of effect.
  40624. */
  40625. vignetteBlendMode: number;
  40626. /**
  40627. * Gets wether the vignette effect is enabled.
  40628. */
  40629. /**
  40630. * Sets wether the vignette effect is enabled.
  40631. */
  40632. vignetteEnabled: boolean;
  40633. private _fromLinearSpace;
  40634. /**
  40635. * Gets wether the input of the processing is in Gamma or Linear Space.
  40636. */
  40637. /**
  40638. * Sets wether the input of the processing is in Gamma or Linear Space.
  40639. */
  40640. fromLinearSpace: boolean;
  40641. /**
  40642. * Defines cache preventing GC.
  40643. */
  40644. private _defines;
  40645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40646. /**
  40647. * "ImageProcessingPostProcess"
  40648. * @returns "ImageProcessingPostProcess"
  40649. */
  40650. getClassName(): string;
  40651. protected _updateParameters(): void;
  40652. dispose(camera?: Camera): void;
  40653. }
  40654. }
  40655. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40656. import { Scene } from "babylonjs/scene";
  40657. import { Color3 } from "babylonjs/Maths/math";
  40658. import { Mesh } from "babylonjs/Meshes/mesh";
  40659. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40660. import { Nullable } from "babylonjs/types";
  40661. /**
  40662. * Class containing static functions to help procedurally build meshes
  40663. */
  40664. export class GroundBuilder {
  40665. /**
  40666. * Creates a ground mesh
  40667. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40668. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40670. * @param name defines the name of the mesh
  40671. * @param options defines the options used to create the mesh
  40672. * @param scene defines the hosting scene
  40673. * @returns the ground mesh
  40674. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40675. */
  40676. static CreateGround(name: string, options: {
  40677. width?: number;
  40678. height?: number;
  40679. subdivisions?: number;
  40680. subdivisionsX?: number;
  40681. subdivisionsY?: number;
  40682. updatable?: boolean;
  40683. }, scene: any): Mesh;
  40684. /**
  40685. * Creates a tiled ground mesh
  40686. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40687. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40688. * * 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
  40689. * * 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
  40690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40691. * @param name defines the name of the mesh
  40692. * @param options defines the options used to create the mesh
  40693. * @param scene defines the hosting scene
  40694. * @returns the tiled ground mesh
  40695. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40696. */
  40697. static CreateTiledGround(name: string, options: {
  40698. xmin: number;
  40699. zmin: number;
  40700. xmax: number;
  40701. zmax: number;
  40702. subdivisions?: {
  40703. w: number;
  40704. h: number;
  40705. };
  40706. precision?: {
  40707. w: number;
  40708. h: number;
  40709. };
  40710. updatable?: boolean;
  40711. }, scene?: Nullable<Scene>): Mesh;
  40712. /**
  40713. * Creates a ground mesh from a height map
  40714. * * The parameter `url` sets the URL of the height map image resource.
  40715. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40716. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40717. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40718. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40719. * * 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.
  40720. * * 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).
  40721. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40723. * @param name defines the name of the mesh
  40724. * @param url defines the url to the height map
  40725. * @param options defines the options used to create the mesh
  40726. * @param scene defines the hosting scene
  40727. * @returns the ground mesh
  40728. * @see https://doc.babylonjs.com/babylon101/height_map
  40729. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40730. */
  40731. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40732. width?: number;
  40733. height?: number;
  40734. subdivisions?: number;
  40735. minHeight?: number;
  40736. maxHeight?: number;
  40737. colorFilter?: Color3;
  40738. alphaFilter?: number;
  40739. updatable?: boolean;
  40740. onReady?: (mesh: GroundMesh) => void;
  40741. }, scene?: Nullable<Scene>): GroundMesh;
  40742. }
  40743. }
  40744. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40745. import { Vector4 } from "babylonjs/Maths/math";
  40746. import { Mesh } from "babylonjs/Meshes/mesh";
  40747. /**
  40748. * Class containing static functions to help procedurally build meshes
  40749. */
  40750. export class TorusBuilder {
  40751. /**
  40752. * Creates a torus mesh
  40753. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40754. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40755. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40759. * @param name defines the name of the mesh
  40760. * @param options defines the options used to create the mesh
  40761. * @param scene defines the hosting scene
  40762. * @returns the torus mesh
  40763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40764. */
  40765. static CreateTorus(name: string, options: {
  40766. diameter?: number;
  40767. thickness?: number;
  40768. tessellation?: number;
  40769. updatable?: boolean;
  40770. sideOrientation?: number;
  40771. frontUVs?: Vector4;
  40772. backUVs?: Vector4;
  40773. }, scene: any): Mesh;
  40774. }
  40775. }
  40776. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40777. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40778. import { Mesh } from "babylonjs/Meshes/mesh";
  40779. /**
  40780. * Class containing static functions to help procedurally build meshes
  40781. */
  40782. export class CylinderBuilder {
  40783. /**
  40784. * Creates a cylinder or a cone mesh
  40785. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40786. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40787. * * 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.
  40788. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40789. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40790. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40791. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40792. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40793. * * 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).
  40794. * * 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
  40795. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40796. * * 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
  40797. * * 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.
  40798. * * If `enclose` is false, a ring surface is one element.
  40799. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40800. * * 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
  40801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40804. * @param name defines the name of the mesh
  40805. * @param options defines the options used to create the mesh
  40806. * @param scene defines the hosting scene
  40807. * @returns the cylinder mesh
  40808. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40809. */
  40810. static CreateCylinder(name: string, options: {
  40811. height?: number;
  40812. diameterTop?: number;
  40813. diameterBottom?: number;
  40814. diameter?: number;
  40815. tessellation?: number;
  40816. subdivisions?: number;
  40817. arc?: number;
  40818. faceColors?: Color4[];
  40819. faceUV?: Vector4[];
  40820. updatable?: boolean;
  40821. hasRings?: boolean;
  40822. enclose?: boolean;
  40823. sideOrientation?: number;
  40824. frontUVs?: Vector4;
  40825. backUVs?: Vector4;
  40826. }, scene: any): Mesh;
  40827. }
  40828. }
  40829. declare module "babylonjs/Gamepads/gamepadManager" {
  40830. import { Observable } from "babylonjs/Misc/observable";
  40831. import { Nullable } from "babylonjs/types";
  40832. import { Scene } from "babylonjs/scene";
  40833. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40834. /**
  40835. * Manager for handling gamepads
  40836. */
  40837. export class GamepadManager {
  40838. private _scene?;
  40839. private _babylonGamepads;
  40840. private _oneGamepadConnected;
  40841. /** @hidden */
  40842. _isMonitoring: boolean;
  40843. private _gamepadEventSupported;
  40844. private _gamepadSupport;
  40845. /**
  40846. * observable to be triggered when the gamepad controller has been connected
  40847. */
  40848. onGamepadConnectedObservable: Observable<Gamepad>;
  40849. /**
  40850. * observable to be triggered when the gamepad controller has been disconnected
  40851. */
  40852. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40853. private _onGamepadConnectedEvent;
  40854. private _onGamepadDisconnectedEvent;
  40855. /**
  40856. * Initializes the gamepad manager
  40857. * @param _scene BabylonJS scene
  40858. */
  40859. constructor(_scene?: Scene | undefined);
  40860. /**
  40861. * The gamepads in the game pad manager
  40862. */
  40863. readonly gamepads: Gamepad[];
  40864. /**
  40865. * Get the gamepad controllers based on type
  40866. * @param type The type of gamepad controller
  40867. * @returns Nullable gamepad
  40868. */
  40869. getGamepadByType(type?: number): Nullable<Gamepad>;
  40870. /**
  40871. * Disposes the gamepad manager
  40872. */
  40873. dispose(): void;
  40874. private _addNewGamepad;
  40875. private _startMonitoringGamepads;
  40876. private _stopMonitoringGamepads;
  40877. /** @hidden */
  40878. _checkGamepadsStatus(): void;
  40879. private _updateGamepadObjects;
  40880. }
  40881. }
  40882. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40883. import { Nullable } from "babylonjs/types";
  40884. import { Scene } from "babylonjs/scene";
  40885. import { ISceneComponent } from "babylonjs/sceneComponent";
  40886. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40887. module "babylonjs/scene" {
  40888. interface Scene {
  40889. /** @hidden */
  40890. _gamepadManager: Nullable<GamepadManager>;
  40891. /**
  40892. * Gets the gamepad manager associated with the scene
  40893. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40894. */
  40895. gamepadManager: GamepadManager;
  40896. }
  40897. }
  40898. module "babylonjs/Cameras/freeCameraInputsManager" {
  40899. /**
  40900. * Interface representing a free camera inputs manager
  40901. */
  40902. interface FreeCameraInputsManager {
  40903. /**
  40904. * Adds gamepad input support to the FreeCameraInputsManager.
  40905. * @returns the FreeCameraInputsManager
  40906. */
  40907. addGamepad(): FreeCameraInputsManager;
  40908. }
  40909. }
  40910. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40911. /**
  40912. * Interface representing an arc rotate camera inputs manager
  40913. */
  40914. interface ArcRotateCameraInputsManager {
  40915. /**
  40916. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40917. * @returns the camera inputs manager
  40918. */
  40919. addGamepad(): ArcRotateCameraInputsManager;
  40920. }
  40921. }
  40922. /**
  40923. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40924. */
  40925. export class GamepadSystemSceneComponent implements ISceneComponent {
  40926. /**
  40927. * The component name helpfull to identify the component in the list of scene components.
  40928. */
  40929. readonly name: string;
  40930. /**
  40931. * The scene the component belongs to.
  40932. */
  40933. scene: Scene;
  40934. /**
  40935. * Creates a new instance of the component for the given scene
  40936. * @param scene Defines the scene to register the component in
  40937. */
  40938. constructor(scene: Scene);
  40939. /**
  40940. * Registers the component in a given scene
  40941. */
  40942. register(): void;
  40943. /**
  40944. * Rebuilds the elements related to this component in case of
  40945. * context lost for instance.
  40946. */
  40947. rebuild(): void;
  40948. /**
  40949. * Disposes the component and the associated ressources
  40950. */
  40951. dispose(): void;
  40952. private _beforeCameraUpdate;
  40953. }
  40954. }
  40955. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40956. import { Observable } from "babylonjs/Misc/observable";
  40957. import { Nullable } from "babylonjs/types";
  40958. import { Camera } from "babylonjs/Cameras/camera";
  40959. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40960. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40961. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40962. import { Scene } from "babylonjs/scene";
  40963. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40964. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40966. import { Mesh } from "babylonjs/Meshes/mesh";
  40967. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40968. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40969. import "babylonjs/Meshes/Builders/groundBuilder";
  40970. import "babylonjs/Meshes/Builders/torusBuilder";
  40971. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40972. import "babylonjs/Gamepads/gamepadSceneComponent";
  40973. import "babylonjs/Animations/animatable";
  40974. /**
  40975. * Options to modify the vr teleportation behavior.
  40976. */
  40977. export interface VRTeleportationOptions {
  40978. /**
  40979. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40980. */
  40981. floorMeshName?: string;
  40982. /**
  40983. * A list of meshes to be used as the teleportation floor. (default: empty)
  40984. */
  40985. floorMeshes?: Mesh[];
  40986. }
  40987. /**
  40988. * Options to modify the vr experience helper's behavior.
  40989. */
  40990. export interface VRExperienceHelperOptions extends WebVROptions {
  40991. /**
  40992. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40993. */
  40994. createDeviceOrientationCamera?: boolean;
  40995. /**
  40996. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40997. */
  40998. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40999. /**
  41000. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41001. */
  41002. laserToggle?: boolean;
  41003. /**
  41004. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41005. */
  41006. floorMeshes?: Mesh[];
  41007. /**
  41008. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41009. */
  41010. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41011. }
  41012. /**
  41013. * Event containing information after VR has been entered
  41014. */
  41015. export class OnAfterEnteringVRObservableEvent {
  41016. /**
  41017. * If entering vr was successful
  41018. */
  41019. success: boolean;
  41020. }
  41021. /**
  41022. * Helps to quickly add VR support to an existing scene.
  41023. * See http://doc.babylonjs.com/how_to/webvr_helper
  41024. */
  41025. export class VRExperienceHelper {
  41026. /** Options to modify the vr experience helper's behavior. */
  41027. webVROptions: VRExperienceHelperOptions;
  41028. private _scene;
  41029. private _position;
  41030. private _btnVR;
  41031. private _btnVRDisplayed;
  41032. private _webVRsupported;
  41033. private _webVRready;
  41034. private _webVRrequesting;
  41035. private _webVRpresenting;
  41036. private _hasEnteredVR;
  41037. private _fullscreenVRpresenting;
  41038. private _canvas;
  41039. private _webVRCamera;
  41040. private _vrDeviceOrientationCamera;
  41041. private _deviceOrientationCamera;
  41042. private _existingCamera;
  41043. private _onKeyDown;
  41044. private _onVrDisplayPresentChange;
  41045. private _onVRDisplayChanged;
  41046. private _onVRRequestPresentStart;
  41047. private _onVRRequestPresentComplete;
  41048. /**
  41049. * Observable raised right before entering VR.
  41050. */
  41051. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41052. /**
  41053. * Observable raised when entering VR has completed.
  41054. */
  41055. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41056. /**
  41057. * Observable raised when exiting VR.
  41058. */
  41059. onExitingVRObservable: Observable<VRExperienceHelper>;
  41060. /**
  41061. * Observable raised when controller mesh is loaded.
  41062. */
  41063. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41064. /** Return this.onEnteringVRObservable
  41065. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41066. */
  41067. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41068. /** Return this.onExitingVRObservable
  41069. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41070. */
  41071. readonly onExitingVR: Observable<VRExperienceHelper>;
  41072. /** Return this.onControllerMeshLoadedObservable
  41073. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41074. */
  41075. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41076. private _rayLength;
  41077. private _useCustomVRButton;
  41078. private _teleportationRequested;
  41079. private _teleportActive;
  41080. private _floorMeshName;
  41081. private _floorMeshesCollection;
  41082. private _rotationAllowed;
  41083. private _teleportBackwardsVector;
  41084. private _teleportationTarget;
  41085. private _isDefaultTeleportationTarget;
  41086. private _postProcessMove;
  41087. private _teleportationFillColor;
  41088. private _teleportationBorderColor;
  41089. private _rotationAngle;
  41090. private _haloCenter;
  41091. private _cameraGazer;
  41092. private _padSensibilityUp;
  41093. private _padSensibilityDown;
  41094. private _leftController;
  41095. private _rightController;
  41096. /**
  41097. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41098. */
  41099. onNewMeshSelected: Observable<AbstractMesh>;
  41100. /**
  41101. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41102. */
  41103. onNewMeshPicked: Observable<PickingInfo>;
  41104. private _circleEase;
  41105. /**
  41106. * Observable raised before camera teleportation
  41107. */
  41108. onBeforeCameraTeleport: Observable<Vector3>;
  41109. /**
  41110. * Observable raised after camera teleportation
  41111. */
  41112. onAfterCameraTeleport: Observable<Vector3>;
  41113. /**
  41114. * Observable raised when current selected mesh gets unselected
  41115. */
  41116. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41117. private _raySelectionPredicate;
  41118. /**
  41119. * To be optionaly changed by user to define custom ray selection
  41120. */
  41121. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41122. /**
  41123. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41124. */
  41125. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41126. /**
  41127. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41128. */
  41129. teleportationEnabled: boolean;
  41130. private _defaultHeight;
  41131. private _teleportationInitialized;
  41132. private _interactionsEnabled;
  41133. private _interactionsRequested;
  41134. private _displayGaze;
  41135. private _displayLaserPointer;
  41136. /**
  41137. * The mesh used to display where the user is going to teleport.
  41138. */
  41139. /**
  41140. * Sets the mesh to be used to display where the user is going to teleport.
  41141. */
  41142. teleportationTarget: Mesh;
  41143. /**
  41144. * 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
  41145. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41146. * See http://doc.babylonjs.com/resources/baking_transformations
  41147. */
  41148. gazeTrackerMesh: Mesh;
  41149. /**
  41150. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41151. */
  41152. updateGazeTrackerScale: boolean;
  41153. /**
  41154. * If the gaze trackers color should be updated when selecting meshes
  41155. */
  41156. updateGazeTrackerColor: boolean;
  41157. /**
  41158. * The gaze tracking mesh corresponding to the left controller
  41159. */
  41160. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41161. /**
  41162. * The gaze tracking mesh corresponding to the right controller
  41163. */
  41164. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41165. /**
  41166. * If the ray of the gaze should be displayed.
  41167. */
  41168. /**
  41169. * Sets if the ray of the gaze should be displayed.
  41170. */
  41171. displayGaze: boolean;
  41172. /**
  41173. * If the ray of the LaserPointer should be displayed.
  41174. */
  41175. /**
  41176. * Sets if the ray of the LaserPointer should be displayed.
  41177. */
  41178. displayLaserPointer: boolean;
  41179. /**
  41180. * The deviceOrientationCamera used as the camera when not in VR.
  41181. */
  41182. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41183. /**
  41184. * Based on the current WebVR support, returns the current VR camera used.
  41185. */
  41186. readonly currentVRCamera: Nullable<Camera>;
  41187. /**
  41188. * The webVRCamera which is used when in VR.
  41189. */
  41190. readonly webVRCamera: WebVRFreeCamera;
  41191. /**
  41192. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41193. */
  41194. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41195. private readonly _teleportationRequestInitiated;
  41196. /**
  41197. * Defines wether or not Pointer lock should be requested when switching to
  41198. * full screen.
  41199. */
  41200. requestPointerLockOnFullScreen: boolean;
  41201. /**
  41202. * Instantiates a VRExperienceHelper.
  41203. * Helps to quickly add VR support to an existing scene.
  41204. * @param scene The scene the VRExperienceHelper belongs to.
  41205. * @param webVROptions Options to modify the vr experience helper's behavior.
  41206. */
  41207. constructor(scene: Scene,
  41208. /** Options to modify the vr experience helper's behavior. */
  41209. webVROptions?: VRExperienceHelperOptions);
  41210. private _onDefaultMeshLoaded;
  41211. private _onResize;
  41212. private _onFullscreenChange;
  41213. /**
  41214. * Gets a value indicating if we are currently in VR mode.
  41215. */
  41216. readonly isInVRMode: boolean;
  41217. private onVrDisplayPresentChange;
  41218. private onVRDisplayChanged;
  41219. private moveButtonToBottomRight;
  41220. private displayVRButton;
  41221. private updateButtonVisibility;
  41222. private _cachedAngularSensibility;
  41223. /**
  41224. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41225. * Otherwise, will use the fullscreen API.
  41226. */
  41227. enterVR(): void;
  41228. /**
  41229. * Attempt to exit VR, or fullscreen.
  41230. */
  41231. exitVR(): void;
  41232. /**
  41233. * The position of the vr experience helper.
  41234. */
  41235. /**
  41236. * Sets the position of the vr experience helper.
  41237. */
  41238. position: Vector3;
  41239. /**
  41240. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41241. */
  41242. enableInteractions(): void;
  41243. private readonly _noControllerIsActive;
  41244. private beforeRender;
  41245. private _isTeleportationFloor;
  41246. /**
  41247. * Adds a floor mesh to be used for teleportation.
  41248. * @param floorMesh the mesh to be used for teleportation.
  41249. */
  41250. addFloorMesh(floorMesh: Mesh): void;
  41251. /**
  41252. * Removes a floor mesh from being used for teleportation.
  41253. * @param floorMesh the mesh to be removed.
  41254. */
  41255. removeFloorMesh(floorMesh: Mesh): void;
  41256. /**
  41257. * Enables interactions and teleportation using the VR controllers and gaze.
  41258. * @param vrTeleportationOptions options to modify teleportation behavior.
  41259. */
  41260. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41261. private _onNewGamepadConnected;
  41262. private _tryEnableInteractionOnController;
  41263. private _onNewGamepadDisconnected;
  41264. private _enableInteractionOnController;
  41265. private _checkTeleportWithRay;
  41266. private _checkRotate;
  41267. private _checkTeleportBackwards;
  41268. private _enableTeleportationOnController;
  41269. private _createTeleportationCircles;
  41270. private _displayTeleportationTarget;
  41271. private _hideTeleportationTarget;
  41272. private _rotateCamera;
  41273. private _moveTeleportationSelectorTo;
  41274. private _workingVector;
  41275. private _workingQuaternion;
  41276. private _workingMatrix;
  41277. /**
  41278. * Teleports the users feet to the desired location
  41279. * @param location The location where the user's feet should be placed
  41280. */
  41281. teleportCamera(location: Vector3): void;
  41282. private _convertNormalToDirectionOfRay;
  41283. private _castRayAndSelectObject;
  41284. private _notifySelectedMeshUnselected;
  41285. /**
  41286. * Sets the color of the laser ray from the vr controllers.
  41287. * @param color new color for the ray.
  41288. */
  41289. changeLaserColor(color: Color3): void;
  41290. /**
  41291. * Sets the color of the ray from the vr headsets gaze.
  41292. * @param color new color for the ray.
  41293. */
  41294. changeGazeColor(color: Color3): void;
  41295. /**
  41296. * Exits VR and disposes of the vr experience helper
  41297. */
  41298. dispose(): void;
  41299. /**
  41300. * Gets the name of the VRExperienceHelper class
  41301. * @returns "VRExperienceHelper"
  41302. */
  41303. getClassName(): string;
  41304. }
  41305. }
  41306. declare module "babylonjs/Cameras/VR/index" {
  41307. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41308. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41309. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41310. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41311. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41312. export * from "babylonjs/Cameras/VR/webVRCamera";
  41313. }
  41314. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41315. import { Observable } from "babylonjs/Misc/observable";
  41316. import { Nullable } from "babylonjs/types";
  41317. import { IDisposable, Scene } from "babylonjs/scene";
  41318. import { Vector3 } from "babylonjs/Maths/math";
  41319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41320. import { Ray } from "babylonjs/Culling/ray";
  41321. /**
  41322. * Manages an XRSession
  41323. * @see https://doc.babylonjs.com/how_to/webxr
  41324. */
  41325. export class WebXRSessionManager implements IDisposable {
  41326. private scene;
  41327. /**
  41328. * Fires every time a new xrFrame arrives which can be used to update the camera
  41329. */
  41330. onXRFrameObservable: Observable<any>;
  41331. /**
  41332. * Fires when the xr session is ended either by the device or manually done
  41333. */
  41334. onXRSessionEnded: Observable<any>;
  41335. /** @hidden */
  41336. _xrSession: XRSession;
  41337. /** @hidden */
  41338. _frameOfReference: XRFrameOfReference;
  41339. /** @hidden */
  41340. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41341. /** @hidden */
  41342. _currentXRFrame: Nullable<XRFrame>;
  41343. private _xrNavigator;
  41344. private _xrDevice;
  41345. private _tmpMatrix;
  41346. /**
  41347. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41348. * @param scene The scene which the session should be created for
  41349. */
  41350. constructor(scene: Scene);
  41351. /**
  41352. * Initializes the manager
  41353. * After initialization enterXR can be called to start an XR session
  41354. * @returns Promise which resolves after it is initialized
  41355. */
  41356. initializeAsync(): Promise<void>;
  41357. /**
  41358. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41359. * @param sessionCreationOptions xr options to create the session with
  41360. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41361. * @returns Promise which resolves after it enters XR
  41362. */
  41363. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41364. /**
  41365. * Stops the xrSession and restores the renderloop
  41366. * @returns Promise which resolves after it exits XR
  41367. */
  41368. exitXRAsync(): Promise<void>;
  41369. /**
  41370. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41371. * @param ray ray to cast into the environment
  41372. * @returns Promise which resolves with a collision point in the environment if it exists
  41373. */
  41374. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41375. /**
  41376. * Checks if a session would be supported for the creation options specified
  41377. * @param options creation options to check if they are supported
  41378. * @returns true if supported
  41379. */
  41380. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41381. /**
  41382. * @hidden
  41383. * Converts the render layer of xrSession to a render target
  41384. * @param session session to create render target for
  41385. * @param scene scene the new render target should be created for
  41386. */
  41387. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41388. /**
  41389. * Disposes of the session manager
  41390. */
  41391. dispose(): void;
  41392. }
  41393. }
  41394. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41395. import { Scene } from "babylonjs/scene";
  41396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41397. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41398. /**
  41399. * WebXR Camera which holds the views for the xrSession
  41400. * @see https://doc.babylonjs.com/how_to/webxr
  41401. */
  41402. export class WebXRCamera extends FreeCamera {
  41403. private static _TmpMatrix;
  41404. /**
  41405. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41406. * @param name the name of the camera
  41407. * @param scene the scene to add the camera to
  41408. */
  41409. constructor(name: string, scene: Scene);
  41410. private _updateNumberOfRigCameras;
  41411. /** @hidden */
  41412. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41413. /**
  41414. * Updates the cameras position from the current pose information of the XR session
  41415. * @param xrSessionManager the session containing pose information
  41416. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41417. */
  41418. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41419. }
  41420. }
  41421. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41422. import { Nullable } from "babylonjs/types";
  41423. import { Observable } from "babylonjs/Misc/observable";
  41424. import { IDisposable, Scene } from "babylonjs/scene";
  41425. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41427. import { Ray } from "babylonjs/Culling/ray";
  41428. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41429. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41430. /**
  41431. * States of the webXR experience
  41432. */
  41433. export enum WebXRState {
  41434. /**
  41435. * Transitioning to being in XR mode
  41436. */
  41437. ENTERING_XR = 0,
  41438. /**
  41439. * Transitioning to non XR mode
  41440. */
  41441. EXITING_XR = 1,
  41442. /**
  41443. * In XR mode and presenting
  41444. */
  41445. IN_XR = 2,
  41446. /**
  41447. * Not entered XR mode
  41448. */
  41449. NOT_IN_XR = 3
  41450. }
  41451. /**
  41452. * Helper class used to enable XR
  41453. * @see https://doc.babylonjs.com/how_to/webxr
  41454. */
  41455. export class WebXRExperienceHelper implements IDisposable {
  41456. private scene;
  41457. /**
  41458. * 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
  41459. */
  41460. container: AbstractMesh;
  41461. /**
  41462. * Camera used to render xr content
  41463. */
  41464. camera: WebXRCamera;
  41465. /**
  41466. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41467. */
  41468. state: WebXRState;
  41469. private _setState;
  41470. private static _TmpVector;
  41471. /**
  41472. * Fires when the state of the experience helper has changed
  41473. */
  41474. onStateChangedObservable: Observable<WebXRState>;
  41475. /** @hidden */
  41476. _sessionManager: WebXRSessionManager;
  41477. private _nonVRCamera;
  41478. private _originalSceneAutoClear;
  41479. private _supported;
  41480. /**
  41481. * Creates the experience helper
  41482. * @param scene the scene to attach the experience helper to
  41483. * @returns a promise for the experience helper
  41484. */
  41485. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41486. /**
  41487. * Creates a WebXRExperienceHelper
  41488. * @param scene The scene the helper should be created in
  41489. */
  41490. private constructor();
  41491. /**
  41492. * Exits XR mode and returns the scene to its original state
  41493. * @returns promise that resolves after xr mode has exited
  41494. */
  41495. exitXRAsync(): Promise<void>;
  41496. /**
  41497. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41498. * @param sessionCreationOptions options for the XR session
  41499. * @param frameOfReference frame of reference of the XR session
  41500. * @returns promise that resolves after xr mode has entered
  41501. */
  41502. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41503. /**
  41504. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41505. * @param ray ray to cast into the environment
  41506. * @returns Promise which resolves with a collision point in the environment if it exists
  41507. */
  41508. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41509. /**
  41510. * Updates the global position of the camera by moving the camera's container
  41511. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41512. * @param position The desired global position of the camera
  41513. */
  41514. setPositionOfCameraUsingContainer(position: Vector3): void;
  41515. /**
  41516. * Rotates the xr camera by rotating the camera's container around the camera's position
  41517. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41518. * @param rotation the desired quaternion rotation to apply to the camera
  41519. */
  41520. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41521. /**
  41522. * Checks if the creation options are supported by the xr session
  41523. * @param options creation options
  41524. * @returns true if supported
  41525. */
  41526. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41527. /**
  41528. * Disposes of the experience helper
  41529. */
  41530. dispose(): void;
  41531. }
  41532. }
  41533. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41534. import { Nullable } from "babylonjs/types";
  41535. import { Observable } from "babylonjs/Misc/observable";
  41536. import { IDisposable, Scene } from "babylonjs/scene";
  41537. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41538. /**
  41539. * Button which can be used to enter a different mode of XR
  41540. */
  41541. export class WebXREnterExitUIButton {
  41542. /** button element */
  41543. element: HTMLElement;
  41544. /** XR initialization options for the button */
  41545. initializationOptions: XRSessionCreationOptions;
  41546. /**
  41547. * Creates a WebXREnterExitUIButton
  41548. * @param element button element
  41549. * @param initializationOptions XR initialization options for the button
  41550. */
  41551. constructor(
  41552. /** button element */
  41553. element: HTMLElement,
  41554. /** XR initialization options for the button */
  41555. initializationOptions: XRSessionCreationOptions);
  41556. /**
  41557. * Overwritable function which can be used to update the button's visuals when the state changes
  41558. * @param activeButton the current active button in the UI
  41559. */
  41560. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41561. }
  41562. /**
  41563. * Options to create the webXR UI
  41564. */
  41565. export class WebXREnterExitUIOptions {
  41566. /**
  41567. * Context to enter xr with
  41568. */
  41569. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41570. /**
  41571. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41572. */
  41573. customButtons?: Array<WebXREnterExitUIButton>;
  41574. }
  41575. /**
  41576. * UI to allow the user to enter/exit XR mode
  41577. */
  41578. export class WebXREnterExitUI implements IDisposable {
  41579. private scene;
  41580. private _overlay;
  41581. private _buttons;
  41582. private _activeButton;
  41583. /**
  41584. * Fired every time the active button is changed.
  41585. *
  41586. * When xr is entered via a button that launches xr that button will be the callback parameter
  41587. *
  41588. * When exiting xr the callback parameter will be null)
  41589. */
  41590. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41591. /**
  41592. * Creates UI to allow the user to enter/exit XR mode
  41593. * @param scene the scene to add the ui to
  41594. * @param helper the xr experience helper to enter/exit xr with
  41595. * @param options options to configure the UI
  41596. * @returns the created ui
  41597. */
  41598. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41599. private constructor();
  41600. private _updateButtons;
  41601. /**
  41602. * Disposes of the object
  41603. */
  41604. dispose(): void;
  41605. }
  41606. }
  41607. declare module "babylonjs/Cameras/XR/webXRInput" {
  41608. import { IDisposable, Scene } from "babylonjs/scene";
  41609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41610. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41611. /**
  41612. * Represents an XR input
  41613. */
  41614. export class WebXRController {
  41615. /**
  41616. * 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
  41617. */
  41618. grip?: AbstractMesh;
  41619. /**
  41620. * Pointer which can be used to select objects or attach a visible laser to
  41621. */
  41622. pointer: AbstractMesh;
  41623. /**
  41624. * Creates the controller
  41625. * @see https://doc.babylonjs.com/how_to/webxr
  41626. * @param scene the scene which the controller should be associated to
  41627. */
  41628. constructor(scene: Scene);
  41629. /**
  41630. * Disposes of the object
  41631. */
  41632. dispose(): void;
  41633. }
  41634. /**
  41635. * XR input used to track XR inputs such as controllers/rays
  41636. */
  41637. export class WebXRInput implements IDisposable {
  41638. private helper;
  41639. /**
  41640. * XR controllers being tracked
  41641. */
  41642. controllers: Array<WebXRController>;
  41643. private _tmpMatrix;
  41644. private _frameObserver;
  41645. /**
  41646. * Initializes the WebXRInput
  41647. * @param helper experience helper which the input should be created for
  41648. */
  41649. constructor(helper: WebXRExperienceHelper);
  41650. /**
  41651. * Disposes of the object
  41652. */
  41653. dispose(): void;
  41654. }
  41655. }
  41656. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41657. import { Nullable } from "babylonjs/types";
  41658. import { IDisposable } from "babylonjs/scene";
  41659. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41660. /**
  41661. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41662. */
  41663. export class WebXRManagedOutputCanvas implements IDisposable {
  41664. private _canvas;
  41665. /**
  41666. * xrpresent context of the canvas which can be used to display/mirror xr content
  41667. */
  41668. canvasContext: Nullable<WebGLRenderingContext>;
  41669. /**
  41670. * Initializes the canvas to be added/removed upon entering/exiting xr
  41671. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41672. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41673. */
  41674. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41675. /**
  41676. * Disposes of the object
  41677. */
  41678. dispose(): void;
  41679. private _setManagedOutputCanvas;
  41680. private _addCanvas;
  41681. private _removeCanvas;
  41682. }
  41683. }
  41684. declare module "babylonjs/Cameras/XR/index" {
  41685. export * from "babylonjs/Cameras/XR/webXRCamera";
  41686. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41687. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41688. export * from "babylonjs/Cameras/XR/webXRInput";
  41689. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41690. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41691. }
  41692. declare module "babylonjs/Cameras/RigModes/index" {
  41693. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41694. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41695. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41696. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41697. }
  41698. declare module "babylonjs/Cameras/index" {
  41699. export * from "babylonjs/Cameras/Inputs/index";
  41700. export * from "babylonjs/Cameras/cameraInputsManager";
  41701. export * from "babylonjs/Cameras/camera";
  41702. export * from "babylonjs/Cameras/targetCamera";
  41703. export * from "babylonjs/Cameras/freeCamera";
  41704. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41705. export * from "babylonjs/Cameras/touchCamera";
  41706. export * from "babylonjs/Cameras/arcRotateCamera";
  41707. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41708. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41709. export * from "babylonjs/Cameras/flyCamera";
  41710. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41711. export * from "babylonjs/Cameras/followCamera";
  41712. export * from "babylonjs/Cameras/gamepadCamera";
  41713. export * from "babylonjs/Cameras/Stereoscopic/index";
  41714. export * from "babylonjs/Cameras/universalCamera";
  41715. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41716. export * from "babylonjs/Cameras/VR/index";
  41717. export * from "babylonjs/Cameras/XR/index";
  41718. export * from "babylonjs/Cameras/RigModes/index";
  41719. }
  41720. declare module "babylonjs/Collisions/index" {
  41721. export * from "babylonjs/Collisions/collider";
  41722. export * from "babylonjs/Collisions/collisionCoordinator";
  41723. export * from "babylonjs/Collisions/pickingInfo";
  41724. export * from "babylonjs/Collisions/intersectionInfo";
  41725. }
  41726. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41727. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41728. import { Vector3, Plane } from "babylonjs/Maths/math";
  41729. import { Ray } from "babylonjs/Culling/ray";
  41730. /**
  41731. * Contains an array of blocks representing the octree
  41732. */
  41733. export interface IOctreeContainer<T> {
  41734. /**
  41735. * Blocks within the octree
  41736. */
  41737. blocks: Array<OctreeBlock<T>>;
  41738. }
  41739. /**
  41740. * Class used to store a cell in an octree
  41741. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41742. */
  41743. export class OctreeBlock<T> {
  41744. /**
  41745. * Gets the content of the current block
  41746. */
  41747. entries: T[];
  41748. /**
  41749. * Gets the list of block children
  41750. */
  41751. blocks: Array<OctreeBlock<T>>;
  41752. private _depth;
  41753. private _maxDepth;
  41754. private _capacity;
  41755. private _minPoint;
  41756. private _maxPoint;
  41757. private _boundingVectors;
  41758. private _creationFunc;
  41759. /**
  41760. * Creates a new block
  41761. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41762. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41763. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41764. * @param depth defines the current depth of this block in the octree
  41765. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41766. * @param creationFunc defines a callback to call when an element is added to the block
  41767. */
  41768. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41769. /**
  41770. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41771. */
  41772. readonly capacity: number;
  41773. /**
  41774. * Gets the minimum vector (in world space) of the block's bounding box
  41775. */
  41776. readonly minPoint: Vector3;
  41777. /**
  41778. * Gets the maximum vector (in world space) of the block's bounding box
  41779. */
  41780. readonly maxPoint: Vector3;
  41781. /**
  41782. * Add a new element to this block
  41783. * @param entry defines the element to add
  41784. */
  41785. addEntry(entry: T): void;
  41786. /**
  41787. * Remove an element from this block
  41788. * @param entry defines the element to remove
  41789. */
  41790. removeEntry(entry: T): void;
  41791. /**
  41792. * Add an array of elements to this block
  41793. * @param entries defines the array of elements to add
  41794. */
  41795. addEntries(entries: T[]): void;
  41796. /**
  41797. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41798. * @param frustumPlanes defines the frustum planes to test
  41799. * @param selection defines the array to store current content if selection is positive
  41800. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41801. */
  41802. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41803. /**
  41804. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41805. * @param sphereCenter defines the bounding sphere center
  41806. * @param sphereRadius defines the bounding sphere radius
  41807. * @param selection defines the array to store current content if selection is positive
  41808. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41809. */
  41810. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41811. /**
  41812. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41813. * @param ray defines the ray to test with
  41814. * @param selection defines the array to store current content if selection is positive
  41815. */
  41816. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41817. /**
  41818. * Subdivide the content into child blocks (this block will then be empty)
  41819. */
  41820. createInnerBlocks(): void;
  41821. /**
  41822. * @hidden
  41823. */
  41824. 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;
  41825. }
  41826. }
  41827. declare module "babylonjs/Culling/Octrees/octree" {
  41828. import { SmartArray } from "babylonjs/Misc/smartArray";
  41829. import { Vector3, Plane } from "babylonjs/Maths/math";
  41830. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41832. import { Ray } from "babylonjs/Culling/ray";
  41833. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41834. /**
  41835. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41837. */
  41838. export class Octree<T> {
  41839. /** 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.) */
  41840. maxDepth: number;
  41841. /**
  41842. * Blocks within the octree containing objects
  41843. */
  41844. blocks: Array<OctreeBlock<T>>;
  41845. /**
  41846. * Content stored in the octree
  41847. */
  41848. dynamicContent: T[];
  41849. private _maxBlockCapacity;
  41850. private _selectionContent;
  41851. private _creationFunc;
  41852. /**
  41853. * Creates a octree
  41854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41855. * @param creationFunc function to be used to instatiate the octree
  41856. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41857. * @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.)
  41858. */
  41859. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41860. /** 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.) */
  41861. maxDepth?: number);
  41862. /**
  41863. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41864. * @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);
  41865. * @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);
  41866. * @param entries meshes to be added to the octree blocks
  41867. */
  41868. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41869. /**
  41870. * Adds a mesh to the octree
  41871. * @param entry Mesh to add to the octree
  41872. */
  41873. addMesh(entry: T): void;
  41874. /**
  41875. * Remove an element from the octree
  41876. * @param entry defines the element to remove
  41877. */
  41878. removeMesh(entry: T): void;
  41879. /**
  41880. * Selects an array of meshes within the frustum
  41881. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41882. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41883. * @returns array of meshes within the frustum
  41884. */
  41885. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41886. /**
  41887. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41888. * @param sphereCenter defines the bounding sphere center
  41889. * @param sphereRadius defines the bounding sphere radius
  41890. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41891. * @returns an array of objects that intersect the sphere
  41892. */
  41893. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41894. /**
  41895. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41896. * @param ray defines the ray to test with
  41897. * @returns array of intersected objects
  41898. */
  41899. intersectsRay(ray: Ray): SmartArray<T>;
  41900. /**
  41901. * Adds a mesh into the octree block if it intersects the block
  41902. */
  41903. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41904. /**
  41905. * Adds a submesh into the octree block if it intersects the block
  41906. */
  41907. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41908. }
  41909. }
  41910. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41911. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41912. import { Scene } from "babylonjs/scene";
  41913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41915. import { Ray } from "babylonjs/Culling/ray";
  41916. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41917. import { Collider } from "babylonjs/Collisions/collider";
  41918. module "babylonjs/scene" {
  41919. interface Scene {
  41920. /**
  41921. * @hidden
  41922. * Backing Filed
  41923. */
  41924. _selectionOctree: Octree<AbstractMesh>;
  41925. /**
  41926. * Gets the octree used to boost mesh selection (picking)
  41927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41928. */
  41929. selectionOctree: Octree<AbstractMesh>;
  41930. /**
  41931. * Creates or updates the octree used to boost selection (picking)
  41932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41933. * @param maxCapacity defines the maximum capacity per leaf
  41934. * @param maxDepth defines the maximum depth of the octree
  41935. * @returns an octree of AbstractMesh
  41936. */
  41937. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41938. }
  41939. }
  41940. module "babylonjs/Meshes/abstractMesh" {
  41941. interface AbstractMesh {
  41942. /**
  41943. * @hidden
  41944. * Backing Field
  41945. */
  41946. _submeshesOctree: Octree<SubMesh>;
  41947. /**
  41948. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41949. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41950. * @param maxCapacity defines the maximum size of each block (64 by default)
  41951. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41952. * @returns the new octree
  41953. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41955. */
  41956. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41957. }
  41958. }
  41959. /**
  41960. * Defines the octree scene component responsible to manage any octrees
  41961. * in a given scene.
  41962. */
  41963. export class OctreeSceneComponent {
  41964. /**
  41965. * The component name help to identify the component in the list of scene components.
  41966. */
  41967. readonly name: string;
  41968. /**
  41969. * The scene the component belongs to.
  41970. */
  41971. scene: Scene;
  41972. /**
  41973. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41974. */
  41975. readonly checksIsEnabled: boolean;
  41976. /**
  41977. * Creates a new instance of the component for the given scene
  41978. * @param scene Defines the scene to register the component in
  41979. */
  41980. constructor(scene: Scene);
  41981. /**
  41982. * Registers the component in a given scene
  41983. */
  41984. register(): void;
  41985. /**
  41986. * Return the list of active meshes
  41987. * @returns the list of active meshes
  41988. */
  41989. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41990. /**
  41991. * Return the list of active sub meshes
  41992. * @param mesh The mesh to get the candidates sub meshes from
  41993. * @returns the list of active sub meshes
  41994. */
  41995. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41996. private _tempRay;
  41997. /**
  41998. * Return the list of sub meshes intersecting with a given local ray
  41999. * @param mesh defines the mesh to find the submesh for
  42000. * @param localRay defines the ray in local space
  42001. * @returns the list of intersecting sub meshes
  42002. */
  42003. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42004. /**
  42005. * Return the list of sub meshes colliding with a collider
  42006. * @param mesh defines the mesh to find the submesh for
  42007. * @param collider defines the collider to evaluate the collision against
  42008. * @returns the list of colliding sub meshes
  42009. */
  42010. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42011. /**
  42012. * Rebuilds the elements related to this component in case of
  42013. * context lost for instance.
  42014. */
  42015. rebuild(): void;
  42016. /**
  42017. * Disposes the component and the associated ressources.
  42018. */
  42019. dispose(): void;
  42020. }
  42021. }
  42022. declare module "babylonjs/Culling/Octrees/index" {
  42023. export * from "babylonjs/Culling/Octrees/octree";
  42024. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42025. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42026. }
  42027. declare module "babylonjs/Culling/index" {
  42028. export * from "babylonjs/Culling/boundingBox";
  42029. export * from "babylonjs/Culling/boundingInfo";
  42030. export * from "babylonjs/Culling/boundingSphere";
  42031. export * from "babylonjs/Culling/Octrees/index";
  42032. export * from "babylonjs/Culling/ray";
  42033. }
  42034. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42035. import { IDisposable, Scene } from "babylonjs/scene";
  42036. import { Nullable } from "babylonjs/types";
  42037. import { Observable } from "babylonjs/Misc/observable";
  42038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42039. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42040. /**
  42041. * Renders a layer on top of an existing scene
  42042. */
  42043. export class UtilityLayerRenderer implements IDisposable {
  42044. /** the original scene that will be rendered on top of */
  42045. originalScene: Scene;
  42046. private _pointerCaptures;
  42047. private _lastPointerEvents;
  42048. private static _DefaultUtilityLayer;
  42049. private static _DefaultKeepDepthUtilityLayer;
  42050. private _sharedGizmoLight;
  42051. /**
  42052. * @hidden
  42053. * Light which used by gizmos to get light shading
  42054. */
  42055. _getSharedGizmoLight(): HemisphericLight;
  42056. /**
  42057. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42058. */
  42059. pickUtilitySceneFirst: boolean;
  42060. /**
  42061. * 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)
  42062. */
  42063. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42064. /**
  42065. * 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)
  42066. */
  42067. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42068. /**
  42069. * The scene that is rendered on top of the original scene
  42070. */
  42071. utilityLayerScene: Scene;
  42072. /**
  42073. * If the utility layer should automatically be rendered on top of existing scene
  42074. */
  42075. shouldRender: boolean;
  42076. /**
  42077. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42078. */
  42079. onlyCheckPointerDownEvents: boolean;
  42080. /**
  42081. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42082. */
  42083. processAllEvents: boolean;
  42084. /**
  42085. * Observable raised when the pointer move from the utility layer scene to the main scene
  42086. */
  42087. onPointerOutObservable: Observable<number>;
  42088. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42089. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42090. private _afterRenderObserver;
  42091. private _sceneDisposeObserver;
  42092. private _originalPointerObserver;
  42093. /**
  42094. * Instantiates a UtilityLayerRenderer
  42095. * @param originalScene the original scene that will be rendered on top of
  42096. * @param handleEvents boolean indicating if the utility layer should handle events
  42097. */
  42098. constructor(
  42099. /** the original scene that will be rendered on top of */
  42100. originalScene: Scene, handleEvents?: boolean);
  42101. private _notifyObservers;
  42102. /**
  42103. * Renders the utility layers scene on top of the original scene
  42104. */
  42105. render(): void;
  42106. /**
  42107. * Disposes of the renderer
  42108. */
  42109. dispose(): void;
  42110. private _updateCamera;
  42111. }
  42112. }
  42113. declare module "babylonjs/Gizmos/gizmo" {
  42114. import { Nullable } from "babylonjs/types";
  42115. import { IDisposable } from "babylonjs/scene";
  42116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42117. import { Mesh } from "babylonjs/Meshes/mesh";
  42118. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42119. /**
  42120. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42121. */
  42122. export class Gizmo implements IDisposable {
  42123. /** The utility layer the gizmo will be added to */
  42124. gizmoLayer: UtilityLayerRenderer;
  42125. /**
  42126. * The root mesh of the gizmo
  42127. */
  42128. _rootMesh: Mesh;
  42129. private _attachedMesh;
  42130. /**
  42131. * Ratio for the scale of the gizmo (Default: 1)
  42132. */
  42133. scaleRatio: number;
  42134. /**
  42135. * If a custom mesh has been set (Default: false)
  42136. */
  42137. protected _customMeshSet: boolean;
  42138. /**
  42139. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42140. * * When set, interactions will be enabled
  42141. */
  42142. attachedMesh: Nullable<AbstractMesh>;
  42143. /**
  42144. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42145. * @param mesh The mesh to replace the default mesh of the gizmo
  42146. */
  42147. setCustomMesh(mesh: Mesh): void;
  42148. /**
  42149. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42150. */
  42151. updateGizmoRotationToMatchAttachedMesh: boolean;
  42152. /**
  42153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42154. */
  42155. updateGizmoPositionToMatchAttachedMesh: boolean;
  42156. /**
  42157. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42158. */
  42159. protected _updateScale: boolean;
  42160. protected _interactionsEnabled: boolean;
  42161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42162. private _beforeRenderObserver;
  42163. private _tempVector;
  42164. /**
  42165. * Creates a gizmo
  42166. * @param gizmoLayer The utility layer the gizmo will be added to
  42167. */
  42168. constructor(
  42169. /** The utility layer the gizmo will be added to */
  42170. gizmoLayer?: UtilityLayerRenderer);
  42171. /**
  42172. * Updates the gizmo to match the attached mesh's position/rotation
  42173. */
  42174. protected _update(): void;
  42175. /**
  42176. * Disposes of the gizmo
  42177. */
  42178. dispose(): void;
  42179. }
  42180. }
  42181. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42182. import { Observable } from "babylonjs/Misc/observable";
  42183. import { Nullable } from "babylonjs/types";
  42184. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42185. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42187. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42188. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42189. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42190. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42191. import { Scene } from "babylonjs/scene";
  42192. /**
  42193. * Single axis drag gizmo
  42194. */
  42195. export class AxisDragGizmo extends Gizmo {
  42196. /**
  42197. * Drag behavior responsible for the gizmos dragging interactions
  42198. */
  42199. dragBehavior: PointerDragBehavior;
  42200. private _pointerObserver;
  42201. /**
  42202. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42203. */
  42204. snapDistance: number;
  42205. /**
  42206. * Event that fires each time the gizmo snaps to a new location.
  42207. * * snapDistance is the the change in distance
  42208. */
  42209. onSnapObservable: Observable<{
  42210. snapDistance: number;
  42211. }>;
  42212. /** @hidden */
  42213. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42214. /** @hidden */
  42215. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42216. /**
  42217. * Creates an AxisDragGizmo
  42218. * @param gizmoLayer The utility layer the gizmo will be added to
  42219. * @param dragAxis The axis which the gizmo will be able to drag on
  42220. * @param color The color of the gizmo
  42221. */
  42222. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42223. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42224. /**
  42225. * Disposes of the gizmo
  42226. */
  42227. dispose(): void;
  42228. }
  42229. }
  42230. declare module "babylonjs/Debug/axesViewer" {
  42231. import { Vector3 } from "babylonjs/Maths/math";
  42232. import { Nullable } from "babylonjs/types";
  42233. import { Scene } from "babylonjs/scene";
  42234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42235. /**
  42236. * The Axes viewer will show 3 axes in a specific point in space
  42237. */
  42238. export class AxesViewer {
  42239. private _xAxis;
  42240. private _yAxis;
  42241. private _zAxis;
  42242. private _scaleLinesFactor;
  42243. private _instanced;
  42244. /**
  42245. * Gets the hosting scene
  42246. */
  42247. scene: Scene;
  42248. /**
  42249. * Gets or sets a number used to scale line length
  42250. */
  42251. scaleLines: number;
  42252. /** Gets the node hierarchy used to render x-axis */
  42253. readonly xAxis: TransformNode;
  42254. /** Gets the node hierarchy used to render y-axis */
  42255. readonly yAxis: TransformNode;
  42256. /** Gets the node hierarchy used to render z-axis */
  42257. readonly zAxis: TransformNode;
  42258. /**
  42259. * Creates a new AxesViewer
  42260. * @param scene defines the hosting scene
  42261. * @param scaleLines defines a number used to scale line length (1 by default)
  42262. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42263. * @param xAxis defines the node hierarchy used to render the x-axis
  42264. * @param yAxis defines the node hierarchy used to render the y-axis
  42265. * @param zAxis defines the node hierarchy used to render the z-axis
  42266. */
  42267. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42268. /**
  42269. * Force the viewer to update
  42270. * @param position defines the position of the viewer
  42271. * @param xaxis defines the x axis of the viewer
  42272. * @param yaxis defines the y axis of the viewer
  42273. * @param zaxis defines the z axis of the viewer
  42274. */
  42275. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42276. /**
  42277. * Creates an instance of this axes viewer.
  42278. * @returns a new axes viewer with instanced meshes
  42279. */
  42280. createInstance(): AxesViewer;
  42281. /** Releases resources */
  42282. dispose(): void;
  42283. private static _SetRenderingGroupId;
  42284. }
  42285. }
  42286. declare module "babylonjs/Debug/boneAxesViewer" {
  42287. import { Nullable } from "babylonjs/types";
  42288. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42289. import { Vector3 } from "babylonjs/Maths/math";
  42290. import { Mesh } from "babylonjs/Meshes/mesh";
  42291. import { Bone } from "babylonjs/Bones/bone";
  42292. import { Scene } from "babylonjs/scene";
  42293. /**
  42294. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42295. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42296. */
  42297. export class BoneAxesViewer extends AxesViewer {
  42298. /**
  42299. * Gets or sets the target mesh where to display the axes viewer
  42300. */
  42301. mesh: Nullable<Mesh>;
  42302. /**
  42303. * Gets or sets the target bone where to display the axes viewer
  42304. */
  42305. bone: Nullable<Bone>;
  42306. /** Gets current position */
  42307. pos: Vector3;
  42308. /** Gets direction of X axis */
  42309. xaxis: Vector3;
  42310. /** Gets direction of Y axis */
  42311. yaxis: Vector3;
  42312. /** Gets direction of Z axis */
  42313. zaxis: Vector3;
  42314. /**
  42315. * Creates a new BoneAxesViewer
  42316. * @param scene defines the hosting scene
  42317. * @param bone defines the target bone
  42318. * @param mesh defines the target mesh
  42319. * @param scaleLines defines a scaling factor for line length (1 by default)
  42320. */
  42321. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42322. /**
  42323. * Force the viewer to update
  42324. */
  42325. update(): void;
  42326. /** Releases resources */
  42327. dispose(): void;
  42328. }
  42329. }
  42330. declare module "babylonjs/Debug/debugLayer" {
  42331. import { Observable } from "babylonjs/Misc/observable";
  42332. import { Scene } from "babylonjs/scene";
  42333. /**
  42334. * Interface used to define scene explorer extensibility option
  42335. */
  42336. export interface IExplorerExtensibilityOption {
  42337. /**
  42338. * Define the option label
  42339. */
  42340. label: string;
  42341. /**
  42342. * Defines the action to execute on click
  42343. */
  42344. action: (entity: any) => void;
  42345. }
  42346. /**
  42347. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42348. */
  42349. export interface IExplorerExtensibilityGroup {
  42350. /**
  42351. * Defines a predicate to test if a given type mut be extended
  42352. */
  42353. predicate: (entity: any) => boolean;
  42354. /**
  42355. * Gets the list of options added to a type
  42356. */
  42357. entries: IExplorerExtensibilityOption[];
  42358. }
  42359. /**
  42360. * Interface used to define the options to use to create the Inspector
  42361. */
  42362. export interface IInspectorOptions {
  42363. /**
  42364. * Display in overlay mode (default: false)
  42365. */
  42366. overlay?: boolean;
  42367. /**
  42368. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42369. */
  42370. globalRoot?: HTMLElement;
  42371. /**
  42372. * Display the Scene explorer
  42373. */
  42374. showExplorer?: boolean;
  42375. /**
  42376. * Display the property inspector
  42377. */
  42378. showInspector?: boolean;
  42379. /**
  42380. * Display in embed mode (both panes on the right)
  42381. */
  42382. embedMode?: boolean;
  42383. /**
  42384. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42385. */
  42386. handleResize?: boolean;
  42387. /**
  42388. * Allow the panes to popup (default: true)
  42389. */
  42390. enablePopup?: boolean;
  42391. /**
  42392. * Allow the panes to be closed by users (default: true)
  42393. */
  42394. enableClose?: boolean;
  42395. /**
  42396. * Optional list of extensibility entries
  42397. */
  42398. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42399. /**
  42400. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42401. */
  42402. inspectorURL?: string;
  42403. }
  42404. module "babylonjs/scene" {
  42405. interface Scene {
  42406. /**
  42407. * @hidden
  42408. * Backing field
  42409. */
  42410. _debugLayer: DebugLayer;
  42411. /**
  42412. * Gets the debug layer (aka Inspector) associated with the scene
  42413. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42414. */
  42415. debugLayer: DebugLayer;
  42416. }
  42417. }
  42418. /**
  42419. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42420. * what is happening in your scene
  42421. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42422. */
  42423. export class DebugLayer {
  42424. /**
  42425. * Define the url to get the inspector script from.
  42426. * By default it uses the babylonjs CDN.
  42427. * @ignoreNaming
  42428. */
  42429. static InspectorURL: string;
  42430. private _scene;
  42431. private BJSINSPECTOR;
  42432. /**
  42433. * Observable triggered when a property is changed through the inspector.
  42434. */
  42435. onPropertyChangedObservable: Observable<{
  42436. object: any;
  42437. property: string;
  42438. value: any;
  42439. initialValue: any;
  42440. }>;
  42441. /**
  42442. * Instantiates a new debug layer.
  42443. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42444. * what is happening in your scene
  42445. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42446. * @param scene Defines the scene to inspect
  42447. */
  42448. constructor(scene: Scene);
  42449. /** Creates the inspector window. */
  42450. private _createInspector;
  42451. /**
  42452. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42453. * @param entity defines the entity to select
  42454. * @param lineContainerTitle defines the specific block to highlight
  42455. */
  42456. select(entity: any, lineContainerTitle?: string): void;
  42457. /** Get the inspector from bundle or global */
  42458. private _getGlobalInspector;
  42459. /**
  42460. * Get if the inspector is visible or not.
  42461. * @returns true if visible otherwise, false
  42462. */
  42463. isVisible(): boolean;
  42464. /**
  42465. * Hide the inspector and close its window.
  42466. */
  42467. hide(): void;
  42468. /**
  42469. * Launch the debugLayer.
  42470. * @param config Define the configuration of the inspector
  42471. * @return a promise fulfilled when the debug layer is visible
  42472. */
  42473. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42474. }
  42475. }
  42476. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42477. import { Nullable } from "babylonjs/types";
  42478. import { Scene } from "babylonjs/scene";
  42479. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42480. import { Mesh } from "babylonjs/Meshes/mesh";
  42481. /**
  42482. * Class containing static functions to help procedurally build meshes
  42483. */
  42484. export class BoxBuilder {
  42485. /**
  42486. * Creates a box mesh
  42487. * * The parameter `size` sets the size (float) of each box side (default 1)
  42488. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42489. * * 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)
  42490. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42494. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42495. * @param name defines the name of the mesh
  42496. * @param options defines the options used to create the mesh
  42497. * @param scene defines the hosting scene
  42498. * @returns the box mesh
  42499. */
  42500. static CreateBox(name: string, options: {
  42501. size?: number;
  42502. width?: number;
  42503. height?: number;
  42504. depth?: number;
  42505. faceUV?: Vector4[];
  42506. faceColors?: Color4[];
  42507. sideOrientation?: number;
  42508. frontUVs?: Vector4;
  42509. backUVs?: Vector4;
  42510. wrap?: boolean;
  42511. topBaseAt?: number;
  42512. bottomBaseAt?: number;
  42513. updatable?: boolean;
  42514. }, scene?: Nullable<Scene>): Mesh;
  42515. }
  42516. }
  42517. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42518. import { Vector4 } from "babylonjs/Maths/math";
  42519. import { Mesh } from "babylonjs/Meshes/mesh";
  42520. /**
  42521. * Class containing static functions to help procedurally build meshes
  42522. */
  42523. export class SphereBuilder {
  42524. /**
  42525. * Creates a sphere mesh
  42526. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42527. * * 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`)
  42528. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42529. * * 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
  42530. * * 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)
  42531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42534. * @param name defines the name of the mesh
  42535. * @param options defines the options used to create the mesh
  42536. * @param scene defines the hosting scene
  42537. * @returns the sphere mesh
  42538. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42539. */
  42540. static CreateSphere(name: string, options: {
  42541. segments?: number;
  42542. diameter?: number;
  42543. diameterX?: number;
  42544. diameterY?: number;
  42545. diameterZ?: number;
  42546. arc?: number;
  42547. slice?: number;
  42548. sideOrientation?: number;
  42549. frontUVs?: Vector4;
  42550. backUVs?: Vector4;
  42551. updatable?: boolean;
  42552. }, scene: any): Mesh;
  42553. }
  42554. }
  42555. declare module "babylonjs/Debug/physicsViewer" {
  42556. import { Nullable } from "babylonjs/types";
  42557. import { Scene } from "babylonjs/scene";
  42558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42559. import { Mesh } from "babylonjs/Meshes/mesh";
  42560. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42561. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42562. /**
  42563. * Used to show the physics impostor around the specific mesh
  42564. */
  42565. export class PhysicsViewer {
  42566. /** @hidden */
  42567. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42568. /** @hidden */
  42569. protected _meshes: Array<Nullable<AbstractMesh>>;
  42570. /** @hidden */
  42571. protected _scene: Nullable<Scene>;
  42572. /** @hidden */
  42573. protected _numMeshes: number;
  42574. /** @hidden */
  42575. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42576. private _renderFunction;
  42577. private _utilityLayer;
  42578. private _debugBoxMesh;
  42579. private _debugSphereMesh;
  42580. private _debugCylinderMesh;
  42581. private _debugMaterial;
  42582. private _debugMeshMeshes;
  42583. /**
  42584. * Creates a new PhysicsViewer
  42585. * @param scene defines the hosting scene
  42586. */
  42587. constructor(scene: Scene);
  42588. /** @hidden */
  42589. protected _updateDebugMeshes(): void;
  42590. /**
  42591. * Renders a specified physic impostor
  42592. * @param impostor defines the impostor to render
  42593. * @param targetMesh defines the mesh represented by the impostor
  42594. * @returns the new debug mesh used to render the impostor
  42595. */
  42596. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42597. /**
  42598. * Hides a specified physic impostor
  42599. * @param impostor defines the impostor to hide
  42600. */
  42601. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42602. private _getDebugMaterial;
  42603. private _getDebugBoxMesh;
  42604. private _getDebugSphereMesh;
  42605. private _getDebugCylinderMesh;
  42606. private _getDebugMeshMesh;
  42607. private _getDebugMesh;
  42608. /** Releases all resources */
  42609. dispose(): void;
  42610. }
  42611. }
  42612. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42613. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42614. import { Nullable } from "babylonjs/types";
  42615. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42616. import { Scene } from "babylonjs/scene";
  42617. /**
  42618. * Class containing static functions to help procedurally build meshes
  42619. */
  42620. export class LinesBuilder {
  42621. /**
  42622. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42623. * * 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
  42624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42625. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42626. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42627. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42628. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42629. * * 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
  42630. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42633. * @param name defines the name of the new line system
  42634. * @param options defines the options used to create the line system
  42635. * @param scene defines the hosting scene
  42636. * @returns a new line system mesh
  42637. */
  42638. static CreateLineSystem(name: string, options: {
  42639. lines: Vector3[][];
  42640. updatable?: boolean;
  42641. instance?: Nullable<LinesMesh>;
  42642. colors?: Nullable<Color4[][]>;
  42643. useVertexAlpha?: boolean;
  42644. }, scene: Nullable<Scene>): LinesMesh;
  42645. /**
  42646. * Creates a line mesh
  42647. * 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
  42648. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42649. * * The parameter `points` is an array successive Vector3
  42650. * * 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
  42651. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42652. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42653. * * When updating an instance, remember that only point positions can change, not the number of points
  42654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42656. * @param name defines the name of the new line system
  42657. * @param options defines the options used to create the line system
  42658. * @param scene defines the hosting scene
  42659. * @returns a new line mesh
  42660. */
  42661. static CreateLines(name: string, options: {
  42662. points: Vector3[];
  42663. updatable?: boolean;
  42664. instance?: Nullable<LinesMesh>;
  42665. colors?: Color4[];
  42666. useVertexAlpha?: boolean;
  42667. }, scene?: Nullable<Scene>): LinesMesh;
  42668. /**
  42669. * Creates a dashed line mesh
  42670. * * 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
  42671. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42672. * * The parameter `points` is an array successive Vector3
  42673. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42674. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42675. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42676. * * 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
  42677. * * When updating an instance, remember that only point positions can change, not the number of points
  42678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42679. * @param name defines the name of the mesh
  42680. * @param options defines the options used to create the mesh
  42681. * @param scene defines the hosting scene
  42682. * @returns the dashed line mesh
  42683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42684. */
  42685. static CreateDashedLines(name: string, options: {
  42686. points: Vector3[];
  42687. dashSize?: number;
  42688. gapSize?: number;
  42689. dashNb?: number;
  42690. updatable?: boolean;
  42691. instance?: LinesMesh;
  42692. }, scene?: Nullable<Scene>): LinesMesh;
  42693. }
  42694. }
  42695. declare module "babylonjs/Debug/rayHelper" {
  42696. import { Nullable } from "babylonjs/types";
  42697. import { Ray } from "babylonjs/Culling/ray";
  42698. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42699. import { Scene } from "babylonjs/scene";
  42700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42701. import "babylonjs/Meshes/Builders/linesBuilder";
  42702. /**
  42703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42704. * in order to better appreciate the issue one might have.
  42705. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42706. */
  42707. export class RayHelper {
  42708. /**
  42709. * Defines the ray we are currently tryin to visualize.
  42710. */
  42711. ray: Nullable<Ray>;
  42712. private _renderPoints;
  42713. private _renderLine;
  42714. private _renderFunction;
  42715. private _scene;
  42716. private _updateToMeshFunction;
  42717. private _attachedToMesh;
  42718. private _meshSpaceDirection;
  42719. private _meshSpaceOrigin;
  42720. /**
  42721. * Helper function to create a colored helper in a scene in one line.
  42722. * @param ray Defines the ray we are currently tryin to visualize
  42723. * @param scene Defines the scene the ray is used in
  42724. * @param color Defines the color we want to see the ray in
  42725. * @returns The newly created ray helper.
  42726. */
  42727. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42728. /**
  42729. * Instantiate a new ray helper.
  42730. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42731. * in order to better appreciate the issue one might have.
  42732. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42733. * @param ray Defines the ray we are currently tryin to visualize
  42734. */
  42735. constructor(ray: Ray);
  42736. /**
  42737. * Shows the ray we are willing to debug.
  42738. * @param scene Defines the scene the ray needs to be rendered in
  42739. * @param color Defines the color the ray needs to be rendered in
  42740. */
  42741. show(scene: Scene, color?: Color3): void;
  42742. /**
  42743. * Hides the ray we are debugging.
  42744. */
  42745. hide(): void;
  42746. private _render;
  42747. /**
  42748. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42749. * @param mesh Defines the mesh we want the helper attached to
  42750. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42751. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42752. * @param length Defines the length of the ray
  42753. */
  42754. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42755. /**
  42756. * Detach the ray helper from the mesh it has previously been attached to.
  42757. */
  42758. detachFromMesh(): void;
  42759. private _updateToMesh;
  42760. /**
  42761. * Dispose the helper and release its associated resources.
  42762. */
  42763. dispose(): void;
  42764. }
  42765. }
  42766. declare module "babylonjs/Debug/skeletonViewer" {
  42767. import { Color3 } from "babylonjs/Maths/math";
  42768. import { Scene } from "babylonjs/scene";
  42769. import { Nullable } from "babylonjs/types";
  42770. import { Skeleton } from "babylonjs/Bones/skeleton";
  42771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42772. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42773. /**
  42774. * Class used to render a debug view of a given skeleton
  42775. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42776. */
  42777. export class SkeletonViewer {
  42778. /** defines the skeleton to render */
  42779. skeleton: Skeleton;
  42780. /** defines the mesh attached to the skeleton */
  42781. mesh: AbstractMesh;
  42782. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42783. autoUpdateBonesMatrices: boolean;
  42784. /** defines the rendering group id to use with the viewer */
  42785. renderingGroupId: number;
  42786. /** Gets or sets the color used to render the skeleton */
  42787. color: Color3;
  42788. private _scene;
  42789. private _debugLines;
  42790. private _debugMesh;
  42791. private _isEnabled;
  42792. private _renderFunction;
  42793. private _utilityLayer;
  42794. /**
  42795. * Returns the mesh used to render the bones
  42796. */
  42797. readonly debugMesh: Nullable<LinesMesh>;
  42798. /**
  42799. * Creates a new SkeletonViewer
  42800. * @param skeleton defines the skeleton to render
  42801. * @param mesh defines the mesh attached to the skeleton
  42802. * @param scene defines the hosting scene
  42803. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42804. * @param renderingGroupId defines the rendering group id to use with the viewer
  42805. */
  42806. constructor(
  42807. /** defines the skeleton to render */
  42808. skeleton: Skeleton,
  42809. /** defines the mesh attached to the skeleton */
  42810. mesh: AbstractMesh, scene: Scene,
  42811. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42812. autoUpdateBonesMatrices?: boolean,
  42813. /** defines the rendering group id to use with the viewer */
  42814. renderingGroupId?: number);
  42815. /** Gets or sets a boolean indicating if the viewer is enabled */
  42816. isEnabled: boolean;
  42817. private _getBonePosition;
  42818. private _getLinesForBonesWithLength;
  42819. private _getLinesForBonesNoLength;
  42820. /** Update the viewer to sync with current skeleton state */
  42821. update(): void;
  42822. /** Release associated resources */
  42823. dispose(): void;
  42824. }
  42825. }
  42826. declare module "babylonjs/Debug/index" {
  42827. export * from "babylonjs/Debug/axesViewer";
  42828. export * from "babylonjs/Debug/boneAxesViewer";
  42829. export * from "babylonjs/Debug/debugLayer";
  42830. export * from "babylonjs/Debug/physicsViewer";
  42831. export * from "babylonjs/Debug/rayHelper";
  42832. export * from "babylonjs/Debug/skeletonViewer";
  42833. }
  42834. declare module "babylonjs/Engines/nullEngine" {
  42835. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42836. import { Scene } from "babylonjs/scene";
  42837. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42838. import { Engine } from "babylonjs/Engines/engine";
  42839. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42840. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42841. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42842. import { Effect } from "babylonjs/Materials/effect";
  42843. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42845. /**
  42846. * Options to create the null engine
  42847. */
  42848. export class NullEngineOptions {
  42849. /**
  42850. * Render width (Default: 512)
  42851. */
  42852. renderWidth: number;
  42853. /**
  42854. * Render height (Default: 256)
  42855. */
  42856. renderHeight: number;
  42857. /**
  42858. * Texture size (Default: 512)
  42859. */
  42860. textureSize: number;
  42861. /**
  42862. * If delta time between frames should be constant
  42863. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42864. */
  42865. deterministicLockstep: boolean;
  42866. /**
  42867. * Maximum about of steps between frames (Default: 4)
  42868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42869. */
  42870. lockstepMaxSteps: number;
  42871. }
  42872. /**
  42873. * The null engine class provides support for headless version of babylon.js.
  42874. * This can be used in server side scenario or for testing purposes
  42875. */
  42876. export class NullEngine extends Engine {
  42877. private _options;
  42878. /**
  42879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42880. */
  42881. isDeterministicLockStep(): boolean;
  42882. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42883. getLockstepMaxSteps(): number;
  42884. /**
  42885. * Sets hardware scaling, used to save performance if needed
  42886. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42887. */
  42888. getHardwareScalingLevel(): number;
  42889. constructor(options?: NullEngineOptions);
  42890. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42891. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42892. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42893. getRenderWidth(useScreen?: boolean): number;
  42894. getRenderHeight(useScreen?: boolean): number;
  42895. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42896. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42897. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42898. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42899. bindSamplers(effect: Effect): void;
  42900. enableEffect(effect: Effect): void;
  42901. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42902. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42903. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42904. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42905. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42906. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42907. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42908. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42909. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42910. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42911. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42912. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42913. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42914. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42915. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42916. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42917. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42918. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42919. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42920. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42921. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42922. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42923. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42924. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42925. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42926. bindBuffers(vertexBuffers: {
  42927. [key: string]: VertexBuffer;
  42928. }, indexBuffer: DataBuffer, effect: Effect): void;
  42929. wipeCaches(bruteForce?: boolean): void;
  42930. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42931. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42933. /** @hidden */
  42934. _createTexture(): WebGLTexture;
  42935. /** @hidden */
  42936. _releaseTexture(texture: InternalTexture): void;
  42937. 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;
  42938. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42939. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42940. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42941. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42942. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42943. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42944. areAllEffectsReady(): boolean;
  42945. /**
  42946. * @hidden
  42947. * Get the current error code of the webGL context
  42948. * @returns the error code
  42949. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42950. */
  42951. getError(): number;
  42952. /** @hidden */
  42953. _getUnpackAlignement(): number;
  42954. /** @hidden */
  42955. _unpackFlipY(value: boolean): void;
  42956. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42957. /**
  42958. * Updates a dynamic vertex buffer.
  42959. * @param vertexBuffer the vertex buffer to update
  42960. * @param data the data used to update the vertex buffer
  42961. * @param byteOffset the byte offset of the data (optional)
  42962. * @param byteLength the byte length of the data (optional)
  42963. */
  42964. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42965. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42966. /** @hidden */
  42967. _bindTexture(channel: number, texture: InternalTexture): void;
  42968. /** @hidden */
  42969. _releaseBuffer(buffer: DataBuffer): boolean;
  42970. releaseEffects(): void;
  42971. displayLoadingUI(): void;
  42972. hideLoadingUI(): void;
  42973. /** @hidden */
  42974. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42975. /** @hidden */
  42976. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42977. /** @hidden */
  42978. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42979. /** @hidden */
  42980. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42981. }
  42982. }
  42983. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42984. import { Nullable, int } from "babylonjs/types";
  42985. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42986. /** @hidden */
  42987. export class _OcclusionDataStorage {
  42988. /** @hidden */
  42989. occlusionInternalRetryCounter: number;
  42990. /** @hidden */
  42991. isOcclusionQueryInProgress: boolean;
  42992. /** @hidden */
  42993. isOccluded: boolean;
  42994. /** @hidden */
  42995. occlusionRetryCount: number;
  42996. /** @hidden */
  42997. occlusionType: number;
  42998. /** @hidden */
  42999. occlusionQueryAlgorithmType: number;
  43000. }
  43001. module "babylonjs/Engines/engine" {
  43002. interface Engine {
  43003. /**
  43004. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43005. * @return the new query
  43006. */
  43007. createQuery(): WebGLQuery;
  43008. /**
  43009. * Delete and release a webGL query
  43010. * @param query defines the query to delete
  43011. * @return the current engine
  43012. */
  43013. deleteQuery(query: WebGLQuery): Engine;
  43014. /**
  43015. * Check if a given query has resolved and got its value
  43016. * @param query defines the query to check
  43017. * @returns true if the query got its value
  43018. */
  43019. isQueryResultAvailable(query: WebGLQuery): boolean;
  43020. /**
  43021. * Gets the value of a given query
  43022. * @param query defines the query to check
  43023. * @returns the value of the query
  43024. */
  43025. getQueryResult(query: WebGLQuery): number;
  43026. /**
  43027. * Initiates an occlusion query
  43028. * @param algorithmType defines the algorithm to use
  43029. * @param query defines the query to use
  43030. * @returns the current engine
  43031. * @see http://doc.babylonjs.com/features/occlusionquery
  43032. */
  43033. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43034. /**
  43035. * Ends an occlusion query
  43036. * @see http://doc.babylonjs.com/features/occlusionquery
  43037. * @param algorithmType defines the algorithm to use
  43038. * @returns the current engine
  43039. */
  43040. endOcclusionQuery(algorithmType: number): Engine;
  43041. /**
  43042. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43043. * Please note that only one query can be issued at a time
  43044. * @returns a time token used to track the time span
  43045. */
  43046. startTimeQuery(): Nullable<_TimeToken>;
  43047. /**
  43048. * Ends a time query
  43049. * @param token defines the token used to measure the time span
  43050. * @returns the time spent (in ns)
  43051. */
  43052. endTimeQuery(token: _TimeToken): int;
  43053. /** @hidden */
  43054. _currentNonTimestampToken: Nullable<_TimeToken>;
  43055. /** @hidden */
  43056. _createTimeQuery(): WebGLQuery;
  43057. /** @hidden */
  43058. _deleteTimeQuery(query: WebGLQuery): void;
  43059. /** @hidden */
  43060. _getGlAlgorithmType(algorithmType: number): number;
  43061. /** @hidden */
  43062. _getTimeQueryResult(query: WebGLQuery): any;
  43063. /** @hidden */
  43064. _getTimeQueryAvailability(query: WebGLQuery): any;
  43065. }
  43066. }
  43067. module "babylonjs/Meshes/abstractMesh" {
  43068. interface AbstractMesh {
  43069. /**
  43070. * Backing filed
  43071. * @hidden
  43072. */
  43073. __occlusionDataStorage: _OcclusionDataStorage;
  43074. /**
  43075. * Access property
  43076. * @hidden
  43077. */
  43078. _occlusionDataStorage: _OcclusionDataStorage;
  43079. /**
  43080. * 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.
  43081. * The default value is -1 which means don't break the query and wait till the result
  43082. * @see http://doc.babylonjs.com/features/occlusionquery
  43083. */
  43084. occlusionRetryCount: number;
  43085. /**
  43086. * 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:
  43087. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43088. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43089. * * 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.
  43090. * @see http://doc.babylonjs.com/features/occlusionquery
  43091. */
  43092. occlusionType: number;
  43093. /**
  43094. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43095. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43096. * * 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.
  43097. * @see http://doc.babylonjs.com/features/occlusionquery
  43098. */
  43099. occlusionQueryAlgorithmType: number;
  43100. /**
  43101. * 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
  43102. * @see http://doc.babylonjs.com/features/occlusionquery
  43103. */
  43104. isOccluded: boolean;
  43105. /**
  43106. * Flag to check the progress status of the query
  43107. * @see http://doc.babylonjs.com/features/occlusionquery
  43108. */
  43109. isOcclusionQueryInProgress: boolean;
  43110. }
  43111. }
  43112. }
  43113. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43114. import { Nullable } from "babylonjs/types";
  43115. /** @hidden */
  43116. export var _forceTransformFeedbackToBundle: boolean;
  43117. module "babylonjs/Engines/engine" {
  43118. interface Engine {
  43119. /**
  43120. * Creates a webGL transform feedback object
  43121. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43122. * @returns the webGL transform feedback object
  43123. */
  43124. createTransformFeedback(): WebGLTransformFeedback;
  43125. /**
  43126. * Delete a webGL transform feedback object
  43127. * @param value defines the webGL transform feedback object to delete
  43128. */
  43129. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43130. /**
  43131. * Bind a webGL transform feedback object to the webgl context
  43132. * @param value defines the webGL transform feedback object to bind
  43133. */
  43134. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43135. /**
  43136. * Begins a transform feedback operation
  43137. * @param usePoints defines if points or triangles must be used
  43138. */
  43139. beginTransformFeedback(usePoints: boolean): void;
  43140. /**
  43141. * Ends a transform feedback operation
  43142. */
  43143. endTransformFeedback(): void;
  43144. /**
  43145. * Specify the varyings to use with transform feedback
  43146. * @param program defines the associated webGL program
  43147. * @param value defines the list of strings representing the varying names
  43148. */
  43149. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43150. /**
  43151. * Bind a webGL buffer for a transform feedback operation
  43152. * @param value defines the webGL buffer to bind
  43153. */
  43154. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43155. }
  43156. }
  43157. }
  43158. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43159. import { Scene } from "babylonjs/scene";
  43160. import { Engine } from "babylonjs/Engines/engine";
  43161. import { Texture } from "babylonjs/Materials/Textures/texture";
  43162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43163. import "babylonjs/Engines/Extensions/engine.multiRender";
  43164. /**
  43165. * Creation options of the multi render target texture.
  43166. */
  43167. export interface IMultiRenderTargetOptions {
  43168. /**
  43169. * Define if the texture needs to create mip maps after render.
  43170. */
  43171. generateMipMaps?: boolean;
  43172. /**
  43173. * Define the types of all the draw buffers we want to create
  43174. */
  43175. types?: number[];
  43176. /**
  43177. * Define the sampling modes of all the draw buffers we want to create
  43178. */
  43179. samplingModes?: number[];
  43180. /**
  43181. * Define if a depth buffer is required
  43182. */
  43183. generateDepthBuffer?: boolean;
  43184. /**
  43185. * Define if a stencil buffer is required
  43186. */
  43187. generateStencilBuffer?: boolean;
  43188. /**
  43189. * Define if a depth texture is required instead of a depth buffer
  43190. */
  43191. generateDepthTexture?: boolean;
  43192. /**
  43193. * Define the number of desired draw buffers
  43194. */
  43195. textureCount?: number;
  43196. /**
  43197. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43198. */
  43199. doNotChangeAspectRatio?: boolean;
  43200. /**
  43201. * Define the default type of the buffers we are creating
  43202. */
  43203. defaultType?: number;
  43204. }
  43205. /**
  43206. * A multi render target, like a render target provides the ability to render to a texture.
  43207. * Unlike the render target, it can render to several draw buffers in one draw.
  43208. * This is specially interesting in deferred rendering or for any effects requiring more than
  43209. * just one color from a single pass.
  43210. */
  43211. export class MultiRenderTarget extends RenderTargetTexture {
  43212. private _internalTextures;
  43213. private _textures;
  43214. private _multiRenderTargetOptions;
  43215. /**
  43216. * Get if draw buffers are currently supported by the used hardware and browser.
  43217. */
  43218. readonly isSupported: boolean;
  43219. /**
  43220. * Get the list of textures generated by the multi render target.
  43221. */
  43222. readonly textures: Texture[];
  43223. /**
  43224. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43225. */
  43226. readonly depthTexture: Texture;
  43227. /**
  43228. * Set the wrapping mode on U of all the textures we are rendering to.
  43229. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43230. */
  43231. wrapU: number;
  43232. /**
  43233. * Set the wrapping mode on V of all the textures we are rendering to.
  43234. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43235. */
  43236. wrapV: number;
  43237. /**
  43238. * Instantiate a new multi render target texture.
  43239. * A multi render target, like a render target provides the ability to render to a texture.
  43240. * Unlike the render target, it can render to several draw buffers in one draw.
  43241. * This is specially interesting in deferred rendering or for any effects requiring more than
  43242. * just one color from a single pass.
  43243. * @param name Define the name of the texture
  43244. * @param size Define the size of the buffers to render to
  43245. * @param count Define the number of target we are rendering into
  43246. * @param scene Define the scene the texture belongs to
  43247. * @param options Define the options used to create the multi render target
  43248. */
  43249. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43250. /** @hidden */
  43251. _rebuild(): void;
  43252. private _createInternalTextures;
  43253. private _createTextures;
  43254. /**
  43255. * Define the number of samples used if MSAA is enabled.
  43256. */
  43257. samples: number;
  43258. /**
  43259. * Resize all the textures in the multi render target.
  43260. * Be carrefull as it will recreate all the data in the new texture.
  43261. * @param size Define the new size
  43262. */
  43263. resize(size: any): void;
  43264. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43265. /**
  43266. * Dispose the render targets and their associated resources
  43267. */
  43268. dispose(): void;
  43269. /**
  43270. * Release all the underlying texture used as draw buffers.
  43271. */
  43272. releaseInternalTextures(): void;
  43273. }
  43274. }
  43275. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43276. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43277. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43278. import { Nullable } from "babylonjs/types";
  43279. module "babylonjs/Engines/engine" {
  43280. interface Engine {
  43281. /**
  43282. * Unbind a list of render target textures from the webGL context
  43283. * This is used only when drawBuffer extension or webGL2 are active
  43284. * @param textures defines the render target textures to unbind
  43285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43287. */
  43288. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43289. /**
  43290. * Create a multi render target texture
  43291. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43292. * @param size defines the size of the texture
  43293. * @param options defines the creation options
  43294. * @returns the cube texture as an InternalTexture
  43295. */
  43296. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43297. /**
  43298. * Update the sample count for a given multiple render target texture
  43299. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43300. * @param textures defines the textures to update
  43301. * @param samples defines the sample count to set
  43302. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43303. */
  43304. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43305. }
  43306. }
  43307. }
  43308. declare module "babylonjs/Engines/Extensions/index" {
  43309. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43310. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43311. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43312. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43313. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43314. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43315. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43316. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43317. }
  43318. declare module "babylonjs/Engines/index" {
  43319. export * from "babylonjs/Engines/constants";
  43320. export * from "babylonjs/Engines/engine";
  43321. export * from "babylonjs/Engines/engineStore";
  43322. export * from "babylonjs/Engines/nullEngine";
  43323. export * from "babylonjs/Engines/Extensions/index";
  43324. export * from "babylonjs/Engines/IPipelineContext";
  43325. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43326. }
  43327. declare module "babylonjs/Events/clipboardEvents" {
  43328. /**
  43329. * Gather the list of clipboard event types as constants.
  43330. */
  43331. export class ClipboardEventTypes {
  43332. /**
  43333. * The clipboard event is fired when a copy command is active (pressed).
  43334. */
  43335. static readonly COPY: number;
  43336. /**
  43337. * The clipboard event is fired when a cut command is active (pressed).
  43338. */
  43339. static readonly CUT: number;
  43340. /**
  43341. * The clipboard event is fired when a paste command is active (pressed).
  43342. */
  43343. static readonly PASTE: number;
  43344. }
  43345. /**
  43346. * This class is used to store clipboard related info for the onClipboardObservable event.
  43347. */
  43348. export class ClipboardInfo {
  43349. /**
  43350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43351. */
  43352. type: number;
  43353. /**
  43354. * Defines the related dom event
  43355. */
  43356. event: ClipboardEvent;
  43357. /**
  43358. *Creates an instance of ClipboardInfo.
  43359. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43360. * @param event Defines the related dom event
  43361. */
  43362. constructor(
  43363. /**
  43364. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43365. */
  43366. type: number,
  43367. /**
  43368. * Defines the related dom event
  43369. */
  43370. event: ClipboardEvent);
  43371. /**
  43372. * Get the clipboard event's type from the keycode.
  43373. * @param keyCode Defines the keyCode for the current keyboard event.
  43374. * @return {number}
  43375. */
  43376. static GetTypeFromCharacter(keyCode: number): number;
  43377. }
  43378. }
  43379. declare module "babylonjs/Events/index" {
  43380. export * from "babylonjs/Events/keyboardEvents";
  43381. export * from "babylonjs/Events/pointerEvents";
  43382. export * from "babylonjs/Events/clipboardEvents";
  43383. }
  43384. declare module "babylonjs/Loading/sceneLoader" {
  43385. import { Observable } from "babylonjs/Misc/observable";
  43386. import { Nullable } from "babylonjs/types";
  43387. import { Scene } from "babylonjs/scene";
  43388. import { Engine } from "babylonjs/Engines/engine";
  43389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43390. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43391. import { AssetContainer } from "babylonjs/assetContainer";
  43392. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43393. import { Skeleton } from "babylonjs/Bones/skeleton";
  43394. /**
  43395. * Class used to represent data loading progression
  43396. */
  43397. export class SceneLoaderProgressEvent {
  43398. /** defines if data length to load can be evaluated */
  43399. readonly lengthComputable: boolean;
  43400. /** defines the loaded data length */
  43401. readonly loaded: number;
  43402. /** defines the data length to load */
  43403. readonly total: number;
  43404. /**
  43405. * Create a new progress event
  43406. * @param lengthComputable defines if data length to load can be evaluated
  43407. * @param loaded defines the loaded data length
  43408. * @param total defines the data length to load
  43409. */
  43410. constructor(
  43411. /** defines if data length to load can be evaluated */
  43412. lengthComputable: boolean,
  43413. /** defines the loaded data length */
  43414. loaded: number,
  43415. /** defines the data length to load */
  43416. total: number);
  43417. /**
  43418. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43419. * @param event defines the source event
  43420. * @returns a new SceneLoaderProgressEvent
  43421. */
  43422. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43423. }
  43424. /**
  43425. * Interface used by SceneLoader plugins to define supported file extensions
  43426. */
  43427. export interface ISceneLoaderPluginExtensions {
  43428. /**
  43429. * Defines the list of supported extensions
  43430. */
  43431. [extension: string]: {
  43432. isBinary: boolean;
  43433. };
  43434. }
  43435. /**
  43436. * Interface used by SceneLoader plugin factory
  43437. */
  43438. export interface ISceneLoaderPluginFactory {
  43439. /**
  43440. * Defines the name of the factory
  43441. */
  43442. name: string;
  43443. /**
  43444. * Function called to create a new plugin
  43445. * @return the new plugin
  43446. */
  43447. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43448. /**
  43449. * Boolean indicating if the plugin can direct load specific data
  43450. */
  43451. canDirectLoad?: (data: string) => boolean;
  43452. }
  43453. /**
  43454. * Interface used to define a SceneLoader plugin
  43455. */
  43456. export interface ISceneLoaderPlugin {
  43457. /**
  43458. * The friendly name of this plugin.
  43459. */
  43460. name: string;
  43461. /**
  43462. * The file extensions supported by this plugin.
  43463. */
  43464. extensions: string | ISceneLoaderPluginExtensions;
  43465. /**
  43466. * Import meshes into a scene.
  43467. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43468. * @param scene The scene to import into
  43469. * @param data The data to import
  43470. * @param rootUrl The root url for scene and resources
  43471. * @param meshes The meshes array to import into
  43472. * @param particleSystems The particle systems array to import into
  43473. * @param skeletons The skeletons array to import into
  43474. * @param onError The callback when import fails
  43475. * @returns True if successful or false otherwise
  43476. */
  43477. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43478. /**
  43479. * Load into a scene.
  43480. * @param scene The scene to load into
  43481. * @param data The data to import
  43482. * @param rootUrl The root url for scene and resources
  43483. * @param onError The callback when import fails
  43484. * @returns true if successful or false otherwise
  43485. */
  43486. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43487. /**
  43488. * The callback that returns true if the data can be directly loaded.
  43489. */
  43490. canDirectLoad?: (data: string) => boolean;
  43491. /**
  43492. * The callback that allows custom handling of the root url based on the response url.
  43493. */
  43494. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43495. /**
  43496. * Load into an asset container.
  43497. * @param scene The scene to load into
  43498. * @param data The data to import
  43499. * @param rootUrl The root url for scene and resources
  43500. * @param onError The callback when import fails
  43501. * @returns The loaded asset container
  43502. */
  43503. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43504. }
  43505. /**
  43506. * Interface used to define an async SceneLoader plugin
  43507. */
  43508. export interface ISceneLoaderPluginAsync {
  43509. /**
  43510. * The friendly name of this plugin.
  43511. */
  43512. name: string;
  43513. /**
  43514. * The file extensions supported by this plugin.
  43515. */
  43516. extensions: string | ISceneLoaderPluginExtensions;
  43517. /**
  43518. * Import meshes into a scene.
  43519. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43520. * @param scene The scene to import into
  43521. * @param data The data to import
  43522. * @param rootUrl The root url for scene and resources
  43523. * @param onProgress The callback when the load progresses
  43524. * @param fileName Defines the name of the file to load
  43525. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43526. */
  43527. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43528. meshes: AbstractMesh[];
  43529. particleSystems: IParticleSystem[];
  43530. skeletons: Skeleton[];
  43531. animationGroups: AnimationGroup[];
  43532. }>;
  43533. /**
  43534. * Load into a scene.
  43535. * @param scene The scene to load into
  43536. * @param data The data to import
  43537. * @param rootUrl The root url for scene and resources
  43538. * @param onProgress The callback when the load progresses
  43539. * @param fileName Defines the name of the file to load
  43540. * @returns Nothing
  43541. */
  43542. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43543. /**
  43544. * The callback that returns true if the data can be directly loaded.
  43545. */
  43546. canDirectLoad?: (data: string) => boolean;
  43547. /**
  43548. * The callback that allows custom handling of the root url based on the response url.
  43549. */
  43550. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43551. /**
  43552. * Load into an asset container.
  43553. * @param scene The scene to load into
  43554. * @param data The data to import
  43555. * @param rootUrl The root url for scene and resources
  43556. * @param onProgress The callback when the load progresses
  43557. * @param fileName Defines the name of the file to load
  43558. * @returns The loaded asset container
  43559. */
  43560. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43561. }
  43562. /**
  43563. * Class used to load scene from various file formats using registered plugins
  43564. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43565. */
  43566. export class SceneLoader {
  43567. /**
  43568. * No logging while loading
  43569. */
  43570. static readonly NO_LOGGING: number;
  43571. /**
  43572. * Minimal logging while loading
  43573. */
  43574. static readonly MINIMAL_LOGGING: number;
  43575. /**
  43576. * Summary logging while loading
  43577. */
  43578. static readonly SUMMARY_LOGGING: number;
  43579. /**
  43580. * Detailled logging while loading
  43581. */
  43582. static readonly DETAILED_LOGGING: number;
  43583. /**
  43584. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43585. */
  43586. static ForceFullSceneLoadingForIncremental: boolean;
  43587. /**
  43588. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43589. */
  43590. static ShowLoadingScreen: boolean;
  43591. /**
  43592. * Defines the current logging level (while loading the scene)
  43593. * @ignorenaming
  43594. */
  43595. static loggingLevel: number;
  43596. /**
  43597. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43598. */
  43599. static CleanBoneMatrixWeights: boolean;
  43600. /**
  43601. * Event raised when a plugin is used to load a scene
  43602. */
  43603. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43604. private static _registeredPlugins;
  43605. private static _getDefaultPlugin;
  43606. private static _getPluginForExtension;
  43607. private static _getPluginForDirectLoad;
  43608. private static _getPluginForFilename;
  43609. private static _getDirectLoad;
  43610. private static _loadData;
  43611. private static _getFileInfo;
  43612. /**
  43613. * Gets a plugin that can load the given extension
  43614. * @param extension defines the extension to load
  43615. * @returns a plugin or null if none works
  43616. */
  43617. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43618. /**
  43619. * Gets a boolean indicating that the given extension can be loaded
  43620. * @param extension defines the extension to load
  43621. * @returns true if the extension is supported
  43622. */
  43623. static IsPluginForExtensionAvailable(extension: string): boolean;
  43624. /**
  43625. * Adds a new plugin to the list of registered plugins
  43626. * @param plugin defines the plugin to add
  43627. */
  43628. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43629. /**
  43630. * Import meshes into a scene
  43631. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43632. * @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)
  43633. * @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)
  43634. * @param scene the instance of BABYLON.Scene to append to
  43635. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43636. * @param onProgress a callback with a progress event for each file being loaded
  43637. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43638. * @param pluginExtension the extension used to determine the plugin
  43639. * @returns The loaded plugin
  43640. */
  43641. 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>;
  43642. /**
  43643. * Import meshes into a scene
  43644. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43645. * @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)
  43646. * @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)
  43647. * @param scene the instance of BABYLON.Scene to append to
  43648. * @param onProgress a callback with a progress event for each file being loaded
  43649. * @param pluginExtension the extension used to determine the plugin
  43650. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43651. */
  43652. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43653. meshes: AbstractMesh[];
  43654. particleSystems: IParticleSystem[];
  43655. skeletons: Skeleton[];
  43656. animationGroups: AnimationGroup[];
  43657. }>;
  43658. /**
  43659. * Load a scene
  43660. * @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)
  43661. * @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)
  43662. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43663. * @param onSuccess a callback with the scene when import succeeds
  43664. * @param onProgress a callback with a progress event for each file being loaded
  43665. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43666. * @param pluginExtension the extension used to determine the plugin
  43667. * @returns The loaded plugin
  43668. */
  43669. 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>;
  43670. /**
  43671. * Load a scene
  43672. * @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)
  43673. * @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)
  43674. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43675. * @param onProgress a callback with a progress event for each file being loaded
  43676. * @param pluginExtension the extension used to determine the plugin
  43677. * @returns The loaded scene
  43678. */
  43679. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43680. /**
  43681. * Append a scene
  43682. * @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)
  43683. * @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)
  43684. * @param scene is the instance of BABYLON.Scene to append to
  43685. * @param onSuccess a callback with the scene when import succeeds
  43686. * @param onProgress a callback with a progress event for each file being loaded
  43687. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43688. * @param pluginExtension the extension used to determine the plugin
  43689. * @returns The loaded plugin
  43690. */
  43691. 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>;
  43692. /**
  43693. * Append a scene
  43694. * @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)
  43695. * @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)
  43696. * @param scene is the instance of BABYLON.Scene to append to
  43697. * @param onProgress a callback with a progress event for each file being loaded
  43698. * @param pluginExtension the extension used to determine the plugin
  43699. * @returns The given scene
  43700. */
  43701. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43702. /**
  43703. * Load a scene into an asset container
  43704. * @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)
  43705. * @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)
  43706. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43707. * @param onSuccess a callback with the scene when import succeeds
  43708. * @param onProgress a callback with a progress event for each file being loaded
  43709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43710. * @param pluginExtension the extension used to determine the plugin
  43711. * @returns The loaded plugin
  43712. */
  43713. 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>;
  43714. /**
  43715. * Load a scene into an asset container
  43716. * @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)
  43717. * @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)
  43718. * @param scene is the instance of Scene to append to
  43719. * @param onProgress a callback with a progress event for each file being loaded
  43720. * @param pluginExtension the extension used to determine the plugin
  43721. * @returns The loaded asset container
  43722. */
  43723. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43724. }
  43725. }
  43726. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43727. import { Scene } from "babylonjs/scene";
  43728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43729. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43730. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43731. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43732. /**
  43733. * Google Daydream controller
  43734. */
  43735. export class DaydreamController extends WebVRController {
  43736. /**
  43737. * Base Url for the controller model.
  43738. */
  43739. static MODEL_BASE_URL: string;
  43740. /**
  43741. * File name for the controller model.
  43742. */
  43743. static MODEL_FILENAME: string;
  43744. /**
  43745. * Gamepad Id prefix used to identify Daydream Controller.
  43746. */
  43747. static readonly GAMEPAD_ID_PREFIX: string;
  43748. /**
  43749. * Creates a new DaydreamController from a gamepad
  43750. * @param vrGamepad the gamepad that the controller should be created from
  43751. */
  43752. constructor(vrGamepad: any);
  43753. /**
  43754. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43755. * @param scene scene in which to add meshes
  43756. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43757. */
  43758. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43759. /**
  43760. * Called once for each button that changed state since the last frame
  43761. * @param buttonIdx Which button index changed
  43762. * @param state New state of the button
  43763. * @param changes Which properties on the state changed since last frame
  43764. */
  43765. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43766. }
  43767. }
  43768. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43769. import { Scene } from "babylonjs/scene";
  43770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43771. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43772. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43773. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43774. /**
  43775. * Gear VR Controller
  43776. */
  43777. export class GearVRController extends WebVRController {
  43778. /**
  43779. * Base Url for the controller model.
  43780. */
  43781. static MODEL_BASE_URL: string;
  43782. /**
  43783. * File name for the controller model.
  43784. */
  43785. static MODEL_FILENAME: string;
  43786. /**
  43787. * Gamepad Id prefix used to identify this controller.
  43788. */
  43789. static readonly GAMEPAD_ID_PREFIX: string;
  43790. private readonly _buttonIndexToObservableNameMap;
  43791. /**
  43792. * Creates a new GearVRController from a gamepad
  43793. * @param vrGamepad the gamepad that the controller should be created from
  43794. */
  43795. constructor(vrGamepad: any);
  43796. /**
  43797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43798. * @param scene scene in which to add meshes
  43799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43800. */
  43801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43802. /**
  43803. * Called once for each button that changed state since the last frame
  43804. * @param buttonIdx Which button index changed
  43805. * @param state New state of the button
  43806. * @param changes Which properties on the state changed since last frame
  43807. */
  43808. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43809. }
  43810. }
  43811. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43812. import { Scene } from "babylonjs/scene";
  43813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43814. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43815. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43816. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43817. /**
  43818. * Generic Controller
  43819. */
  43820. export class GenericController extends WebVRController {
  43821. /**
  43822. * Base Url for the controller model.
  43823. */
  43824. static readonly MODEL_BASE_URL: string;
  43825. /**
  43826. * File name for the controller model.
  43827. */
  43828. static readonly MODEL_FILENAME: string;
  43829. /**
  43830. * Creates a new GenericController from a gamepad
  43831. * @param vrGamepad the gamepad that the controller should be created from
  43832. */
  43833. constructor(vrGamepad: any);
  43834. /**
  43835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43836. * @param scene scene in which to add meshes
  43837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43838. */
  43839. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43840. /**
  43841. * Called once for each button that changed state since the last frame
  43842. * @param buttonIdx Which button index changed
  43843. * @param state New state of the button
  43844. * @param changes Which properties on the state changed since last frame
  43845. */
  43846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43847. }
  43848. }
  43849. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43850. import { Observable } from "babylonjs/Misc/observable";
  43851. import { Scene } from "babylonjs/scene";
  43852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43853. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43854. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43855. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43856. /**
  43857. * Oculus Touch Controller
  43858. */
  43859. export class OculusTouchController extends WebVRController {
  43860. /**
  43861. * Base Url for the controller model.
  43862. */
  43863. static MODEL_BASE_URL: string;
  43864. /**
  43865. * File name for the left controller model.
  43866. */
  43867. static MODEL_LEFT_FILENAME: string;
  43868. /**
  43869. * File name for the right controller model.
  43870. */
  43871. static MODEL_RIGHT_FILENAME: string;
  43872. /**
  43873. * Fired when the secondary trigger on this controller is modified
  43874. */
  43875. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43876. /**
  43877. * Fired when the thumb rest on this controller is modified
  43878. */
  43879. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43880. /**
  43881. * Creates a new OculusTouchController from a gamepad
  43882. * @param vrGamepad the gamepad that the controller should be created from
  43883. */
  43884. constructor(vrGamepad: any);
  43885. /**
  43886. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43887. * @param scene scene in which to add meshes
  43888. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43889. */
  43890. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43891. /**
  43892. * Fired when the A button on this controller is modified
  43893. */
  43894. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43895. /**
  43896. * Fired when the B button on this controller is modified
  43897. */
  43898. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43899. /**
  43900. * Fired when the X button on this controller is modified
  43901. */
  43902. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43903. /**
  43904. * Fired when the Y button on this controller is modified
  43905. */
  43906. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43907. /**
  43908. * Called once for each button that changed state since the last frame
  43909. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43910. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43911. * 2) secondary trigger (same)
  43912. * 3) A (right) X (left), touch, pressed = value
  43913. * 4) B / Y
  43914. * 5) thumb rest
  43915. * @param buttonIdx Which button index changed
  43916. * @param state New state of the button
  43917. * @param changes Which properties on the state changed since last frame
  43918. */
  43919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43920. }
  43921. }
  43922. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43923. import { Scene } from "babylonjs/scene";
  43924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43925. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43926. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43927. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43928. import { Observable } from "babylonjs/Misc/observable";
  43929. /**
  43930. * Vive Controller
  43931. */
  43932. export class ViveController extends WebVRController {
  43933. /**
  43934. * Base Url for the controller model.
  43935. */
  43936. static MODEL_BASE_URL: string;
  43937. /**
  43938. * File name for the controller model.
  43939. */
  43940. static MODEL_FILENAME: string;
  43941. /**
  43942. * Creates a new ViveController from a gamepad
  43943. * @param vrGamepad the gamepad that the controller should be created from
  43944. */
  43945. constructor(vrGamepad: any);
  43946. /**
  43947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43948. * @param scene scene in which to add meshes
  43949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43950. */
  43951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43952. /**
  43953. * Fired when the left button on this controller is modified
  43954. */
  43955. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43956. /**
  43957. * Fired when the right button on this controller is modified
  43958. */
  43959. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43960. /**
  43961. * Fired when the menu button on this controller is modified
  43962. */
  43963. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43964. /**
  43965. * Called once for each button that changed state since the last frame
  43966. * Vive mapping:
  43967. * 0: touchpad
  43968. * 1: trigger
  43969. * 2: left AND right buttons
  43970. * 3: menu button
  43971. * @param buttonIdx Which button index changed
  43972. * @param state New state of the button
  43973. * @param changes Which properties on the state changed since last frame
  43974. */
  43975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43976. }
  43977. }
  43978. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43979. import { Observable } from "babylonjs/Misc/observable";
  43980. import { Scene } from "babylonjs/scene";
  43981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43982. import { Ray } from "babylonjs/Culling/ray";
  43983. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43984. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43985. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43986. /**
  43987. * Defines the WindowsMotionController object that the state of the windows motion controller
  43988. */
  43989. export class WindowsMotionController extends WebVRController {
  43990. /**
  43991. * The base url used to load the left and right controller models
  43992. */
  43993. static MODEL_BASE_URL: string;
  43994. /**
  43995. * The name of the left controller model file
  43996. */
  43997. static MODEL_LEFT_FILENAME: string;
  43998. /**
  43999. * The name of the right controller model file
  44000. */
  44001. static MODEL_RIGHT_FILENAME: string;
  44002. /**
  44003. * The controller name prefix for this controller type
  44004. */
  44005. static readonly GAMEPAD_ID_PREFIX: string;
  44006. /**
  44007. * The controller id pattern for this controller type
  44008. */
  44009. private static readonly GAMEPAD_ID_PATTERN;
  44010. private _loadedMeshInfo;
  44011. private readonly _mapping;
  44012. /**
  44013. * Fired when the trackpad on this controller is clicked
  44014. */
  44015. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44016. /**
  44017. * Fired when the trackpad on this controller is modified
  44018. */
  44019. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44020. /**
  44021. * The current x and y values of this controller's trackpad
  44022. */
  44023. trackpad: StickValues;
  44024. /**
  44025. * Creates a new WindowsMotionController from a gamepad
  44026. * @param vrGamepad the gamepad that the controller should be created from
  44027. */
  44028. constructor(vrGamepad: any);
  44029. /**
  44030. * Fired when the trigger on this controller is modified
  44031. */
  44032. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44033. /**
  44034. * Fired when the menu button on this controller is modified
  44035. */
  44036. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44037. /**
  44038. * Fired when the grip button on this controller is modified
  44039. */
  44040. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Fired when the thumbstick button on this controller is modified
  44043. */
  44044. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44045. /**
  44046. * Fired when the touchpad button on this controller is modified
  44047. */
  44048. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44049. /**
  44050. * Fired when the touchpad values on this controller are modified
  44051. */
  44052. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44053. private _updateTrackpad;
  44054. /**
  44055. * Called once per frame by the engine.
  44056. */
  44057. update(): void;
  44058. /**
  44059. * Called once for each button that changed state since the last frame
  44060. * @param buttonIdx Which button index changed
  44061. * @param state New state of the button
  44062. * @param changes Which properties on the state changed since last frame
  44063. */
  44064. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44065. /**
  44066. * Moves the buttons on the controller mesh based on their current state
  44067. * @param buttonName the name of the button to move
  44068. * @param buttonValue the value of the button which determines the buttons new position
  44069. */
  44070. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44071. /**
  44072. * Moves the axis on the controller mesh based on its current state
  44073. * @param axis the index of the axis
  44074. * @param axisValue the value of the axis which determines the meshes new position
  44075. * @hidden
  44076. */
  44077. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44078. /**
  44079. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44080. * @param scene scene in which to add meshes
  44081. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44082. */
  44083. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44084. /**
  44085. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44086. * can be transformed by button presses and axes values, based on this._mapping.
  44087. *
  44088. * @param scene scene in which the meshes exist
  44089. * @param meshes list of meshes that make up the controller model to process
  44090. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44091. */
  44092. private processModel;
  44093. private createMeshInfo;
  44094. /**
  44095. * Gets the ray of the controller in the direction the controller is pointing
  44096. * @param length the length the resulting ray should be
  44097. * @returns a ray in the direction the controller is pointing
  44098. */
  44099. getForwardRay(length?: number): Ray;
  44100. /**
  44101. * Disposes of the controller
  44102. */
  44103. dispose(): void;
  44104. }
  44105. }
  44106. declare module "babylonjs/Gamepads/Controllers/index" {
  44107. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44108. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44109. export * from "babylonjs/Gamepads/Controllers/genericController";
  44110. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44111. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44112. export * from "babylonjs/Gamepads/Controllers/viveController";
  44113. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44114. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44115. }
  44116. declare module "babylonjs/Gamepads/index" {
  44117. export * from "babylonjs/Gamepads/Controllers/index";
  44118. export * from "babylonjs/Gamepads/gamepad";
  44119. export * from "babylonjs/Gamepads/gamepadManager";
  44120. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44121. export * from "babylonjs/Gamepads/xboxGamepad";
  44122. }
  44123. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44124. import { Observable } from "babylonjs/Misc/observable";
  44125. import { Nullable } from "babylonjs/types";
  44126. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44128. import { Mesh } from "babylonjs/Meshes/mesh";
  44129. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44130. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44131. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44132. /**
  44133. * Single axis scale gizmo
  44134. */
  44135. export class AxisScaleGizmo extends Gizmo {
  44136. private _coloredMaterial;
  44137. /**
  44138. * Drag behavior responsible for the gizmos dragging interactions
  44139. */
  44140. dragBehavior: PointerDragBehavior;
  44141. private _pointerObserver;
  44142. /**
  44143. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44144. */
  44145. snapDistance: number;
  44146. /**
  44147. * Event that fires each time the gizmo snaps to a new location.
  44148. * * snapDistance is the the change in distance
  44149. */
  44150. onSnapObservable: Observable<{
  44151. snapDistance: number;
  44152. }>;
  44153. /**
  44154. * If the scaling operation should be done on all axis (default: false)
  44155. */
  44156. uniformScaling: boolean;
  44157. /**
  44158. * Creates an AxisScaleGizmo
  44159. * @param gizmoLayer The utility layer the gizmo will be added to
  44160. * @param dragAxis The axis which the gizmo will be able to scale on
  44161. * @param color The color of the gizmo
  44162. */
  44163. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44164. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44165. /**
  44166. * Disposes of the gizmo
  44167. */
  44168. dispose(): void;
  44169. /**
  44170. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44171. * @param mesh The mesh to replace the default mesh of the gizmo
  44172. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44173. */
  44174. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44175. }
  44176. }
  44177. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44178. import { Observable } from "babylonjs/Misc/observable";
  44179. import { Nullable } from "babylonjs/types";
  44180. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44182. import { Mesh } from "babylonjs/Meshes/mesh";
  44183. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44184. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44185. import "babylonjs/Meshes/Builders/boxBuilder";
  44186. /**
  44187. * Bounding box gizmo
  44188. */
  44189. export class BoundingBoxGizmo extends Gizmo {
  44190. private _lineBoundingBox;
  44191. private _rotateSpheresParent;
  44192. private _scaleBoxesParent;
  44193. private _boundingDimensions;
  44194. private _renderObserver;
  44195. private _pointerObserver;
  44196. private _scaleDragSpeed;
  44197. private _tmpQuaternion;
  44198. private _tmpVector;
  44199. private _tmpRotationMatrix;
  44200. /**
  44201. * 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)
  44202. */
  44203. ignoreChildren: boolean;
  44204. /**
  44205. * 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)
  44206. */
  44207. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44208. /**
  44209. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44210. */
  44211. rotationSphereSize: number;
  44212. /**
  44213. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44214. */
  44215. scaleBoxSize: number;
  44216. /**
  44217. * 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)
  44218. */
  44219. fixedDragMeshScreenSize: boolean;
  44220. /**
  44221. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44222. */
  44223. fixedDragMeshScreenSizeDistanceFactor: number;
  44224. /**
  44225. * Fired when a rotation sphere or scale box is dragged
  44226. */
  44227. onDragStartObservable: Observable<{}>;
  44228. /**
  44229. * Fired when a scale box is dragged
  44230. */
  44231. onScaleBoxDragObservable: Observable<{}>;
  44232. /**
  44233. * Fired when a scale box drag is ended
  44234. */
  44235. onScaleBoxDragEndObservable: Observable<{}>;
  44236. /**
  44237. * Fired when a rotation sphere is dragged
  44238. */
  44239. onRotationSphereDragObservable: Observable<{}>;
  44240. /**
  44241. * Fired when a rotation sphere drag is ended
  44242. */
  44243. onRotationSphereDragEndObservable: Observable<{}>;
  44244. /**
  44245. * 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)
  44246. */
  44247. scalePivot: Nullable<Vector3>;
  44248. /**
  44249. * Mesh used as a pivot to rotate the attached mesh
  44250. */
  44251. private _anchorMesh;
  44252. private _existingMeshScale;
  44253. private _dragMesh;
  44254. private pointerDragBehavior;
  44255. private coloredMaterial;
  44256. private hoverColoredMaterial;
  44257. /**
  44258. * Sets the color of the bounding box gizmo
  44259. * @param color the color to set
  44260. */
  44261. setColor(color: Color3): void;
  44262. /**
  44263. * Creates an BoundingBoxGizmo
  44264. * @param gizmoLayer The utility layer the gizmo will be added to
  44265. * @param color The color of the gizmo
  44266. */
  44267. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44269. private _selectNode;
  44270. /**
  44271. * Updates the bounding box information for the Gizmo
  44272. */
  44273. updateBoundingBox(): void;
  44274. private _updateRotationSpheres;
  44275. private _updateScaleBoxes;
  44276. /**
  44277. * Enables rotation on the specified axis and disables rotation on the others
  44278. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44279. */
  44280. setEnabledRotationAxis(axis: string): void;
  44281. /**
  44282. * Enables/disables scaling
  44283. * @param enable if scaling should be enabled
  44284. */
  44285. setEnabledScaling(enable: boolean): void;
  44286. private _updateDummy;
  44287. /**
  44288. * Enables a pointer drag behavior on the bounding box of the gizmo
  44289. */
  44290. enableDragBehavior(): void;
  44291. /**
  44292. * Disposes of the gizmo
  44293. */
  44294. dispose(): void;
  44295. /**
  44296. * 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)
  44297. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44298. * @returns the bounding box mesh with the passed in mesh as a child
  44299. */
  44300. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44301. /**
  44302. * CustomMeshes are not supported by this gizmo
  44303. * @param mesh The mesh to replace the default mesh of the gizmo
  44304. */
  44305. setCustomMesh(mesh: Mesh): void;
  44306. }
  44307. }
  44308. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44309. import { Observable } from "babylonjs/Misc/observable";
  44310. import { Nullable } from "babylonjs/types";
  44311. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44313. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44314. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44315. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44316. import "babylonjs/Meshes/Builders/linesBuilder";
  44317. /**
  44318. * Single plane rotation gizmo
  44319. */
  44320. export class PlaneRotationGizmo extends Gizmo {
  44321. /**
  44322. * Drag behavior responsible for the gizmos dragging interactions
  44323. */
  44324. dragBehavior: PointerDragBehavior;
  44325. private _pointerObserver;
  44326. /**
  44327. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44328. */
  44329. snapDistance: number;
  44330. /**
  44331. * Event that fires each time the gizmo snaps to a new location.
  44332. * * snapDistance is the the change in distance
  44333. */
  44334. onSnapObservable: Observable<{
  44335. snapDistance: number;
  44336. }>;
  44337. /**
  44338. * Creates a PlaneRotationGizmo
  44339. * @param gizmoLayer The utility layer the gizmo will be added to
  44340. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44341. * @param color The color of the gizmo
  44342. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44343. */
  44344. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44345. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44346. /**
  44347. * Disposes of the gizmo
  44348. */
  44349. dispose(): void;
  44350. }
  44351. }
  44352. declare module "babylonjs/Gizmos/rotationGizmo" {
  44353. import { Observable } from "babylonjs/Misc/observable";
  44354. import { Nullable } from "babylonjs/types";
  44355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44356. import { Mesh } from "babylonjs/Meshes/mesh";
  44357. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44358. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44359. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44360. /**
  44361. * Gizmo that enables rotating a mesh along 3 axis
  44362. */
  44363. export class RotationGizmo extends Gizmo {
  44364. /**
  44365. * Internal gizmo used for interactions on the x axis
  44366. */
  44367. xGizmo: PlaneRotationGizmo;
  44368. /**
  44369. * Internal gizmo used for interactions on the y axis
  44370. */
  44371. yGizmo: PlaneRotationGizmo;
  44372. /**
  44373. * Internal gizmo used for interactions on the z axis
  44374. */
  44375. zGizmo: PlaneRotationGizmo;
  44376. /** Fires an event when any of it's sub gizmos are dragged */
  44377. onDragStartObservable: Observable<{}>;
  44378. /** Fires an event when any of it's sub gizmos are released from dragging */
  44379. onDragEndObservable: Observable<{}>;
  44380. attachedMesh: Nullable<AbstractMesh>;
  44381. /**
  44382. * Creates a RotationGizmo
  44383. * @param gizmoLayer The utility layer the gizmo will be added to
  44384. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44385. */
  44386. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44387. updateGizmoRotationToMatchAttachedMesh: boolean;
  44388. /**
  44389. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44390. */
  44391. snapDistance: number;
  44392. /**
  44393. * Ratio for the scale of the gizmo (Default: 1)
  44394. */
  44395. scaleRatio: number;
  44396. /**
  44397. * Disposes of the gizmo
  44398. */
  44399. dispose(): void;
  44400. /**
  44401. * CustomMeshes are not supported by this gizmo
  44402. * @param mesh The mesh to replace the default mesh of the gizmo
  44403. */
  44404. setCustomMesh(mesh: Mesh): void;
  44405. }
  44406. }
  44407. declare module "babylonjs/Gizmos/positionGizmo" {
  44408. import { Observable } from "babylonjs/Misc/observable";
  44409. import { Nullable } from "babylonjs/types";
  44410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44411. import { Mesh } from "babylonjs/Meshes/mesh";
  44412. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44413. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44414. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44415. /**
  44416. * Gizmo that enables dragging a mesh along 3 axis
  44417. */
  44418. export class PositionGizmo extends Gizmo {
  44419. /**
  44420. * Internal gizmo used for interactions on the x axis
  44421. */
  44422. xGizmo: AxisDragGizmo;
  44423. /**
  44424. * Internal gizmo used for interactions on the y axis
  44425. */
  44426. yGizmo: AxisDragGizmo;
  44427. /**
  44428. * Internal gizmo used for interactions on the z axis
  44429. */
  44430. zGizmo: AxisDragGizmo;
  44431. /** Fires an event when any of it's sub gizmos are dragged */
  44432. onDragStartObservable: Observable<{}>;
  44433. /** Fires an event when any of it's sub gizmos are released from dragging */
  44434. onDragEndObservable: Observable<{}>;
  44435. attachedMesh: Nullable<AbstractMesh>;
  44436. /**
  44437. * Creates a PositionGizmo
  44438. * @param gizmoLayer The utility layer the gizmo will be added to
  44439. */
  44440. constructor(gizmoLayer?: UtilityLayerRenderer);
  44441. updateGizmoRotationToMatchAttachedMesh: boolean;
  44442. /**
  44443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44444. */
  44445. snapDistance: number;
  44446. /**
  44447. * Ratio for the scale of the gizmo (Default: 1)
  44448. */
  44449. scaleRatio: number;
  44450. /**
  44451. * Disposes of the gizmo
  44452. */
  44453. dispose(): void;
  44454. /**
  44455. * CustomMeshes are not supported by this gizmo
  44456. * @param mesh The mesh to replace the default mesh of the gizmo
  44457. */
  44458. setCustomMesh(mesh: Mesh): void;
  44459. }
  44460. }
  44461. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44462. import { Scene } from "babylonjs/scene";
  44463. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44464. import { Mesh } from "babylonjs/Meshes/mesh";
  44465. import { Nullable } from "babylonjs/types";
  44466. /**
  44467. * Class containing static functions to help procedurally build meshes
  44468. */
  44469. export class PolyhedronBuilder {
  44470. /**
  44471. * Creates a polyhedron mesh
  44472. * * 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
  44473. * * The parameter `size` (positive float, default 1) sets the polygon size
  44474. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44475. * * 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`
  44476. * * 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
  44477. * * 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)`)
  44478. * * 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
  44479. * * 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
  44480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44483. * @param name defines the name of the mesh
  44484. * @param options defines the options used to create the mesh
  44485. * @param scene defines the hosting scene
  44486. * @returns the polyhedron mesh
  44487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44488. */
  44489. static CreatePolyhedron(name: string, options: {
  44490. type?: number;
  44491. size?: number;
  44492. sizeX?: number;
  44493. sizeY?: number;
  44494. sizeZ?: number;
  44495. custom?: any;
  44496. faceUV?: Vector4[];
  44497. faceColors?: Color4[];
  44498. flat?: boolean;
  44499. updatable?: boolean;
  44500. sideOrientation?: number;
  44501. frontUVs?: Vector4;
  44502. backUVs?: Vector4;
  44503. }, scene?: Nullable<Scene>): Mesh;
  44504. }
  44505. }
  44506. declare module "babylonjs/Gizmos/scaleGizmo" {
  44507. import { Observable } from "babylonjs/Misc/observable";
  44508. import { Nullable } from "babylonjs/types";
  44509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44511. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44513. /**
  44514. * Gizmo that enables scaling a mesh along 3 axis
  44515. */
  44516. export class ScaleGizmo extends Gizmo {
  44517. /**
  44518. * Internal gizmo used for interactions on the x axis
  44519. */
  44520. xGizmo: AxisScaleGizmo;
  44521. /**
  44522. * Internal gizmo used for interactions on the y axis
  44523. */
  44524. yGizmo: AxisScaleGizmo;
  44525. /**
  44526. * Internal gizmo used for interactions on the z axis
  44527. */
  44528. zGizmo: AxisScaleGizmo;
  44529. /**
  44530. * Internal gizmo used to scale all axis equally
  44531. */
  44532. uniformScaleGizmo: AxisScaleGizmo;
  44533. /** Fires an event when any of it's sub gizmos are dragged */
  44534. onDragStartObservable: Observable<{}>;
  44535. /** Fires an event when any of it's sub gizmos are released from dragging */
  44536. onDragEndObservable: Observable<{}>;
  44537. attachedMesh: Nullable<AbstractMesh>;
  44538. /**
  44539. * Creates a ScaleGizmo
  44540. * @param gizmoLayer The utility layer the gizmo will be added to
  44541. */
  44542. constructor(gizmoLayer?: UtilityLayerRenderer);
  44543. updateGizmoRotationToMatchAttachedMesh: boolean;
  44544. /**
  44545. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44546. */
  44547. snapDistance: number;
  44548. /**
  44549. * Ratio for the scale of the gizmo (Default: 1)
  44550. */
  44551. scaleRatio: number;
  44552. /**
  44553. * Disposes of the gizmo
  44554. */
  44555. dispose(): void;
  44556. }
  44557. }
  44558. declare module "babylonjs/Gizmos/gizmoManager" {
  44559. import { Observable } from "babylonjs/Misc/observable";
  44560. import { Nullable } from "babylonjs/types";
  44561. import { Scene, IDisposable } from "babylonjs/scene";
  44562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44563. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44564. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44565. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44566. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44567. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44568. /**
  44569. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44570. */
  44571. export class GizmoManager implements IDisposable {
  44572. private scene;
  44573. /**
  44574. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44575. */
  44576. gizmos: {
  44577. positionGizmo: Nullable<PositionGizmo>;
  44578. rotationGizmo: Nullable<RotationGizmo>;
  44579. scaleGizmo: Nullable<ScaleGizmo>;
  44580. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44581. };
  44582. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44583. clearGizmoOnEmptyPointerEvent: boolean;
  44584. /** Fires an event when the manager is attached to a mesh */
  44585. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44586. private _gizmosEnabled;
  44587. private _pointerObserver;
  44588. private _attachedMesh;
  44589. private _boundingBoxColor;
  44590. private _defaultUtilityLayer;
  44591. private _defaultKeepDepthUtilityLayer;
  44592. /**
  44593. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44594. */
  44595. boundingBoxDragBehavior: SixDofDragBehavior;
  44596. /**
  44597. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44598. */
  44599. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44600. /**
  44601. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44602. */
  44603. usePointerToAttachGizmos: boolean;
  44604. /**
  44605. * Instatiates a gizmo manager
  44606. * @param scene the scene to overlay the gizmos on top of
  44607. */
  44608. constructor(scene: Scene);
  44609. /**
  44610. * Attaches a set of gizmos to the specified mesh
  44611. * @param mesh The mesh the gizmo's should be attached to
  44612. */
  44613. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44614. /**
  44615. * If the position gizmo is enabled
  44616. */
  44617. positionGizmoEnabled: boolean;
  44618. /**
  44619. * If the rotation gizmo is enabled
  44620. */
  44621. rotationGizmoEnabled: boolean;
  44622. /**
  44623. * If the scale gizmo is enabled
  44624. */
  44625. scaleGizmoEnabled: boolean;
  44626. /**
  44627. * If the boundingBox gizmo is enabled
  44628. */
  44629. boundingBoxGizmoEnabled: boolean;
  44630. /**
  44631. * Disposes of the gizmo manager
  44632. */
  44633. dispose(): void;
  44634. }
  44635. }
  44636. declare module "babylonjs/Lights/directionalLight" {
  44637. import { Camera } from "babylonjs/Cameras/camera";
  44638. import { Scene } from "babylonjs/scene";
  44639. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44641. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44642. import { Effect } from "babylonjs/Materials/effect";
  44643. /**
  44644. * A directional light is defined by a direction (what a surprise!).
  44645. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44646. * 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.
  44647. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44648. */
  44649. export class DirectionalLight extends ShadowLight {
  44650. private _shadowFrustumSize;
  44651. /**
  44652. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44653. */
  44654. /**
  44655. * Specifies a fix frustum size for the shadow generation.
  44656. */
  44657. shadowFrustumSize: number;
  44658. private _shadowOrthoScale;
  44659. /**
  44660. * Gets the shadow projection scale against the optimal computed one.
  44661. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44662. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44663. */
  44664. /**
  44665. * Sets the shadow projection scale against the optimal computed one.
  44666. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44667. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44668. */
  44669. shadowOrthoScale: number;
  44670. /**
  44671. * Automatically compute the projection matrix to best fit (including all the casters)
  44672. * on each frame.
  44673. */
  44674. autoUpdateExtends: boolean;
  44675. private _orthoLeft;
  44676. private _orthoRight;
  44677. private _orthoTop;
  44678. private _orthoBottom;
  44679. /**
  44680. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44681. * The directional light is emitted from everywhere in the given direction.
  44682. * It can cast shadows.
  44683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44684. * @param name The friendly name of the light
  44685. * @param direction The direction of the light
  44686. * @param scene The scene the light belongs to
  44687. */
  44688. constructor(name: string, direction: Vector3, scene: Scene);
  44689. /**
  44690. * Returns the string "DirectionalLight".
  44691. * @return The class name
  44692. */
  44693. getClassName(): string;
  44694. /**
  44695. * Returns the integer 1.
  44696. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44697. */
  44698. getTypeID(): number;
  44699. /**
  44700. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44701. * Returns the DirectionalLight Shadow projection matrix.
  44702. */
  44703. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44704. /**
  44705. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44706. * Returns the DirectionalLight Shadow projection matrix.
  44707. */
  44708. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44709. /**
  44710. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44711. * Returns the DirectionalLight Shadow projection matrix.
  44712. */
  44713. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44714. protected _buildUniformLayout(): void;
  44715. /**
  44716. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44717. * @param effect The effect to update
  44718. * @param lightIndex The index of the light in the effect to update
  44719. * @returns The directional light
  44720. */
  44721. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44722. /**
  44723. * Gets the minZ used for shadow according to both the scene and the light.
  44724. *
  44725. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44726. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44727. * @param activeCamera The camera we are returning the min for
  44728. * @returns the depth min z
  44729. */
  44730. getDepthMinZ(activeCamera: Camera): number;
  44731. /**
  44732. * Gets the maxZ used for shadow according to both the scene and the light.
  44733. *
  44734. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44735. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44736. * @param activeCamera The camera we are returning the max for
  44737. * @returns the depth max z
  44738. */
  44739. getDepthMaxZ(activeCamera: Camera): number;
  44740. /**
  44741. * Prepares the list of defines specific to the light type.
  44742. * @param defines the list of defines
  44743. * @param lightIndex defines the index of the light for the effect
  44744. */
  44745. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44746. }
  44747. }
  44748. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44749. import { Mesh } from "babylonjs/Meshes/mesh";
  44750. /**
  44751. * Class containing static functions to help procedurally build meshes
  44752. */
  44753. export class HemisphereBuilder {
  44754. /**
  44755. * Creates a hemisphere mesh
  44756. * @param name defines the name of the mesh
  44757. * @param options defines the options used to create the mesh
  44758. * @param scene defines the hosting scene
  44759. * @returns the hemisphere mesh
  44760. */
  44761. static CreateHemisphere(name: string, options: {
  44762. segments?: number;
  44763. diameter?: number;
  44764. sideOrientation?: number;
  44765. }, scene: any): Mesh;
  44766. }
  44767. }
  44768. declare module "babylonjs/Lights/spotLight" {
  44769. import { Nullable } from "babylonjs/types";
  44770. import { Scene } from "babylonjs/scene";
  44771. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44773. import { Effect } from "babylonjs/Materials/effect";
  44774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44775. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44776. /**
  44777. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44778. * These values define a cone of light starting from the position, emitting toward the direction.
  44779. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44780. * and the exponent defines the speed of the decay of the light with distance (reach).
  44781. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44782. */
  44783. export class SpotLight extends ShadowLight {
  44784. private _angle;
  44785. private _innerAngle;
  44786. private _cosHalfAngle;
  44787. private _lightAngleScale;
  44788. private _lightAngleOffset;
  44789. /**
  44790. * Gets the cone angle of the spot light in Radians.
  44791. */
  44792. /**
  44793. * Sets the cone angle of the spot light in Radians.
  44794. */
  44795. angle: number;
  44796. /**
  44797. * Only used in gltf falloff mode, this defines the angle where
  44798. * the directional falloff will start before cutting at angle which could be seen
  44799. * as outer angle.
  44800. */
  44801. /**
  44802. * Only used in gltf falloff mode, this defines the angle where
  44803. * the directional falloff will start before cutting at angle which could be seen
  44804. * as outer angle.
  44805. */
  44806. innerAngle: number;
  44807. private _shadowAngleScale;
  44808. /**
  44809. * Allows scaling the angle of the light for shadow generation only.
  44810. */
  44811. /**
  44812. * Allows scaling the angle of the light for shadow generation only.
  44813. */
  44814. shadowAngleScale: number;
  44815. /**
  44816. * The light decay speed with the distance from the emission spot.
  44817. */
  44818. exponent: number;
  44819. private _projectionTextureMatrix;
  44820. /**
  44821. * Allows reading the projecton texture
  44822. */
  44823. readonly projectionTextureMatrix: Matrix;
  44824. protected _projectionTextureLightNear: number;
  44825. /**
  44826. * Gets the near clip of the Spotlight for texture projection.
  44827. */
  44828. /**
  44829. * Sets the near clip of the Spotlight for texture projection.
  44830. */
  44831. projectionTextureLightNear: number;
  44832. protected _projectionTextureLightFar: number;
  44833. /**
  44834. * Gets the far clip of the Spotlight for texture projection.
  44835. */
  44836. /**
  44837. * Sets the far clip of the Spotlight for texture projection.
  44838. */
  44839. projectionTextureLightFar: number;
  44840. protected _projectionTextureUpDirection: Vector3;
  44841. /**
  44842. * Gets the Up vector of the Spotlight for texture projection.
  44843. */
  44844. /**
  44845. * Sets the Up vector of the Spotlight for texture projection.
  44846. */
  44847. projectionTextureUpDirection: Vector3;
  44848. private _projectionTexture;
  44849. /**
  44850. * Gets the projection texture of the light.
  44851. */
  44852. /**
  44853. * Sets the projection texture of the light.
  44854. */
  44855. projectionTexture: Nullable<BaseTexture>;
  44856. private _projectionTextureViewLightDirty;
  44857. private _projectionTextureProjectionLightDirty;
  44858. private _projectionTextureDirty;
  44859. private _projectionTextureViewTargetVector;
  44860. private _projectionTextureViewLightMatrix;
  44861. private _projectionTextureProjectionLightMatrix;
  44862. private _projectionTextureScalingMatrix;
  44863. /**
  44864. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44865. * It can cast shadows.
  44866. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44867. * @param name The light friendly name
  44868. * @param position The position of the spot light in the scene
  44869. * @param direction The direction of the light in the scene
  44870. * @param angle The cone angle of the light in Radians
  44871. * @param exponent The light decay speed with the distance from the emission spot
  44872. * @param scene The scene the lights belongs to
  44873. */
  44874. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44875. /**
  44876. * Returns the string "SpotLight".
  44877. * @returns the class name
  44878. */
  44879. getClassName(): string;
  44880. /**
  44881. * Returns the integer 2.
  44882. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44883. */
  44884. getTypeID(): number;
  44885. /**
  44886. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44887. */
  44888. protected _setDirection(value: Vector3): void;
  44889. /**
  44890. * Overrides the position setter to recompute the projection texture view light Matrix.
  44891. */
  44892. protected _setPosition(value: Vector3): void;
  44893. /**
  44894. * 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.
  44895. * Returns the SpotLight.
  44896. */
  44897. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44898. protected _computeProjectionTextureViewLightMatrix(): void;
  44899. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44900. /**
  44901. * Main function for light texture projection matrix computing.
  44902. */
  44903. protected _computeProjectionTextureMatrix(): void;
  44904. protected _buildUniformLayout(): void;
  44905. private _computeAngleValues;
  44906. /**
  44907. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44908. * @param effect The effect to update
  44909. * @param lightIndex The index of the light in the effect to update
  44910. * @returns The spot light
  44911. */
  44912. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44913. /**
  44914. * Disposes the light and the associated resources.
  44915. */
  44916. dispose(): void;
  44917. /**
  44918. * Prepares the list of defines specific to the light type.
  44919. * @param defines the list of defines
  44920. * @param lightIndex defines the index of the light for the effect
  44921. */
  44922. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44923. }
  44924. }
  44925. declare module "babylonjs/Gizmos/lightGizmo" {
  44926. import { Nullable } from "babylonjs/types";
  44927. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44928. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44929. import { Light } from "babylonjs/Lights/light";
  44930. /**
  44931. * Gizmo that enables viewing a light
  44932. */
  44933. export class LightGizmo extends Gizmo {
  44934. private _lightMesh;
  44935. private _material;
  44936. /**
  44937. * Creates a LightGizmo
  44938. * @param gizmoLayer The utility layer the gizmo will be added to
  44939. */
  44940. constructor(gizmoLayer?: UtilityLayerRenderer);
  44941. private _light;
  44942. /**
  44943. * The light that the gizmo is attached to
  44944. */
  44945. light: Nullable<Light>;
  44946. /**
  44947. * @hidden
  44948. * Updates the gizmo to match the attached mesh's position/rotation
  44949. */
  44950. protected _update(): void;
  44951. private static _Scale;
  44952. /**
  44953. * Creates the lines for a light mesh
  44954. */
  44955. private static _createLightLines;
  44956. private static _CreateHemisphericLightMesh;
  44957. private static _CreatePointLightMesh;
  44958. private static _CreateSpotLightMesh;
  44959. private static _CreateDirectionalLightMesh;
  44960. }
  44961. }
  44962. declare module "babylonjs/Gizmos/index" {
  44963. export * from "babylonjs/Gizmos/axisDragGizmo";
  44964. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44965. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44966. export * from "babylonjs/Gizmos/gizmo";
  44967. export * from "babylonjs/Gizmos/gizmoManager";
  44968. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44969. export * from "babylonjs/Gizmos/positionGizmo";
  44970. export * from "babylonjs/Gizmos/rotationGizmo";
  44971. export * from "babylonjs/Gizmos/scaleGizmo";
  44972. export * from "babylonjs/Gizmos/lightGizmo";
  44973. }
  44974. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44975. /** @hidden */
  44976. export var backgroundFragmentDeclaration: {
  44977. name: string;
  44978. shader: string;
  44979. };
  44980. }
  44981. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44982. /** @hidden */
  44983. export var backgroundUboDeclaration: {
  44984. name: string;
  44985. shader: string;
  44986. };
  44987. }
  44988. declare module "babylonjs/Shaders/background.fragment" {
  44989. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44990. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44991. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44992. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44993. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44994. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44995. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44996. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44997. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44998. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45000. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45001. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45002. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45003. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45004. /** @hidden */
  45005. export var backgroundPixelShader: {
  45006. name: string;
  45007. shader: string;
  45008. };
  45009. }
  45010. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45011. /** @hidden */
  45012. export var backgroundVertexDeclaration: {
  45013. name: string;
  45014. shader: string;
  45015. };
  45016. }
  45017. declare module "babylonjs/Shaders/background.vertex" {
  45018. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45019. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45020. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45021. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45022. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45023. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45024. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45025. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45026. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45027. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45028. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45029. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45030. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45031. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45032. /** @hidden */
  45033. export var backgroundVertexShader: {
  45034. name: string;
  45035. shader: string;
  45036. };
  45037. }
  45038. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45039. import { Nullable, int, float } from "babylonjs/types";
  45040. import { Scene } from "babylonjs/scene";
  45041. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45042. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45044. import { Mesh } from "babylonjs/Meshes/mesh";
  45045. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45046. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45047. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45049. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45050. import "babylonjs/Shaders/background.fragment";
  45051. import "babylonjs/Shaders/background.vertex";
  45052. /**
  45053. * Background material used to create an efficient environement around your scene.
  45054. */
  45055. export class BackgroundMaterial extends PushMaterial {
  45056. /**
  45057. * Standard reflectance value at parallel view angle.
  45058. */
  45059. static StandardReflectance0: number;
  45060. /**
  45061. * Standard reflectance value at grazing angle.
  45062. */
  45063. static StandardReflectance90: number;
  45064. protected _primaryColor: Color3;
  45065. /**
  45066. * Key light Color (multiply against the environement texture)
  45067. */
  45068. primaryColor: Color3;
  45069. protected __perceptualColor: Nullable<Color3>;
  45070. /**
  45071. * Experimental Internal Use Only.
  45072. *
  45073. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45074. * This acts as a helper to set the primary color to a more "human friendly" value.
  45075. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45076. * output color as close as possible from the chosen value.
  45077. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45078. * part of lighting setup.)
  45079. */
  45080. _perceptualColor: Nullable<Color3>;
  45081. protected _primaryColorShadowLevel: float;
  45082. /**
  45083. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45084. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45085. */
  45086. primaryColorShadowLevel: float;
  45087. protected _primaryColorHighlightLevel: float;
  45088. /**
  45089. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45090. * The primary color is used at the level chosen to define what the white area would look.
  45091. */
  45092. primaryColorHighlightLevel: float;
  45093. protected _reflectionTexture: Nullable<BaseTexture>;
  45094. /**
  45095. * Reflection Texture used in the material.
  45096. * Should be author in a specific way for the best result (refer to the documentation).
  45097. */
  45098. reflectionTexture: Nullable<BaseTexture>;
  45099. protected _reflectionBlur: float;
  45100. /**
  45101. * Reflection Texture level of blur.
  45102. *
  45103. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45104. * texture twice.
  45105. */
  45106. reflectionBlur: float;
  45107. protected _diffuseTexture: Nullable<BaseTexture>;
  45108. /**
  45109. * Diffuse Texture used in the material.
  45110. * Should be author in a specific way for the best result (refer to the documentation).
  45111. */
  45112. diffuseTexture: Nullable<BaseTexture>;
  45113. protected _shadowLights: Nullable<IShadowLight[]>;
  45114. /**
  45115. * Specify the list of lights casting shadow on the material.
  45116. * All scene shadow lights will be included if null.
  45117. */
  45118. shadowLights: Nullable<IShadowLight[]>;
  45119. protected _shadowLevel: float;
  45120. /**
  45121. * Helps adjusting the shadow to a softer level if required.
  45122. * 0 means black shadows and 1 means no shadows.
  45123. */
  45124. shadowLevel: float;
  45125. protected _sceneCenter: Vector3;
  45126. /**
  45127. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45128. * It is usually zero but might be interesting to modify according to your setup.
  45129. */
  45130. sceneCenter: Vector3;
  45131. protected _opacityFresnel: boolean;
  45132. /**
  45133. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45134. * This helps ensuring a nice transition when the camera goes under the ground.
  45135. */
  45136. opacityFresnel: boolean;
  45137. protected _reflectionFresnel: boolean;
  45138. /**
  45139. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45140. * This helps adding a mirror texture on the ground.
  45141. */
  45142. reflectionFresnel: boolean;
  45143. protected _reflectionFalloffDistance: number;
  45144. /**
  45145. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45146. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45147. */
  45148. reflectionFalloffDistance: number;
  45149. protected _reflectionAmount: number;
  45150. /**
  45151. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45152. */
  45153. reflectionAmount: number;
  45154. protected _reflectionReflectance0: number;
  45155. /**
  45156. * This specifies the weight of the reflection at grazing angle.
  45157. */
  45158. reflectionReflectance0: number;
  45159. protected _reflectionReflectance90: number;
  45160. /**
  45161. * This specifies the weight of the reflection at a perpendicular point of view.
  45162. */
  45163. reflectionReflectance90: number;
  45164. /**
  45165. * Sets the reflection reflectance fresnel values according to the default standard
  45166. * empirically know to work well :-)
  45167. */
  45168. reflectionStandardFresnelWeight: number;
  45169. protected _useRGBColor: boolean;
  45170. /**
  45171. * Helps to directly use the maps channels instead of their level.
  45172. */
  45173. useRGBColor: boolean;
  45174. protected _enableNoise: boolean;
  45175. /**
  45176. * This helps reducing the banding effect that could occur on the background.
  45177. */
  45178. enableNoise: boolean;
  45179. /**
  45180. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45181. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45182. * Recommended to be keep at 1.0 except for special cases.
  45183. */
  45184. fovMultiplier: number;
  45185. private _fovMultiplier;
  45186. /**
  45187. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45188. */
  45189. useEquirectangularFOV: boolean;
  45190. private _maxSimultaneousLights;
  45191. /**
  45192. * Number of Simultaneous lights allowed on the material.
  45193. */
  45194. maxSimultaneousLights: int;
  45195. /**
  45196. * Default configuration related to image processing available in the Background Material.
  45197. */
  45198. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45199. /**
  45200. * Keep track of the image processing observer to allow dispose and replace.
  45201. */
  45202. private _imageProcessingObserver;
  45203. /**
  45204. * Attaches a new image processing configuration to the PBR Material.
  45205. * @param configuration (if null the scene configuration will be use)
  45206. */
  45207. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45208. /**
  45209. * Gets the image processing configuration used either in this material.
  45210. */
  45211. /**
  45212. * Sets the Default image processing configuration used either in the this material.
  45213. *
  45214. * If sets to null, the scene one is in use.
  45215. */
  45216. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45217. /**
  45218. * Gets wether the color curves effect is enabled.
  45219. */
  45220. /**
  45221. * Sets wether the color curves effect is enabled.
  45222. */
  45223. cameraColorCurvesEnabled: boolean;
  45224. /**
  45225. * Gets wether the color grading effect is enabled.
  45226. */
  45227. /**
  45228. * Gets wether the color grading effect is enabled.
  45229. */
  45230. cameraColorGradingEnabled: boolean;
  45231. /**
  45232. * Gets wether tonemapping is enabled or not.
  45233. */
  45234. /**
  45235. * Sets wether tonemapping is enabled or not
  45236. */
  45237. cameraToneMappingEnabled: boolean;
  45238. /**
  45239. * The camera exposure used on this material.
  45240. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45241. * This corresponds to a photographic exposure.
  45242. */
  45243. /**
  45244. * The camera exposure used on this material.
  45245. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45246. * This corresponds to a photographic exposure.
  45247. */
  45248. cameraExposure: float;
  45249. /**
  45250. * Gets The camera contrast used on this material.
  45251. */
  45252. /**
  45253. * Sets The camera contrast used on this material.
  45254. */
  45255. cameraContrast: float;
  45256. /**
  45257. * Gets the Color Grading 2D Lookup Texture.
  45258. */
  45259. /**
  45260. * Sets the Color Grading 2D Lookup Texture.
  45261. */
  45262. cameraColorGradingTexture: Nullable<BaseTexture>;
  45263. /**
  45264. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45265. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45266. * 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;
  45267. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45268. */
  45269. /**
  45270. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45271. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45272. * 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;
  45273. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45274. */
  45275. cameraColorCurves: Nullable<ColorCurves>;
  45276. /**
  45277. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45278. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45279. */
  45280. switchToBGR: boolean;
  45281. private _renderTargets;
  45282. private _reflectionControls;
  45283. private _white;
  45284. private _primaryShadowColor;
  45285. private _primaryHighlightColor;
  45286. /**
  45287. * Instantiates a Background Material in the given scene
  45288. * @param name The friendly name of the material
  45289. * @param scene The scene to add the material to
  45290. */
  45291. constructor(name: string, scene: Scene);
  45292. /**
  45293. * Gets a boolean indicating that current material needs to register RTT
  45294. */
  45295. readonly hasRenderTargetTextures: boolean;
  45296. /**
  45297. * The entire material has been created in order to prevent overdraw.
  45298. * @returns false
  45299. */
  45300. needAlphaTesting(): boolean;
  45301. /**
  45302. * The entire material has been created in order to prevent overdraw.
  45303. * @returns true if blending is enable
  45304. */
  45305. needAlphaBlending(): boolean;
  45306. /**
  45307. * Checks wether the material is ready to be rendered for a given mesh.
  45308. * @param mesh The mesh to render
  45309. * @param subMesh The submesh to check against
  45310. * @param useInstances Specify wether or not the material is used with instances
  45311. * @returns true if all the dependencies are ready (Textures, Effects...)
  45312. */
  45313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45314. /**
  45315. * Compute the primary color according to the chosen perceptual color.
  45316. */
  45317. private _computePrimaryColorFromPerceptualColor;
  45318. /**
  45319. * Compute the highlights and shadow colors according to their chosen levels.
  45320. */
  45321. private _computePrimaryColors;
  45322. /**
  45323. * Build the uniform buffer used in the material.
  45324. */
  45325. buildUniformLayout(): void;
  45326. /**
  45327. * Unbind the material.
  45328. */
  45329. unbind(): void;
  45330. /**
  45331. * Bind only the world matrix to the material.
  45332. * @param world The world matrix to bind.
  45333. */
  45334. bindOnlyWorldMatrix(world: Matrix): void;
  45335. /**
  45336. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45337. * @param world The world matrix to bind.
  45338. * @param subMesh The submesh to bind for.
  45339. */
  45340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45341. /**
  45342. * Dispose the material.
  45343. * @param forceDisposeEffect Force disposal of the associated effect.
  45344. * @param forceDisposeTextures Force disposal of the associated textures.
  45345. */
  45346. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45347. /**
  45348. * Clones the material.
  45349. * @param name The cloned name.
  45350. * @returns The cloned material.
  45351. */
  45352. clone(name: string): BackgroundMaterial;
  45353. /**
  45354. * Serializes the current material to its JSON representation.
  45355. * @returns The JSON representation.
  45356. */
  45357. serialize(): any;
  45358. /**
  45359. * Gets the class name of the material
  45360. * @returns "BackgroundMaterial"
  45361. */
  45362. getClassName(): string;
  45363. /**
  45364. * Parse a JSON input to create back a background material.
  45365. * @param source The JSON data to parse
  45366. * @param scene The scene to create the parsed material in
  45367. * @param rootUrl The root url of the assets the material depends upon
  45368. * @returns the instantiated BackgroundMaterial.
  45369. */
  45370. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45371. }
  45372. }
  45373. declare module "babylonjs/Helpers/environmentHelper" {
  45374. import { Observable } from "babylonjs/Misc/observable";
  45375. import { Nullable } from "babylonjs/types";
  45376. import { Scene } from "babylonjs/scene";
  45377. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45379. import { Mesh } from "babylonjs/Meshes/mesh";
  45380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45381. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45382. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45383. import "babylonjs/Meshes/Builders/planeBuilder";
  45384. import "babylonjs/Meshes/Builders/boxBuilder";
  45385. /**
  45386. * Represents the different options available during the creation of
  45387. * a Environment helper.
  45388. *
  45389. * This can control the default ground, skybox and image processing setup of your scene.
  45390. */
  45391. export interface IEnvironmentHelperOptions {
  45392. /**
  45393. * Specifies wether or not to create a ground.
  45394. * True by default.
  45395. */
  45396. createGround: boolean;
  45397. /**
  45398. * Specifies the ground size.
  45399. * 15 by default.
  45400. */
  45401. groundSize: number;
  45402. /**
  45403. * The texture used on the ground for the main color.
  45404. * Comes from the BabylonJS CDN by default.
  45405. *
  45406. * Remarks: Can be either a texture or a url.
  45407. */
  45408. groundTexture: string | BaseTexture;
  45409. /**
  45410. * The color mixed in the ground texture by default.
  45411. * BabylonJS clearColor by default.
  45412. */
  45413. groundColor: Color3;
  45414. /**
  45415. * Specifies the ground opacity.
  45416. * 1 by default.
  45417. */
  45418. groundOpacity: number;
  45419. /**
  45420. * Enables the ground to receive shadows.
  45421. * True by default.
  45422. */
  45423. enableGroundShadow: boolean;
  45424. /**
  45425. * Helps preventing the shadow to be fully black on the ground.
  45426. * 0.5 by default.
  45427. */
  45428. groundShadowLevel: number;
  45429. /**
  45430. * Creates a mirror texture attach to the ground.
  45431. * false by default.
  45432. */
  45433. enableGroundMirror: boolean;
  45434. /**
  45435. * Specifies the ground mirror size ratio.
  45436. * 0.3 by default as the default kernel is 64.
  45437. */
  45438. groundMirrorSizeRatio: number;
  45439. /**
  45440. * Specifies the ground mirror blur kernel size.
  45441. * 64 by default.
  45442. */
  45443. groundMirrorBlurKernel: number;
  45444. /**
  45445. * Specifies the ground mirror visibility amount.
  45446. * 1 by default
  45447. */
  45448. groundMirrorAmount: number;
  45449. /**
  45450. * Specifies the ground mirror reflectance weight.
  45451. * This uses the standard weight of the background material to setup the fresnel effect
  45452. * of the mirror.
  45453. * 1 by default.
  45454. */
  45455. groundMirrorFresnelWeight: number;
  45456. /**
  45457. * Specifies the ground mirror Falloff distance.
  45458. * This can helps reducing the size of the reflection.
  45459. * 0 by Default.
  45460. */
  45461. groundMirrorFallOffDistance: number;
  45462. /**
  45463. * Specifies the ground mirror texture type.
  45464. * Unsigned Int by Default.
  45465. */
  45466. groundMirrorTextureType: number;
  45467. /**
  45468. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45469. * the shown objects.
  45470. */
  45471. groundYBias: number;
  45472. /**
  45473. * Specifies wether or not to create a skybox.
  45474. * True by default.
  45475. */
  45476. createSkybox: boolean;
  45477. /**
  45478. * Specifies the skybox size.
  45479. * 20 by default.
  45480. */
  45481. skyboxSize: number;
  45482. /**
  45483. * The texture used on the skybox for the main color.
  45484. * Comes from the BabylonJS CDN by default.
  45485. *
  45486. * Remarks: Can be either a texture or a url.
  45487. */
  45488. skyboxTexture: string | BaseTexture;
  45489. /**
  45490. * The color mixed in the skybox texture by default.
  45491. * BabylonJS clearColor by default.
  45492. */
  45493. skyboxColor: Color3;
  45494. /**
  45495. * The background rotation around the Y axis of the scene.
  45496. * This helps aligning the key lights of your scene with the background.
  45497. * 0 by default.
  45498. */
  45499. backgroundYRotation: number;
  45500. /**
  45501. * Compute automatically the size of the elements to best fit with the scene.
  45502. */
  45503. sizeAuto: boolean;
  45504. /**
  45505. * Default position of the rootMesh if autoSize is not true.
  45506. */
  45507. rootPosition: Vector3;
  45508. /**
  45509. * Sets up the image processing in the scene.
  45510. * true by default.
  45511. */
  45512. setupImageProcessing: boolean;
  45513. /**
  45514. * The texture used as your environment texture in the scene.
  45515. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45516. *
  45517. * Remarks: Can be either a texture or a url.
  45518. */
  45519. environmentTexture: string | BaseTexture;
  45520. /**
  45521. * The value of the exposure to apply to the scene.
  45522. * 0.6 by default if setupImageProcessing is true.
  45523. */
  45524. cameraExposure: number;
  45525. /**
  45526. * The value of the contrast to apply to the scene.
  45527. * 1.6 by default if setupImageProcessing is true.
  45528. */
  45529. cameraContrast: number;
  45530. /**
  45531. * Specifies wether or not tonemapping should be enabled in the scene.
  45532. * true by default if setupImageProcessing is true.
  45533. */
  45534. toneMappingEnabled: boolean;
  45535. }
  45536. /**
  45537. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45538. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45539. * It also helps with the default setup of your imageProcessing configuration.
  45540. */
  45541. export class EnvironmentHelper {
  45542. /**
  45543. * Default ground texture URL.
  45544. */
  45545. private static _groundTextureCDNUrl;
  45546. /**
  45547. * Default skybox texture URL.
  45548. */
  45549. private static _skyboxTextureCDNUrl;
  45550. /**
  45551. * Default environment texture URL.
  45552. */
  45553. private static _environmentTextureCDNUrl;
  45554. /**
  45555. * Creates the default options for the helper.
  45556. */
  45557. private static _getDefaultOptions;
  45558. private _rootMesh;
  45559. /**
  45560. * Gets the root mesh created by the helper.
  45561. */
  45562. readonly rootMesh: Mesh;
  45563. private _skybox;
  45564. /**
  45565. * Gets the skybox created by the helper.
  45566. */
  45567. readonly skybox: Nullable<Mesh>;
  45568. private _skyboxTexture;
  45569. /**
  45570. * Gets the skybox texture created by the helper.
  45571. */
  45572. readonly skyboxTexture: Nullable<BaseTexture>;
  45573. private _skyboxMaterial;
  45574. /**
  45575. * Gets the skybox material created by the helper.
  45576. */
  45577. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45578. private _ground;
  45579. /**
  45580. * Gets the ground mesh created by the helper.
  45581. */
  45582. readonly ground: Nullable<Mesh>;
  45583. private _groundTexture;
  45584. /**
  45585. * Gets the ground texture created by the helper.
  45586. */
  45587. readonly groundTexture: Nullable<BaseTexture>;
  45588. private _groundMirror;
  45589. /**
  45590. * Gets the ground mirror created by the helper.
  45591. */
  45592. readonly groundMirror: Nullable<MirrorTexture>;
  45593. /**
  45594. * Gets the ground mirror render list to helps pushing the meshes
  45595. * you wish in the ground reflection.
  45596. */
  45597. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45598. private _groundMaterial;
  45599. /**
  45600. * Gets the ground material created by the helper.
  45601. */
  45602. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45603. /**
  45604. * Stores the creation options.
  45605. */
  45606. private readonly _scene;
  45607. private _options;
  45608. /**
  45609. * This observable will be notified with any error during the creation of the environment,
  45610. * mainly texture creation errors.
  45611. */
  45612. onErrorObservable: Observable<{
  45613. message?: string;
  45614. exception?: any;
  45615. }>;
  45616. /**
  45617. * constructor
  45618. * @param options Defines the options we want to customize the helper
  45619. * @param scene The scene to add the material to
  45620. */
  45621. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45622. /**
  45623. * Updates the background according to the new options
  45624. * @param options
  45625. */
  45626. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45627. /**
  45628. * Sets the primary color of all the available elements.
  45629. * @param color the main color to affect to the ground and the background
  45630. */
  45631. setMainColor(color: Color3): void;
  45632. /**
  45633. * Setup the image processing according to the specified options.
  45634. */
  45635. private _setupImageProcessing;
  45636. /**
  45637. * Setup the environment texture according to the specified options.
  45638. */
  45639. private _setupEnvironmentTexture;
  45640. /**
  45641. * Setup the background according to the specified options.
  45642. */
  45643. private _setupBackground;
  45644. /**
  45645. * Get the scene sizes according to the setup.
  45646. */
  45647. private _getSceneSize;
  45648. /**
  45649. * Setup the ground according to the specified options.
  45650. */
  45651. private _setupGround;
  45652. /**
  45653. * Setup the ground material according to the specified options.
  45654. */
  45655. private _setupGroundMaterial;
  45656. /**
  45657. * Setup the ground diffuse texture according to the specified options.
  45658. */
  45659. private _setupGroundDiffuseTexture;
  45660. /**
  45661. * Setup the ground mirror texture according to the specified options.
  45662. */
  45663. private _setupGroundMirrorTexture;
  45664. /**
  45665. * Setup the ground to receive the mirror texture.
  45666. */
  45667. private _setupMirrorInGroundMaterial;
  45668. /**
  45669. * Setup the skybox according to the specified options.
  45670. */
  45671. private _setupSkybox;
  45672. /**
  45673. * Setup the skybox material according to the specified options.
  45674. */
  45675. private _setupSkyboxMaterial;
  45676. /**
  45677. * Setup the skybox reflection texture according to the specified options.
  45678. */
  45679. private _setupSkyboxReflectionTexture;
  45680. private _errorHandler;
  45681. /**
  45682. * Dispose all the elements created by the Helper.
  45683. */
  45684. dispose(): void;
  45685. }
  45686. }
  45687. declare module "babylonjs/Helpers/photoDome" {
  45688. import { Observable } from "babylonjs/Misc/observable";
  45689. import { Nullable } from "babylonjs/types";
  45690. import { Scene } from "babylonjs/scene";
  45691. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45692. import { Mesh } from "babylonjs/Meshes/mesh";
  45693. import { Texture } from "babylonjs/Materials/Textures/texture";
  45694. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45695. import "babylonjs/Meshes/Builders/sphereBuilder";
  45696. /**
  45697. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45698. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45699. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45700. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45701. */
  45702. export class PhotoDome extends TransformNode {
  45703. private _useDirectMapping;
  45704. /**
  45705. * The texture being displayed on the sphere
  45706. */
  45707. protected _photoTexture: Texture;
  45708. /**
  45709. * Gets or sets the texture being displayed on the sphere
  45710. */
  45711. photoTexture: Texture;
  45712. /**
  45713. * Observable raised when an error occured while loading the 360 image
  45714. */
  45715. onLoadErrorObservable: Observable<string>;
  45716. /**
  45717. * The skybox material
  45718. */
  45719. protected _material: BackgroundMaterial;
  45720. /**
  45721. * The surface used for the skybox
  45722. */
  45723. protected _mesh: Mesh;
  45724. /**
  45725. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45726. * Also see the options.resolution property.
  45727. */
  45728. fovMultiplier: number;
  45729. /**
  45730. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45731. * @param name Element's name, child elements will append suffixes for their own names.
  45732. * @param urlsOfPhoto defines the url of the photo to display
  45733. * @param options defines an object containing optional or exposed sub element properties
  45734. * @param onError defines a callback called when an error occured while loading the texture
  45735. */
  45736. constructor(name: string, urlOfPhoto: string, options: {
  45737. resolution?: number;
  45738. size?: number;
  45739. useDirectMapping?: boolean;
  45740. faceForward?: boolean;
  45741. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45742. /**
  45743. * Releases resources associated with this node.
  45744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45746. */
  45747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45748. }
  45749. }
  45750. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45751. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45752. /** @hidden */
  45753. export var rgbdDecodePixelShader: {
  45754. name: string;
  45755. shader: string;
  45756. };
  45757. }
  45758. declare module "babylonjs/Misc/brdfTextureTools" {
  45759. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45760. import { Scene } from "babylonjs/scene";
  45761. import "babylonjs/Shaders/rgbdDecode.fragment";
  45762. /**
  45763. * Class used to host texture specific utilities
  45764. */
  45765. export class BRDFTextureTools {
  45766. /**
  45767. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45768. * @param texture the texture to expand.
  45769. */
  45770. private static _ExpandDefaultBRDFTexture;
  45771. /**
  45772. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45773. * @param scene defines the hosting scene
  45774. * @returns the environment BRDF texture
  45775. */
  45776. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45777. private static _environmentBRDFBase64Texture;
  45778. }
  45779. }
  45780. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45781. import { Nullable } from "babylonjs/types";
  45782. import { IAnimatable } from "babylonjs/Misc/tools";
  45783. import { Color3 } from "babylonjs/Maths/math";
  45784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45785. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45786. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45787. import { Engine } from "babylonjs/Engines/engine";
  45788. import { Scene } from "babylonjs/scene";
  45789. /**
  45790. * @hidden
  45791. */
  45792. export interface IMaterialClearCoatDefines {
  45793. CLEARCOAT: boolean;
  45794. CLEARCOAT_DEFAULTIOR: boolean;
  45795. CLEARCOAT_TEXTURE: boolean;
  45796. CLEARCOAT_TEXTUREDIRECTUV: number;
  45797. CLEARCOAT_BUMP: boolean;
  45798. CLEARCOAT_BUMPDIRECTUV: number;
  45799. CLEARCOAT_TINT: boolean;
  45800. CLEARCOAT_TINT_TEXTURE: boolean;
  45801. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45802. /** @hidden */
  45803. _areTexturesDirty: boolean;
  45804. }
  45805. /**
  45806. * Define the code related to the clear coat parameters of the pbr material.
  45807. */
  45808. export class PBRClearCoatConfiguration {
  45809. /**
  45810. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45811. * The default fits with a polyurethane material.
  45812. */
  45813. private static readonly _DefaultIndiceOfRefraction;
  45814. private _isEnabled;
  45815. /**
  45816. * Defines if the clear coat is enabled in the material.
  45817. */
  45818. isEnabled: boolean;
  45819. /**
  45820. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45821. */
  45822. intensity: number;
  45823. /**
  45824. * Defines the clear coat layer roughness.
  45825. */
  45826. roughness: number;
  45827. private _indiceOfRefraction;
  45828. /**
  45829. * Defines the indice of refraction of the clear coat.
  45830. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45831. * The default fits with a polyurethane material.
  45832. * Changing the default value is more performance intensive.
  45833. */
  45834. indiceOfRefraction: number;
  45835. private _texture;
  45836. /**
  45837. * Stores the clear coat values in a texture.
  45838. */
  45839. texture: Nullable<BaseTexture>;
  45840. private _bumpTexture;
  45841. /**
  45842. * Define the clear coat specific bump texture.
  45843. */
  45844. bumpTexture: Nullable<BaseTexture>;
  45845. private _isTintEnabled;
  45846. /**
  45847. * Defines if the clear coat tint is enabled in the material.
  45848. */
  45849. isTintEnabled: boolean;
  45850. /**
  45851. * Defines the clear coat tint of the material.
  45852. * This is only use if tint is enabled
  45853. */
  45854. tintColor: Color3;
  45855. /**
  45856. * Defines the distance at which the tint color should be found in the
  45857. * clear coat media.
  45858. * This is only use if tint is enabled
  45859. */
  45860. tintColorAtDistance: number;
  45861. /**
  45862. * Defines the clear coat layer thickness.
  45863. * This is only use if tint is enabled
  45864. */
  45865. tintThickness: number;
  45866. private _tintTexture;
  45867. /**
  45868. * Stores the clear tint values in a texture.
  45869. * rgb is tint
  45870. * a is a thickness factor
  45871. */
  45872. tintTexture: Nullable<BaseTexture>;
  45873. /** @hidden */
  45874. private _internalMarkAllSubMeshesAsTexturesDirty;
  45875. /** @hidden */
  45876. _markAllSubMeshesAsTexturesDirty(): void;
  45877. /**
  45878. * Instantiate a new istance of clear coat configuration.
  45879. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45880. */
  45881. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45882. /**
  45883. * Gets wehter the submesh is ready to be used or not.
  45884. * @param defines the list of "defines" to update.
  45885. * @param scene defines the scene the material belongs to.
  45886. * @param engine defines the engine the material belongs to.
  45887. * @param disableBumpMap defines wether the material disables bump or not.
  45888. * @returns - boolean indicating that the submesh is ready or not.
  45889. */
  45890. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45891. /**
  45892. * Checks to see if a texture is used in the material.
  45893. * @param defines the list of "defines" to update.
  45894. * @param scene defines the scene to the material belongs to.
  45895. */
  45896. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45897. /**
  45898. * Binds the material data.
  45899. * @param uniformBuffer defines the Uniform buffer to fill in.
  45900. * @param scene defines the scene the material belongs to.
  45901. * @param engine defines the engine the material belongs to.
  45902. * @param disableBumpMap defines wether the material disables bump or not.
  45903. * @param isFrozen defines wether the material is frozen or not.
  45904. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45905. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45906. */
  45907. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45908. /**
  45909. * Checks to see if a texture is used in the material.
  45910. * @param texture - Base texture to use.
  45911. * @returns - Boolean specifying if a texture is used in the material.
  45912. */
  45913. hasTexture(texture: BaseTexture): boolean;
  45914. /**
  45915. * Returns an array of the actively used textures.
  45916. * @param activeTextures Array of BaseTextures
  45917. */
  45918. getActiveTextures(activeTextures: BaseTexture[]): void;
  45919. /**
  45920. * Returns the animatable textures.
  45921. * @param animatables Array of animatable textures.
  45922. */
  45923. getAnimatables(animatables: IAnimatable[]): void;
  45924. /**
  45925. * Disposes the resources of the material.
  45926. * @param forceDisposeTextures - Forces the disposal of all textures.
  45927. */
  45928. dispose(forceDisposeTextures?: boolean): void;
  45929. /**
  45930. * Get the current class name of the texture useful for serialization or dynamic coding.
  45931. * @returns "PBRClearCoatConfiguration"
  45932. */
  45933. getClassName(): string;
  45934. /**
  45935. * Add fallbacks to the effect fallbacks list.
  45936. * @param defines defines the Base texture to use.
  45937. * @param fallbacks defines the current fallback list.
  45938. * @param currentRank defines the current fallback rank.
  45939. * @returns the new fallback rank.
  45940. */
  45941. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45942. /**
  45943. * Add the required uniforms to the current list.
  45944. * @param uniforms defines the current uniform list.
  45945. */
  45946. static AddUniforms(uniforms: string[]): void;
  45947. /**
  45948. * Add the required samplers to the current list.
  45949. * @param samplers defines the current sampler list.
  45950. */
  45951. static AddSamplers(samplers: string[]): void;
  45952. /**
  45953. * Add the required uniforms to the current buffer.
  45954. * @param uniformBuffer defines the current uniform buffer.
  45955. */
  45956. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45957. /**
  45958. * Makes a duplicate of the current configuration into another one.
  45959. * @param clearCoatConfiguration define the config where to copy the info
  45960. */
  45961. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45962. /**
  45963. * Serializes this clear coat configuration.
  45964. * @returns - An object with the serialized config.
  45965. */
  45966. serialize(): any;
  45967. /**
  45968. * Parses a Clear Coat Configuration from a serialized object.
  45969. * @param source - Serialized object.
  45970. */
  45971. parse(source: any): void;
  45972. }
  45973. }
  45974. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45975. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45976. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45978. import { Vector2 } from "babylonjs/Maths/math";
  45979. import { Scene } from "babylonjs/scene";
  45980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45981. import { IAnimatable } from "babylonjs/Misc/tools";
  45982. import { Nullable } from "babylonjs/types";
  45983. /**
  45984. * @hidden
  45985. */
  45986. export interface IMaterialAnisotropicDefines {
  45987. ANISOTROPIC: boolean;
  45988. ANISOTROPIC_TEXTURE: boolean;
  45989. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45990. MAINUV1: boolean;
  45991. _areTexturesDirty: boolean;
  45992. _needUVs: boolean;
  45993. }
  45994. /**
  45995. * Define the code related to the anisotropic parameters of the pbr material.
  45996. */
  45997. export class PBRAnisotropicConfiguration {
  45998. private _isEnabled;
  45999. /**
  46000. * Defines if the anisotropy is enabled in the material.
  46001. */
  46002. isEnabled: boolean;
  46003. /**
  46004. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46005. */
  46006. intensity: number;
  46007. /**
  46008. * Defines if the effect is along the tangents, bitangents or in between.
  46009. * By default, the effect is "strectching" the highlights along the tangents.
  46010. */
  46011. direction: Vector2;
  46012. private _texture;
  46013. /**
  46014. * Stores the anisotropy values in a texture.
  46015. * rg is direction (like normal from -1 to 1)
  46016. * b is a intensity
  46017. */
  46018. texture: Nullable<BaseTexture>;
  46019. /** @hidden */
  46020. private _internalMarkAllSubMeshesAsTexturesDirty;
  46021. /** @hidden */
  46022. _markAllSubMeshesAsTexturesDirty(): void;
  46023. /**
  46024. * Instantiate a new istance of anisotropy configuration.
  46025. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46026. */
  46027. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46028. /**
  46029. * Specifies that the submesh is ready to be used.
  46030. * @param defines the list of "defines" to update.
  46031. * @param scene defines the scene the material belongs to.
  46032. * @returns - boolean indicating that the submesh is ready or not.
  46033. */
  46034. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46035. /**
  46036. * Checks to see if a texture is used in the material.
  46037. * @param defines the list of "defines" to update.
  46038. * @param mesh the mesh we are preparing the defines for.
  46039. * @param scene defines the scene the material belongs to.
  46040. */
  46041. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46042. /**
  46043. * Binds the material data.
  46044. * @param uniformBuffer defines the Uniform buffer to fill in.
  46045. * @param scene defines the scene the material belongs to.
  46046. * @param isFrozen defines wether the material is frozen or not.
  46047. */
  46048. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46049. /**
  46050. * Checks to see if a texture is used in the material.
  46051. * @param texture - Base texture to use.
  46052. * @returns - Boolean specifying if a texture is used in the material.
  46053. */
  46054. hasTexture(texture: BaseTexture): boolean;
  46055. /**
  46056. * Returns an array of the actively used textures.
  46057. * @param activeTextures Array of BaseTextures
  46058. */
  46059. getActiveTextures(activeTextures: BaseTexture[]): void;
  46060. /**
  46061. * Returns the animatable textures.
  46062. * @param animatables Array of animatable textures.
  46063. */
  46064. getAnimatables(animatables: IAnimatable[]): void;
  46065. /**
  46066. * Disposes the resources of the material.
  46067. * @param forceDisposeTextures - Forces the disposal of all textures.
  46068. */
  46069. dispose(forceDisposeTextures?: boolean): void;
  46070. /**
  46071. * Get the current class name of the texture useful for serialization or dynamic coding.
  46072. * @returns "PBRAnisotropicConfiguration"
  46073. */
  46074. getClassName(): string;
  46075. /**
  46076. * Add fallbacks to the effect fallbacks list.
  46077. * @param defines defines the Base texture to use.
  46078. * @param fallbacks defines the current fallback list.
  46079. * @param currentRank defines the current fallback rank.
  46080. * @returns the new fallback rank.
  46081. */
  46082. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46083. /**
  46084. * Add the required uniforms to the current list.
  46085. * @param uniforms defines the current uniform list.
  46086. */
  46087. static AddUniforms(uniforms: string[]): void;
  46088. /**
  46089. * Add the required uniforms to the current buffer.
  46090. * @param uniformBuffer defines the current uniform buffer.
  46091. */
  46092. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46093. /**
  46094. * Add the required samplers to the current list.
  46095. * @param samplers defines the current sampler list.
  46096. */
  46097. static AddSamplers(samplers: string[]): void;
  46098. /**
  46099. * Makes a duplicate of the current configuration into another one.
  46100. * @param anisotropicConfiguration define the config where to copy the info
  46101. */
  46102. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46103. /**
  46104. * Serializes this anisotropy configuration.
  46105. * @returns - An object with the serialized config.
  46106. */
  46107. serialize(): any;
  46108. /**
  46109. * Parses a anisotropy Configuration from a serialized object.
  46110. * @param source - Serialized object.
  46111. */
  46112. parse(source: any): void;
  46113. }
  46114. }
  46115. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46116. /**
  46117. * @hidden
  46118. */
  46119. export interface IMaterialBRDFDefines {
  46120. BRDF_V_HEIGHT_CORRELATED: boolean;
  46121. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46122. SPHERICAL_HARMONICS: boolean;
  46123. /** @hidden */
  46124. _areMiscDirty: boolean;
  46125. }
  46126. /**
  46127. * Define the code related to the BRDF parameters of the pbr material.
  46128. */
  46129. export class PBRBRDFConfiguration {
  46130. /**
  46131. * Default value used for the energy conservation.
  46132. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46133. */
  46134. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46135. /**
  46136. * Default value used for the Smith Visibility Height Correlated mode.
  46137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46138. */
  46139. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46140. /**
  46141. * Default value used for the IBL diffuse part.
  46142. * This can help switching back to the polynomials mode globally which is a tiny bit
  46143. * less GPU intensive at the drawback of a lower quality.
  46144. */
  46145. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46146. private _useEnergyConservation;
  46147. /**
  46148. * Defines if the material uses energy conservation.
  46149. */
  46150. useEnergyConservation: boolean;
  46151. private _useSmithVisibilityHeightCorrelated;
  46152. /**
  46153. * LEGACY Mode set to false
  46154. * Defines if the material uses height smith correlated visibility term.
  46155. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46156. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46157. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46158. * Not relying on height correlated will also disable energy conservation.
  46159. */
  46160. useSmithVisibilityHeightCorrelated: boolean;
  46161. private _useSphericalHarmonics;
  46162. /**
  46163. * LEGACY Mode set to false
  46164. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46165. * diffuse part of the IBL.
  46166. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46167. * to the ground truth.
  46168. */
  46169. useSphericalHarmonics: boolean;
  46170. /** @hidden */
  46171. private _internalMarkAllSubMeshesAsMiscDirty;
  46172. /** @hidden */
  46173. _markAllSubMeshesAsMiscDirty(): void;
  46174. /**
  46175. * Instantiate a new istance of clear coat configuration.
  46176. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46177. */
  46178. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46179. /**
  46180. * Checks to see if a texture is used in the material.
  46181. * @param defines the list of "defines" to update.
  46182. */
  46183. prepareDefines(defines: IMaterialBRDFDefines): void;
  46184. /**
  46185. * Get the current class name of the texture useful for serialization or dynamic coding.
  46186. * @returns "PBRClearCoatConfiguration"
  46187. */
  46188. getClassName(): string;
  46189. /**
  46190. * Makes a duplicate of the current configuration into another one.
  46191. * @param brdfConfiguration define the config where to copy the info
  46192. */
  46193. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46194. /**
  46195. * Serializes this BRDF configuration.
  46196. * @returns - An object with the serialized config.
  46197. */
  46198. serialize(): any;
  46199. /**
  46200. * Parses a BRDF Configuration from a serialized object.
  46201. * @param source - Serialized object.
  46202. */
  46203. parse(source: any): void;
  46204. }
  46205. }
  46206. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46207. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46208. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46209. import { Color3 } from "babylonjs/Maths/math";
  46210. import { Scene } from "babylonjs/scene";
  46211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46212. import { IAnimatable } from "babylonjs/Misc/tools";
  46213. import { Nullable } from "babylonjs/types";
  46214. /**
  46215. * @hidden
  46216. */
  46217. export interface IMaterialSheenDefines {
  46218. SHEEN: boolean;
  46219. SHEEN_TEXTURE: boolean;
  46220. SHEEN_TEXTUREDIRECTUV: number;
  46221. SHEEN_LINKWITHALBEDO: boolean;
  46222. /** @hidden */
  46223. _areTexturesDirty: boolean;
  46224. }
  46225. /**
  46226. * Define the code related to the Sheen parameters of the pbr material.
  46227. */
  46228. export class PBRSheenConfiguration {
  46229. private _isEnabled;
  46230. /**
  46231. * Defines if the material uses sheen.
  46232. */
  46233. isEnabled: boolean;
  46234. private _linkSheenWithAlbedo;
  46235. /**
  46236. * Defines if the sheen is linked to the sheen color.
  46237. */
  46238. linkSheenWithAlbedo: boolean;
  46239. /**
  46240. * Defines the sheen intensity.
  46241. */
  46242. intensity: number;
  46243. /**
  46244. * Defines the sheen color.
  46245. */
  46246. color: Color3;
  46247. private _texture;
  46248. /**
  46249. * Stores the sheen tint values in a texture.
  46250. * rgb is tint
  46251. * a is a intensity
  46252. */
  46253. texture: Nullable<BaseTexture>;
  46254. /** @hidden */
  46255. private _internalMarkAllSubMeshesAsTexturesDirty;
  46256. /** @hidden */
  46257. _markAllSubMeshesAsTexturesDirty(): void;
  46258. /**
  46259. * Instantiate a new istance of clear coat configuration.
  46260. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46261. */
  46262. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46263. /**
  46264. * Specifies that the submesh is ready to be used.
  46265. * @param defines the list of "defines" to update.
  46266. * @param scene defines the scene the material belongs to.
  46267. * @returns - boolean indicating that the submesh is ready or not.
  46268. */
  46269. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46270. /**
  46271. * Checks to see if a texture is used in the material.
  46272. * @param defines the list of "defines" to update.
  46273. * @param scene defines the scene the material belongs to.
  46274. */
  46275. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46276. /**
  46277. * Binds the material data.
  46278. * @param uniformBuffer defines the Uniform buffer to fill in.
  46279. * @param scene defines the scene the material belongs to.
  46280. * @param isFrozen defines wether the material is frozen or not.
  46281. */
  46282. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46283. /**
  46284. * Checks to see if a texture is used in the material.
  46285. * @param texture - Base texture to use.
  46286. * @returns - Boolean specifying if a texture is used in the material.
  46287. */
  46288. hasTexture(texture: BaseTexture): boolean;
  46289. /**
  46290. * Returns an array of the actively used textures.
  46291. * @param activeTextures Array of BaseTextures
  46292. */
  46293. getActiveTextures(activeTextures: BaseTexture[]): void;
  46294. /**
  46295. * Returns the animatable textures.
  46296. * @param animatables Array of animatable textures.
  46297. */
  46298. getAnimatables(animatables: IAnimatable[]): void;
  46299. /**
  46300. * Disposes the resources of the material.
  46301. * @param forceDisposeTextures - Forces the disposal of all textures.
  46302. */
  46303. dispose(forceDisposeTextures?: boolean): void;
  46304. /**
  46305. * Get the current class name of the texture useful for serialization or dynamic coding.
  46306. * @returns "PBRSheenConfiguration"
  46307. */
  46308. getClassName(): string;
  46309. /**
  46310. * Add fallbacks to the effect fallbacks list.
  46311. * @param defines defines the Base texture to use.
  46312. * @param fallbacks defines the current fallback list.
  46313. * @param currentRank defines the current fallback rank.
  46314. * @returns the new fallback rank.
  46315. */
  46316. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46317. /**
  46318. * Add the required uniforms to the current list.
  46319. * @param uniforms defines the current uniform list.
  46320. */
  46321. static AddUniforms(uniforms: string[]): void;
  46322. /**
  46323. * Add the required uniforms to the current buffer.
  46324. * @param uniformBuffer defines the current uniform buffer.
  46325. */
  46326. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46327. /**
  46328. * Add the required samplers to the current list.
  46329. * @param samplers defines the current sampler list.
  46330. */
  46331. static AddSamplers(samplers: string[]): void;
  46332. /**
  46333. * Makes a duplicate of the current configuration into another one.
  46334. * @param sheenConfiguration define the config where to copy the info
  46335. */
  46336. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46337. /**
  46338. * Serializes this BRDF configuration.
  46339. * @returns - An object with the serialized config.
  46340. */
  46341. serialize(): any;
  46342. /**
  46343. * Parses a Sheen Configuration from a serialized object.
  46344. * @param source - Serialized object.
  46345. */
  46346. parse(source: any): void;
  46347. }
  46348. }
  46349. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46350. import { Nullable } from "babylonjs/types";
  46351. import { IAnimatable } from "babylonjs/Misc/tools";
  46352. import { Color3 } from "babylonjs/Maths/math";
  46353. import { SmartArray } from "babylonjs/Misc/smartArray";
  46354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46355. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46356. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46357. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46358. import { Engine } from "babylonjs/Engines/engine";
  46359. import { Scene } from "babylonjs/scene";
  46360. /**
  46361. * @hidden
  46362. */
  46363. export interface IMaterialSubSurfaceDefines {
  46364. SUBSURFACE: boolean;
  46365. SS_REFRACTION: boolean;
  46366. SS_TRANSLUCENCY: boolean;
  46367. SS_SCATERRING: boolean;
  46368. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46369. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46370. SS_REFRACTIONMAP_3D: boolean;
  46371. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46372. SS_LODINREFRACTIONALPHA: boolean;
  46373. SS_GAMMAREFRACTION: boolean;
  46374. SS_RGBDREFRACTION: boolean;
  46375. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46376. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46377. /** @hidden */
  46378. _areTexturesDirty: boolean;
  46379. }
  46380. /**
  46381. * Define the code related to the sub surface parameters of the pbr material.
  46382. */
  46383. export class PBRSubSurfaceConfiguration {
  46384. private _isRefractionEnabled;
  46385. /**
  46386. * Defines if the refraction is enabled in the material.
  46387. */
  46388. isRefractionEnabled: boolean;
  46389. private _isTranslucencyEnabled;
  46390. /**
  46391. * Defines if the translucency is enabled in the material.
  46392. */
  46393. isTranslucencyEnabled: boolean;
  46394. private _isScatteringEnabled;
  46395. /**
  46396. * Defines the refraction intensity of the material.
  46397. * The refraction when enabled replaces the Diffuse part of the material.
  46398. * The intensity helps transitionning between diffuse and refraction.
  46399. */
  46400. refractionIntensity: number;
  46401. /**
  46402. * Defines the translucency intensity of the material.
  46403. * When translucency has been enabled, this defines how much of the "translucency"
  46404. * is addded to the diffuse part of the material.
  46405. */
  46406. translucencyIntensity: number;
  46407. /**
  46408. * Defines the scattering intensity of the material.
  46409. * When scattering has been enabled, this defines how much of the "scattered light"
  46410. * is addded to the diffuse part of the material.
  46411. */
  46412. scatteringIntensity: number;
  46413. private _thicknessTexture;
  46414. /**
  46415. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46416. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46417. * 0 would mean minimumThickness
  46418. * 1 would mean maximumThickness
  46419. * The other channels might be use as a mask to vary the different effects intensity.
  46420. */
  46421. thicknessTexture: Nullable<BaseTexture>;
  46422. private _refractionTexture;
  46423. /**
  46424. * Defines the texture to use for refraction.
  46425. */
  46426. refractionTexture: Nullable<BaseTexture>;
  46427. private _indexOfRefraction;
  46428. /**
  46429. * Defines the indice of refraction used in the material.
  46430. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46431. */
  46432. indexOfRefraction: number;
  46433. private _invertRefractionY;
  46434. /**
  46435. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46436. */
  46437. invertRefractionY: boolean;
  46438. private _linkRefractionWithTransparency;
  46439. /**
  46440. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46441. * Materials half opaque for instance using refraction could benefit from this control.
  46442. */
  46443. linkRefractionWithTransparency: boolean;
  46444. /**
  46445. * Defines the minimum thickness stored in the thickness map.
  46446. * If no thickness map is defined, this value will be used to simulate thickness.
  46447. */
  46448. minimumThickness: number;
  46449. /**
  46450. * Defines the maximum thickness stored in the thickness map.
  46451. */
  46452. maximumThickness: number;
  46453. /**
  46454. * Defines the volume tint of the material.
  46455. * This is used for both translucency and scattering.
  46456. */
  46457. tintColor: Color3;
  46458. /**
  46459. * Defines the distance at which the tint color should be found in the media.
  46460. * This is used for refraction only.
  46461. */
  46462. tintColorAtDistance: number;
  46463. /**
  46464. * Defines how far each channel transmit through the media.
  46465. * It is defined as a color to simplify it selection.
  46466. */
  46467. diffusionDistance: Color3;
  46468. private _useMaskFromThicknessTexture;
  46469. /**
  46470. * Stores the intensity of the different subsurface effects in the thickness texture.
  46471. * * the green channel is the translucency intensity.
  46472. * * the blue channel is the scattering intensity.
  46473. * * the alpha channel is the refraction intensity.
  46474. */
  46475. useMaskFromThicknessTexture: boolean;
  46476. /** @hidden */
  46477. private _internalMarkAllSubMeshesAsTexturesDirty;
  46478. /** @hidden */
  46479. _markAllSubMeshesAsTexturesDirty(): void;
  46480. /**
  46481. * Instantiate a new istance of sub surface configuration.
  46482. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46483. */
  46484. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46485. /**
  46486. * Gets wehter the submesh is ready to be used or not.
  46487. * @param defines the list of "defines" to update.
  46488. * @param scene defines the scene the material belongs to.
  46489. * @returns - boolean indicating that the submesh is ready or not.
  46490. */
  46491. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46492. /**
  46493. * Checks to see if a texture is used in the material.
  46494. * @param defines the list of "defines" to update.
  46495. * @param scene defines the scene to the material belongs to.
  46496. */
  46497. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46498. /**
  46499. * Binds the material data.
  46500. * @param uniformBuffer defines the Uniform buffer to fill in.
  46501. * @param scene defines the scene the material belongs to.
  46502. * @param engine defines the engine the material belongs to.
  46503. * @param isFrozen defines wether the material is frozen or not.
  46504. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46505. */
  46506. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46507. /**
  46508. * Unbinds the material from the mesh.
  46509. * @param activeEffect defines the effect that should be unbound from.
  46510. * @returns true if unbound, otherwise false
  46511. */
  46512. unbind(activeEffect: Effect): boolean;
  46513. /**
  46514. * Returns the texture used for refraction or null if none is used.
  46515. * @param scene defines the scene the material belongs to.
  46516. * @returns - Refraction texture if present. If no refraction texture and refraction
  46517. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46518. */
  46519. private _getRefractionTexture;
  46520. /**
  46521. * Returns true if alpha blending should be disabled.
  46522. */
  46523. readonly disableAlphaBlending: boolean;
  46524. /**
  46525. * Fills the list of render target textures.
  46526. * @param renderTargets the list of render targets to update
  46527. */
  46528. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46529. /**
  46530. * Checks to see if a texture is used in the material.
  46531. * @param texture - Base texture to use.
  46532. * @returns - Boolean specifying if a texture is used in the material.
  46533. */
  46534. hasTexture(texture: BaseTexture): boolean;
  46535. /**
  46536. * Gets a boolean indicating that current material needs to register RTT
  46537. * @returns true if this uses a render target otherwise false.
  46538. */
  46539. hasRenderTargetTextures(): boolean;
  46540. /**
  46541. * Returns an array of the actively used textures.
  46542. * @param activeTextures Array of BaseTextures
  46543. */
  46544. getActiveTextures(activeTextures: BaseTexture[]): void;
  46545. /**
  46546. * Returns the animatable textures.
  46547. * @param animatables Array of animatable textures.
  46548. */
  46549. getAnimatables(animatables: IAnimatable[]): void;
  46550. /**
  46551. * Disposes the resources of the material.
  46552. * @param forceDisposeTextures - Forces the disposal of all textures.
  46553. */
  46554. dispose(forceDisposeTextures?: boolean): void;
  46555. /**
  46556. * Get the current class name of the texture useful for serialization or dynamic coding.
  46557. * @returns "PBRSubSurfaceConfiguration"
  46558. */
  46559. getClassName(): string;
  46560. /**
  46561. * Add fallbacks to the effect fallbacks list.
  46562. * @param defines defines the Base texture to use.
  46563. * @param fallbacks defines the current fallback list.
  46564. * @param currentRank defines the current fallback rank.
  46565. * @returns the new fallback rank.
  46566. */
  46567. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46568. /**
  46569. * Add the required uniforms to the current list.
  46570. * @param uniforms defines the current uniform list.
  46571. */
  46572. static AddUniforms(uniforms: string[]): void;
  46573. /**
  46574. * Add the required samplers to the current list.
  46575. * @param samplers defines the current sampler list.
  46576. */
  46577. static AddSamplers(samplers: string[]): void;
  46578. /**
  46579. * Add the required uniforms to the current buffer.
  46580. * @param uniformBuffer defines the current uniform buffer.
  46581. */
  46582. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46583. /**
  46584. * Makes a duplicate of the current configuration into another one.
  46585. * @param configuration define the config where to copy the info
  46586. */
  46587. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46588. /**
  46589. * Serializes this Sub Surface configuration.
  46590. * @returns - An object with the serialized config.
  46591. */
  46592. serialize(): any;
  46593. /**
  46594. * Parses a Sub Surface Configuration from a serialized object.
  46595. * @param source - Serialized object.
  46596. */
  46597. parse(source: any): void;
  46598. }
  46599. }
  46600. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46601. /** @hidden */
  46602. export var pbrFragmentDeclaration: {
  46603. name: string;
  46604. shader: string;
  46605. };
  46606. }
  46607. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46608. /** @hidden */
  46609. export var pbrUboDeclaration: {
  46610. name: string;
  46611. shader: string;
  46612. };
  46613. }
  46614. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46615. /** @hidden */
  46616. export var pbrFragmentExtraDeclaration: {
  46617. name: string;
  46618. shader: string;
  46619. };
  46620. }
  46621. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46622. /** @hidden */
  46623. export var pbrFragmentSamplersDeclaration: {
  46624. name: string;
  46625. shader: string;
  46626. };
  46627. }
  46628. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46629. /** @hidden */
  46630. export var pbrHelperFunctions: {
  46631. name: string;
  46632. shader: string;
  46633. };
  46634. }
  46635. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46636. /** @hidden */
  46637. export var harmonicsFunctions: {
  46638. name: string;
  46639. shader: string;
  46640. };
  46641. }
  46642. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46643. /** @hidden */
  46644. export var pbrDirectLightingSetupFunctions: {
  46645. name: string;
  46646. shader: string;
  46647. };
  46648. }
  46649. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46650. /** @hidden */
  46651. export var pbrDirectLightingFalloffFunctions: {
  46652. name: string;
  46653. shader: string;
  46654. };
  46655. }
  46656. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46657. /** @hidden */
  46658. export var pbrBRDFFunctions: {
  46659. name: string;
  46660. shader: string;
  46661. };
  46662. }
  46663. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46664. /** @hidden */
  46665. export var pbrDirectLightingFunctions: {
  46666. name: string;
  46667. shader: string;
  46668. };
  46669. }
  46670. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46671. /** @hidden */
  46672. export var pbrIBLFunctions: {
  46673. name: string;
  46674. shader: string;
  46675. };
  46676. }
  46677. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46678. /** @hidden */
  46679. export var pbrDebug: {
  46680. name: string;
  46681. shader: string;
  46682. };
  46683. }
  46684. declare module "babylonjs/Shaders/pbr.fragment" {
  46685. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46686. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46687. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46688. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46689. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46690. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46691. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46692. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46693. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46694. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46695. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46696. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46697. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46698. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46699. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46700. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46701. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46702. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46703. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46704. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46705. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46706. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46707. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46708. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46709. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46710. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46711. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46712. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46713. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46714. /** @hidden */
  46715. export var pbrPixelShader: {
  46716. name: string;
  46717. shader: string;
  46718. };
  46719. }
  46720. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46721. /** @hidden */
  46722. export var pbrVertexDeclaration: {
  46723. name: string;
  46724. shader: string;
  46725. };
  46726. }
  46727. declare module "babylonjs/Shaders/pbr.vertex" {
  46728. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46729. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46730. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46731. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46732. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46733. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46734. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46735. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46736. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46737. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46738. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46741. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46743. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46744. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46745. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46746. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46747. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46748. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46749. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46750. /** @hidden */
  46751. export var pbrVertexShader: {
  46752. name: string;
  46753. shader: string;
  46754. };
  46755. }
  46756. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46757. import { IAnimatable } from "babylonjs/Misc/tools";
  46758. import { Nullable } from "babylonjs/types";
  46759. import { Scene } from "babylonjs/scene";
  46760. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46761. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46763. import { Mesh } from "babylonjs/Meshes/mesh";
  46764. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46765. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46766. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46767. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46768. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46769. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46770. import { Material } from "babylonjs/Materials/material";
  46771. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46772. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46774. import "babylonjs/Shaders/pbr.fragment";
  46775. import "babylonjs/Shaders/pbr.vertex";
  46776. /**
  46777. * Manages the defines for the PBR Material.
  46778. * @hidden
  46779. */
  46780. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46781. PBR: boolean;
  46782. MAINUV1: boolean;
  46783. MAINUV2: boolean;
  46784. UV1: boolean;
  46785. UV2: boolean;
  46786. ALBEDO: boolean;
  46787. ALBEDODIRECTUV: number;
  46788. VERTEXCOLOR: boolean;
  46789. AMBIENT: boolean;
  46790. AMBIENTDIRECTUV: number;
  46791. AMBIENTINGRAYSCALE: boolean;
  46792. OPACITY: boolean;
  46793. VERTEXALPHA: boolean;
  46794. OPACITYDIRECTUV: number;
  46795. OPACITYRGB: boolean;
  46796. ALPHATEST: boolean;
  46797. DEPTHPREPASS: boolean;
  46798. ALPHABLEND: boolean;
  46799. ALPHAFROMALBEDO: boolean;
  46800. ALPHATESTVALUE: string;
  46801. SPECULAROVERALPHA: boolean;
  46802. RADIANCEOVERALPHA: boolean;
  46803. ALPHAFRESNEL: boolean;
  46804. LINEARALPHAFRESNEL: boolean;
  46805. PREMULTIPLYALPHA: boolean;
  46806. EMISSIVE: boolean;
  46807. EMISSIVEDIRECTUV: number;
  46808. REFLECTIVITY: boolean;
  46809. REFLECTIVITYDIRECTUV: number;
  46810. SPECULARTERM: boolean;
  46811. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46812. MICROSURFACEAUTOMATIC: boolean;
  46813. LODBASEDMICROSFURACE: boolean;
  46814. MICROSURFACEMAP: boolean;
  46815. MICROSURFACEMAPDIRECTUV: number;
  46816. METALLICWORKFLOW: boolean;
  46817. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46818. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46819. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46820. AOSTOREINMETALMAPRED: boolean;
  46821. ENVIRONMENTBRDF: boolean;
  46822. ENVIRONMENTBRDF_RGBD: boolean;
  46823. NORMAL: boolean;
  46824. TANGENT: boolean;
  46825. BUMP: boolean;
  46826. BUMPDIRECTUV: number;
  46827. OBJECTSPACE_NORMALMAP: boolean;
  46828. PARALLAX: boolean;
  46829. PARALLAXOCCLUSION: boolean;
  46830. NORMALXYSCALE: boolean;
  46831. LIGHTMAP: boolean;
  46832. LIGHTMAPDIRECTUV: number;
  46833. USELIGHTMAPASSHADOWMAP: boolean;
  46834. GAMMALIGHTMAP: boolean;
  46835. REFLECTION: boolean;
  46836. REFLECTIONMAP_3D: boolean;
  46837. REFLECTIONMAP_SPHERICAL: boolean;
  46838. REFLECTIONMAP_PLANAR: boolean;
  46839. REFLECTIONMAP_CUBIC: boolean;
  46840. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46841. REFLECTIONMAP_PROJECTION: boolean;
  46842. REFLECTIONMAP_SKYBOX: boolean;
  46843. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46844. REFLECTIONMAP_EXPLICIT: boolean;
  46845. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46846. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46847. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46848. INVERTCUBICMAP: boolean;
  46849. USESPHERICALFROMREFLECTIONMAP: boolean;
  46850. SPHERICAL_HARMONICS: boolean;
  46851. USESPHERICALINVERTEX: boolean;
  46852. REFLECTIONMAP_OPPOSITEZ: boolean;
  46853. LODINREFLECTIONALPHA: boolean;
  46854. GAMMAREFLECTION: boolean;
  46855. RGBDREFLECTION: boolean;
  46856. RADIANCEOCCLUSION: boolean;
  46857. HORIZONOCCLUSION: boolean;
  46858. INSTANCES: boolean;
  46859. NUM_BONE_INFLUENCERS: number;
  46860. BonesPerMesh: number;
  46861. BONETEXTURE: boolean;
  46862. NONUNIFORMSCALING: boolean;
  46863. MORPHTARGETS: boolean;
  46864. MORPHTARGETS_NORMAL: boolean;
  46865. MORPHTARGETS_TANGENT: boolean;
  46866. NUM_MORPH_INFLUENCERS: number;
  46867. IMAGEPROCESSING: boolean;
  46868. VIGNETTE: boolean;
  46869. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46870. VIGNETTEBLENDMODEOPAQUE: boolean;
  46871. TONEMAPPING: boolean;
  46872. TONEMAPPING_ACES: boolean;
  46873. CONTRAST: boolean;
  46874. COLORCURVES: boolean;
  46875. COLORGRADING: boolean;
  46876. COLORGRADING3D: boolean;
  46877. SAMPLER3DGREENDEPTH: boolean;
  46878. SAMPLER3DBGRMAP: boolean;
  46879. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46880. EXPOSURE: boolean;
  46881. MULTIVIEW: boolean;
  46882. USEPHYSICALLIGHTFALLOFF: boolean;
  46883. USEGLTFLIGHTFALLOFF: boolean;
  46884. TWOSIDEDLIGHTING: boolean;
  46885. SHADOWFLOAT: boolean;
  46886. CLIPPLANE: boolean;
  46887. CLIPPLANE2: boolean;
  46888. CLIPPLANE3: boolean;
  46889. CLIPPLANE4: boolean;
  46890. POINTSIZE: boolean;
  46891. FOG: boolean;
  46892. LOGARITHMICDEPTH: boolean;
  46893. FORCENORMALFORWARD: boolean;
  46894. SPECULARAA: boolean;
  46895. CLEARCOAT: boolean;
  46896. CLEARCOAT_DEFAULTIOR: boolean;
  46897. CLEARCOAT_TEXTURE: boolean;
  46898. CLEARCOAT_TEXTUREDIRECTUV: number;
  46899. CLEARCOAT_BUMP: boolean;
  46900. CLEARCOAT_BUMPDIRECTUV: number;
  46901. CLEARCOAT_TINT: boolean;
  46902. CLEARCOAT_TINT_TEXTURE: boolean;
  46903. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46904. ANISOTROPIC: boolean;
  46905. ANISOTROPIC_TEXTURE: boolean;
  46906. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46907. BRDF_V_HEIGHT_CORRELATED: boolean;
  46908. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46909. SHEEN: boolean;
  46910. SHEEN_TEXTURE: boolean;
  46911. SHEEN_TEXTUREDIRECTUV: number;
  46912. SHEEN_LINKWITHALBEDO: boolean;
  46913. SUBSURFACE: boolean;
  46914. SS_REFRACTION: boolean;
  46915. SS_TRANSLUCENCY: boolean;
  46916. SS_SCATERRING: boolean;
  46917. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46918. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46919. SS_REFRACTIONMAP_3D: boolean;
  46920. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46921. SS_LODINREFRACTIONALPHA: boolean;
  46922. SS_GAMMAREFRACTION: boolean;
  46923. SS_RGBDREFRACTION: boolean;
  46924. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46925. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46926. UNLIT: boolean;
  46927. DEBUGMODE: number;
  46928. /**
  46929. * Initializes the PBR Material defines.
  46930. */
  46931. constructor();
  46932. /**
  46933. * Resets the PBR Material defines.
  46934. */
  46935. reset(): void;
  46936. }
  46937. /**
  46938. * The Physically based material base class of BJS.
  46939. *
  46940. * This offers the main features of a standard PBR material.
  46941. * For more information, please refer to the documentation :
  46942. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46943. */
  46944. export abstract class PBRBaseMaterial extends PushMaterial {
  46945. /**
  46946. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46947. */
  46948. static readonly PBRMATERIAL_OPAQUE: number;
  46949. /**
  46950. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46951. */
  46952. static readonly PBRMATERIAL_ALPHATEST: number;
  46953. /**
  46954. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46955. */
  46956. static readonly PBRMATERIAL_ALPHABLEND: number;
  46957. /**
  46958. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46959. * They are also discarded below the alpha cutoff threshold to improve performances.
  46960. */
  46961. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46962. /**
  46963. * Defines the default value of how much AO map is occluding the analytical lights
  46964. * (point spot...).
  46965. */
  46966. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46967. /**
  46968. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46969. */
  46970. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46971. /**
  46972. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46973. * to enhance interoperability with other engines.
  46974. */
  46975. static readonly LIGHTFALLOFF_GLTF: number;
  46976. /**
  46977. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46978. * to enhance interoperability with other materials.
  46979. */
  46980. static readonly LIGHTFALLOFF_STANDARD: number;
  46981. /**
  46982. * Intensity of the direct lights e.g. the four lights available in your scene.
  46983. * This impacts both the direct diffuse and specular highlights.
  46984. */
  46985. protected _directIntensity: number;
  46986. /**
  46987. * Intensity of the emissive part of the material.
  46988. * This helps controlling the emissive effect without modifying the emissive color.
  46989. */
  46990. protected _emissiveIntensity: number;
  46991. /**
  46992. * Intensity of the environment e.g. how much the environment will light the object
  46993. * either through harmonics for rough material or through the refelction for shiny ones.
  46994. */
  46995. protected _environmentIntensity: number;
  46996. /**
  46997. * This is a special control allowing the reduction of the specular highlights coming from the
  46998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46999. */
  47000. protected _specularIntensity: number;
  47001. /**
  47002. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47003. */
  47004. private _lightingInfos;
  47005. /**
  47006. * Debug Control allowing disabling the bump map on this material.
  47007. */
  47008. protected _disableBumpMap: boolean;
  47009. /**
  47010. * AKA Diffuse Texture in standard nomenclature.
  47011. */
  47012. protected _albedoTexture: Nullable<BaseTexture>;
  47013. /**
  47014. * AKA Occlusion Texture in other nomenclature.
  47015. */
  47016. protected _ambientTexture: Nullable<BaseTexture>;
  47017. /**
  47018. * AKA Occlusion Texture Intensity in other nomenclature.
  47019. */
  47020. protected _ambientTextureStrength: number;
  47021. /**
  47022. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47023. * 1 means it completely occludes it
  47024. * 0 mean it has no impact
  47025. */
  47026. protected _ambientTextureImpactOnAnalyticalLights: number;
  47027. /**
  47028. * Stores the alpha values in a texture.
  47029. */
  47030. protected _opacityTexture: Nullable<BaseTexture>;
  47031. /**
  47032. * Stores the reflection values in a texture.
  47033. */
  47034. protected _reflectionTexture: Nullable<BaseTexture>;
  47035. /**
  47036. * Stores the emissive values in a texture.
  47037. */
  47038. protected _emissiveTexture: Nullable<BaseTexture>;
  47039. /**
  47040. * AKA Specular texture in other nomenclature.
  47041. */
  47042. protected _reflectivityTexture: Nullable<BaseTexture>;
  47043. /**
  47044. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47045. */
  47046. protected _metallicTexture: Nullable<BaseTexture>;
  47047. /**
  47048. * Specifies the metallic scalar of the metallic/roughness workflow.
  47049. * Can also be used to scale the metalness values of the metallic texture.
  47050. */
  47051. protected _metallic: Nullable<number>;
  47052. /**
  47053. * Specifies the roughness scalar of the metallic/roughness workflow.
  47054. * Can also be used to scale the roughness values of the metallic texture.
  47055. */
  47056. protected _roughness: Nullable<number>;
  47057. /**
  47058. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47059. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47060. */
  47061. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47062. /**
  47063. * Stores surface normal data used to displace a mesh in a texture.
  47064. */
  47065. protected _bumpTexture: Nullable<BaseTexture>;
  47066. /**
  47067. * Stores the pre-calculated light information of a mesh in a texture.
  47068. */
  47069. protected _lightmapTexture: Nullable<BaseTexture>;
  47070. /**
  47071. * The color of a material in ambient lighting.
  47072. */
  47073. protected _ambientColor: Color3;
  47074. /**
  47075. * AKA Diffuse Color in other nomenclature.
  47076. */
  47077. protected _albedoColor: Color3;
  47078. /**
  47079. * AKA Specular Color in other nomenclature.
  47080. */
  47081. protected _reflectivityColor: Color3;
  47082. /**
  47083. * The color applied when light is reflected from a material.
  47084. */
  47085. protected _reflectionColor: Color3;
  47086. /**
  47087. * The color applied when light is emitted from a material.
  47088. */
  47089. protected _emissiveColor: Color3;
  47090. /**
  47091. * AKA Glossiness in other nomenclature.
  47092. */
  47093. protected _microSurface: number;
  47094. /**
  47095. * Specifies that the material will use the light map as a show map.
  47096. */
  47097. protected _useLightmapAsShadowmap: boolean;
  47098. /**
  47099. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47100. * makes the reflect vector face the model (under horizon).
  47101. */
  47102. protected _useHorizonOcclusion: boolean;
  47103. /**
  47104. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47105. * too much the area relying on ambient texture to define their ambient occlusion.
  47106. */
  47107. protected _useRadianceOcclusion: boolean;
  47108. /**
  47109. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47110. */
  47111. protected _useAlphaFromAlbedoTexture: boolean;
  47112. /**
  47113. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47114. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47115. */
  47116. protected _useSpecularOverAlpha: boolean;
  47117. /**
  47118. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47119. */
  47120. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47121. /**
  47122. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47123. */
  47124. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47125. /**
  47126. * Specifies if the metallic texture contains the roughness information in its green channel.
  47127. */
  47128. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47129. /**
  47130. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47131. */
  47132. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47133. /**
  47134. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47135. */
  47136. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47137. /**
  47138. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47139. */
  47140. protected _useAmbientInGrayScale: boolean;
  47141. /**
  47142. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47143. * The material will try to infer what glossiness each pixel should be.
  47144. */
  47145. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47146. /**
  47147. * Defines the falloff type used in this material.
  47148. * It by default is Physical.
  47149. */
  47150. protected _lightFalloff: number;
  47151. /**
  47152. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47153. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47154. */
  47155. protected _useRadianceOverAlpha: boolean;
  47156. /**
  47157. * Allows using an object space normal map (instead of tangent space).
  47158. */
  47159. protected _useObjectSpaceNormalMap: boolean;
  47160. /**
  47161. * Allows using the bump map in parallax mode.
  47162. */
  47163. protected _useParallax: boolean;
  47164. /**
  47165. * Allows using the bump map in parallax occlusion mode.
  47166. */
  47167. protected _useParallaxOcclusion: boolean;
  47168. /**
  47169. * Controls the scale bias of the parallax mode.
  47170. */
  47171. protected _parallaxScaleBias: number;
  47172. /**
  47173. * If sets to true, disables all the lights affecting the material.
  47174. */
  47175. protected _disableLighting: boolean;
  47176. /**
  47177. * Number of Simultaneous lights allowed on the material.
  47178. */
  47179. protected _maxSimultaneousLights: number;
  47180. /**
  47181. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47182. */
  47183. protected _invertNormalMapX: boolean;
  47184. /**
  47185. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47186. */
  47187. protected _invertNormalMapY: boolean;
  47188. /**
  47189. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47190. */
  47191. protected _twoSidedLighting: boolean;
  47192. /**
  47193. * Defines the alpha limits in alpha test mode.
  47194. */
  47195. protected _alphaCutOff: number;
  47196. /**
  47197. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47198. */
  47199. protected _forceAlphaTest: boolean;
  47200. /**
  47201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47202. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47203. */
  47204. protected _useAlphaFresnel: boolean;
  47205. /**
  47206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47207. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47208. */
  47209. protected _useLinearAlphaFresnel: boolean;
  47210. /**
  47211. * The transparency mode of the material.
  47212. */
  47213. protected _transparencyMode: Nullable<number>;
  47214. /**
  47215. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47216. * from cos thetav and roughness:
  47217. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47218. */
  47219. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47220. /**
  47221. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47222. */
  47223. protected _forceIrradianceInFragment: boolean;
  47224. /**
  47225. * Force normal to face away from face.
  47226. */
  47227. protected _forceNormalForward: boolean;
  47228. /**
  47229. * Enables specular anti aliasing in the PBR shader.
  47230. * It will both interacts on the Geometry for analytical and IBL lighting.
  47231. * It also prefilter the roughness map based on the bump values.
  47232. */
  47233. protected _enableSpecularAntiAliasing: boolean;
  47234. /**
  47235. * Default configuration related to image processing available in the PBR Material.
  47236. */
  47237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47238. /**
  47239. * Keep track of the image processing observer to allow dispose and replace.
  47240. */
  47241. private _imageProcessingObserver;
  47242. /**
  47243. * Attaches a new image processing configuration to the PBR Material.
  47244. * @param configuration
  47245. */
  47246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47247. /**
  47248. * Stores the available render targets.
  47249. */
  47250. private _renderTargets;
  47251. /**
  47252. * Sets the global ambient color for the material used in lighting calculations.
  47253. */
  47254. private _globalAmbientColor;
  47255. /**
  47256. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47257. */
  47258. private _useLogarithmicDepth;
  47259. /**
  47260. * If set to true, no lighting calculations will be applied.
  47261. */
  47262. private _unlit;
  47263. private _debugMode;
  47264. /**
  47265. * @hidden
  47266. * This is reserved for the inspector.
  47267. * Defines the material debug mode.
  47268. * It helps seeing only some components of the material while troubleshooting.
  47269. */
  47270. debugMode: number;
  47271. /**
  47272. * @hidden
  47273. * This is reserved for the inspector.
  47274. * Specify from where on screen the debug mode should start.
  47275. * The value goes from -1 (full screen) to 1 (not visible)
  47276. * It helps with side by side comparison against the final render
  47277. * This defaults to -1
  47278. */
  47279. private debugLimit;
  47280. /**
  47281. * @hidden
  47282. * This is reserved for the inspector.
  47283. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47284. * You can use the factor to better multiply the final value.
  47285. */
  47286. private debugFactor;
  47287. /**
  47288. * Defines the clear coat layer parameters for the material.
  47289. */
  47290. readonly clearCoat: PBRClearCoatConfiguration;
  47291. /**
  47292. * Defines the anisotropic parameters for the material.
  47293. */
  47294. readonly anisotropy: PBRAnisotropicConfiguration;
  47295. /**
  47296. * Defines the BRDF parameters for the material.
  47297. */
  47298. readonly brdf: PBRBRDFConfiguration;
  47299. /**
  47300. * Defines the Sheen parameters for the material.
  47301. */
  47302. readonly sheen: PBRSheenConfiguration;
  47303. /**
  47304. * Defines the SubSurface parameters for the material.
  47305. */
  47306. readonly subSurface: PBRSubSurfaceConfiguration;
  47307. /**
  47308. * Custom callback helping to override the default shader used in the material.
  47309. */
  47310. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47311. /**
  47312. * Instantiates a new PBRMaterial instance.
  47313. *
  47314. * @param name The material name
  47315. * @param scene The scene the material will be use in.
  47316. */
  47317. constructor(name: string, scene: Scene);
  47318. /**
  47319. * Gets a boolean indicating that current material needs to register RTT
  47320. */
  47321. readonly hasRenderTargetTextures: boolean;
  47322. /**
  47323. * Gets the name of the material class.
  47324. */
  47325. getClassName(): string;
  47326. /**
  47327. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47328. */
  47329. /**
  47330. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47331. */
  47332. useLogarithmicDepth: boolean;
  47333. /**
  47334. * Gets the current transparency mode.
  47335. */
  47336. /**
  47337. * Sets the transparency mode of the material.
  47338. *
  47339. * | Value | Type | Description |
  47340. * | ----- | ----------------------------------- | ----------- |
  47341. * | 0 | OPAQUE | |
  47342. * | 1 | ALPHATEST | |
  47343. * | 2 | ALPHABLEND | |
  47344. * | 3 | ALPHATESTANDBLEND | |
  47345. *
  47346. */
  47347. transparencyMode: Nullable<number>;
  47348. /**
  47349. * Returns true if alpha blending should be disabled.
  47350. */
  47351. private readonly _disableAlphaBlending;
  47352. /**
  47353. * Specifies whether or not this material should be rendered in alpha blend mode.
  47354. */
  47355. needAlphaBlending(): boolean;
  47356. /**
  47357. * Specifies if the mesh will require alpha blending.
  47358. * @param mesh - BJS mesh.
  47359. */
  47360. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47361. /**
  47362. * Specifies whether or not this material should be rendered in alpha test mode.
  47363. */
  47364. needAlphaTesting(): boolean;
  47365. /**
  47366. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47367. */
  47368. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47369. /**
  47370. * Gets the texture used for the alpha test.
  47371. */
  47372. getAlphaTestTexture(): Nullable<BaseTexture>;
  47373. /**
  47374. * Specifies that the submesh is ready to be used.
  47375. * @param mesh - BJS mesh.
  47376. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47377. * @param useInstances - Specifies that instances should be used.
  47378. * @returns - boolean indicating that the submesh is ready or not.
  47379. */
  47380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47381. /**
  47382. * Specifies if the material uses metallic roughness workflow.
  47383. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47384. */
  47385. isMetallicWorkflow(): boolean;
  47386. private _prepareEffect;
  47387. private _prepareDefines;
  47388. /**
  47389. * Force shader compilation
  47390. */
  47391. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47392. clipPlane: boolean;
  47393. }>): void;
  47394. /**
  47395. * Initializes the uniform buffer layout for the shader.
  47396. */
  47397. buildUniformLayout(): void;
  47398. /**
  47399. * Unbinds the material from the mesh
  47400. */
  47401. unbind(): void;
  47402. /**
  47403. * Binds the submesh data.
  47404. * @param world - The world matrix.
  47405. * @param mesh - The BJS mesh.
  47406. * @param subMesh - A submesh of the BJS mesh.
  47407. */
  47408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47409. /**
  47410. * Returns the animatable textures.
  47411. * @returns - Array of animatable textures.
  47412. */
  47413. getAnimatables(): IAnimatable[];
  47414. /**
  47415. * Returns the texture used for reflections.
  47416. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47417. */
  47418. private _getReflectionTexture;
  47419. /**
  47420. * Returns an array of the actively used textures.
  47421. * @returns - Array of BaseTextures
  47422. */
  47423. getActiveTextures(): BaseTexture[];
  47424. /**
  47425. * Checks to see if a texture is used in the material.
  47426. * @param texture - Base texture to use.
  47427. * @returns - Boolean specifying if a texture is used in the material.
  47428. */
  47429. hasTexture(texture: BaseTexture): boolean;
  47430. /**
  47431. * Disposes the resources of the material.
  47432. * @param forceDisposeEffect - Forces the disposal of effects.
  47433. * @param forceDisposeTextures - Forces the disposal of all textures.
  47434. */
  47435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47436. }
  47437. }
  47438. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47439. import { Nullable } from "babylonjs/types";
  47440. import { Scene } from "babylonjs/scene";
  47441. import { Color3 } from "babylonjs/Maths/math";
  47442. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47443. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47445. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47446. /**
  47447. * The Physically based material of BJS.
  47448. *
  47449. * This offers the main features of a standard PBR material.
  47450. * For more information, please refer to the documentation :
  47451. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47452. */
  47453. export class PBRMaterial extends PBRBaseMaterial {
  47454. /**
  47455. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47456. */
  47457. static readonly PBRMATERIAL_OPAQUE: number;
  47458. /**
  47459. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47460. */
  47461. static readonly PBRMATERIAL_ALPHATEST: number;
  47462. /**
  47463. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47464. */
  47465. static readonly PBRMATERIAL_ALPHABLEND: number;
  47466. /**
  47467. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47468. * They are also discarded below the alpha cutoff threshold to improve performances.
  47469. */
  47470. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47471. /**
  47472. * Defines the default value of how much AO map is occluding the analytical lights
  47473. * (point spot...).
  47474. */
  47475. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47476. /**
  47477. * Intensity of the direct lights e.g. the four lights available in your scene.
  47478. * This impacts both the direct diffuse and specular highlights.
  47479. */
  47480. directIntensity: number;
  47481. /**
  47482. * Intensity of the emissive part of the material.
  47483. * This helps controlling the emissive effect without modifying the emissive color.
  47484. */
  47485. emissiveIntensity: number;
  47486. /**
  47487. * Intensity of the environment e.g. how much the environment will light the object
  47488. * either through harmonics for rough material or through the refelction for shiny ones.
  47489. */
  47490. environmentIntensity: number;
  47491. /**
  47492. * This is a special control allowing the reduction of the specular highlights coming from the
  47493. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47494. */
  47495. specularIntensity: number;
  47496. /**
  47497. * Debug Control allowing disabling the bump map on this material.
  47498. */
  47499. disableBumpMap: boolean;
  47500. /**
  47501. * AKA Diffuse Texture in standard nomenclature.
  47502. */
  47503. albedoTexture: BaseTexture;
  47504. /**
  47505. * AKA Occlusion Texture in other nomenclature.
  47506. */
  47507. ambientTexture: BaseTexture;
  47508. /**
  47509. * AKA Occlusion Texture Intensity in other nomenclature.
  47510. */
  47511. ambientTextureStrength: number;
  47512. /**
  47513. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47514. * 1 means it completely occludes it
  47515. * 0 mean it has no impact
  47516. */
  47517. ambientTextureImpactOnAnalyticalLights: number;
  47518. /**
  47519. * Stores the alpha values in a texture.
  47520. */
  47521. opacityTexture: BaseTexture;
  47522. /**
  47523. * Stores the reflection values in a texture.
  47524. */
  47525. reflectionTexture: Nullable<BaseTexture>;
  47526. /**
  47527. * Stores the emissive values in a texture.
  47528. */
  47529. emissiveTexture: BaseTexture;
  47530. /**
  47531. * AKA Specular texture in other nomenclature.
  47532. */
  47533. reflectivityTexture: BaseTexture;
  47534. /**
  47535. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47536. */
  47537. metallicTexture: BaseTexture;
  47538. /**
  47539. * Specifies the metallic scalar of the metallic/roughness workflow.
  47540. * Can also be used to scale the metalness values of the metallic texture.
  47541. */
  47542. metallic: Nullable<number>;
  47543. /**
  47544. * Specifies the roughness scalar of the metallic/roughness workflow.
  47545. * Can also be used to scale the roughness values of the metallic texture.
  47546. */
  47547. roughness: Nullable<number>;
  47548. /**
  47549. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47550. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47551. */
  47552. microSurfaceTexture: BaseTexture;
  47553. /**
  47554. * Stores surface normal data used to displace a mesh in a texture.
  47555. */
  47556. bumpTexture: BaseTexture;
  47557. /**
  47558. * Stores the pre-calculated light information of a mesh in a texture.
  47559. */
  47560. lightmapTexture: BaseTexture;
  47561. /**
  47562. * Stores the refracted light information in a texture.
  47563. */
  47564. refractionTexture: Nullable<BaseTexture>;
  47565. /**
  47566. * The color of a material in ambient lighting.
  47567. */
  47568. ambientColor: Color3;
  47569. /**
  47570. * AKA Diffuse Color in other nomenclature.
  47571. */
  47572. albedoColor: Color3;
  47573. /**
  47574. * AKA Specular Color in other nomenclature.
  47575. */
  47576. reflectivityColor: Color3;
  47577. /**
  47578. * The color reflected from the material.
  47579. */
  47580. reflectionColor: Color3;
  47581. /**
  47582. * The color emitted from the material.
  47583. */
  47584. emissiveColor: Color3;
  47585. /**
  47586. * AKA Glossiness in other nomenclature.
  47587. */
  47588. microSurface: number;
  47589. /**
  47590. * source material index of refraction (IOR)' / 'destination material IOR.
  47591. */
  47592. indexOfRefraction: number;
  47593. /**
  47594. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47595. */
  47596. invertRefractionY: boolean;
  47597. /**
  47598. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47599. * Materials half opaque for instance using refraction could benefit from this control.
  47600. */
  47601. linkRefractionWithTransparency: boolean;
  47602. /**
  47603. * If true, the light map contains occlusion information instead of lighting info.
  47604. */
  47605. useLightmapAsShadowmap: boolean;
  47606. /**
  47607. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47608. */
  47609. useAlphaFromAlbedoTexture: boolean;
  47610. /**
  47611. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47612. */
  47613. forceAlphaTest: boolean;
  47614. /**
  47615. * Defines the alpha limits in alpha test mode.
  47616. */
  47617. alphaCutOff: number;
  47618. /**
  47619. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47620. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47621. */
  47622. useSpecularOverAlpha: boolean;
  47623. /**
  47624. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47625. */
  47626. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47627. /**
  47628. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47629. */
  47630. useRoughnessFromMetallicTextureAlpha: boolean;
  47631. /**
  47632. * Specifies if the metallic texture contains the roughness information in its green channel.
  47633. */
  47634. useRoughnessFromMetallicTextureGreen: boolean;
  47635. /**
  47636. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47637. */
  47638. useMetallnessFromMetallicTextureBlue: boolean;
  47639. /**
  47640. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47641. */
  47642. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47643. /**
  47644. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47645. */
  47646. useAmbientInGrayScale: boolean;
  47647. /**
  47648. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47649. * The material will try to infer what glossiness each pixel should be.
  47650. */
  47651. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47652. /**
  47653. * BJS is using an harcoded light falloff based on a manually sets up range.
  47654. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47655. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47656. */
  47657. /**
  47658. * BJS is using an harcoded light falloff based on a manually sets up range.
  47659. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47660. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47661. */
  47662. usePhysicalLightFalloff: boolean;
  47663. /**
  47664. * In order to support the falloff compatibility with gltf, a special mode has been added
  47665. * to reproduce the gltf light falloff.
  47666. */
  47667. /**
  47668. * In order to support the falloff compatibility with gltf, a special mode has been added
  47669. * to reproduce the gltf light falloff.
  47670. */
  47671. useGLTFLightFalloff: boolean;
  47672. /**
  47673. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47674. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47675. */
  47676. useRadianceOverAlpha: boolean;
  47677. /**
  47678. * Allows using an object space normal map (instead of tangent space).
  47679. */
  47680. useObjectSpaceNormalMap: boolean;
  47681. /**
  47682. * Allows using the bump map in parallax mode.
  47683. */
  47684. useParallax: boolean;
  47685. /**
  47686. * Allows using the bump map in parallax occlusion mode.
  47687. */
  47688. useParallaxOcclusion: boolean;
  47689. /**
  47690. * Controls the scale bias of the parallax mode.
  47691. */
  47692. parallaxScaleBias: number;
  47693. /**
  47694. * If sets to true, disables all the lights affecting the material.
  47695. */
  47696. disableLighting: boolean;
  47697. /**
  47698. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47699. */
  47700. forceIrradianceInFragment: boolean;
  47701. /**
  47702. * Number of Simultaneous lights allowed on the material.
  47703. */
  47704. maxSimultaneousLights: number;
  47705. /**
  47706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47707. */
  47708. invertNormalMapX: boolean;
  47709. /**
  47710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47711. */
  47712. invertNormalMapY: boolean;
  47713. /**
  47714. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47715. */
  47716. twoSidedLighting: boolean;
  47717. /**
  47718. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47719. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47720. */
  47721. useAlphaFresnel: boolean;
  47722. /**
  47723. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47724. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47725. */
  47726. useLinearAlphaFresnel: boolean;
  47727. /**
  47728. * Let user defines the brdf lookup texture used for IBL.
  47729. * A default 8bit version is embedded but you could point at :
  47730. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47731. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47732. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47733. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47734. */
  47735. environmentBRDFTexture: Nullable<BaseTexture>;
  47736. /**
  47737. * Force normal to face away from face.
  47738. */
  47739. forceNormalForward: boolean;
  47740. /**
  47741. * Enables specular anti aliasing in the PBR shader.
  47742. * It will both interacts on the Geometry for analytical and IBL lighting.
  47743. * It also prefilter the roughness map based on the bump values.
  47744. */
  47745. enableSpecularAntiAliasing: boolean;
  47746. /**
  47747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47748. * makes the reflect vector face the model (under horizon).
  47749. */
  47750. useHorizonOcclusion: boolean;
  47751. /**
  47752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47753. * too much the area relying on ambient texture to define their ambient occlusion.
  47754. */
  47755. useRadianceOcclusion: boolean;
  47756. /**
  47757. * If set to true, no lighting calculations will be applied.
  47758. */
  47759. unlit: boolean;
  47760. /**
  47761. * Gets the image processing configuration used either in this material.
  47762. */
  47763. /**
  47764. * Sets the Default image processing configuration used either in the this material.
  47765. *
  47766. * If sets to null, the scene one is in use.
  47767. */
  47768. imageProcessingConfiguration: ImageProcessingConfiguration;
  47769. /**
  47770. * Gets wether the color curves effect is enabled.
  47771. */
  47772. /**
  47773. * Sets wether the color curves effect is enabled.
  47774. */
  47775. cameraColorCurvesEnabled: boolean;
  47776. /**
  47777. * Gets wether the color grading effect is enabled.
  47778. */
  47779. /**
  47780. * Gets wether the color grading effect is enabled.
  47781. */
  47782. cameraColorGradingEnabled: boolean;
  47783. /**
  47784. * Gets wether tonemapping is enabled or not.
  47785. */
  47786. /**
  47787. * Sets wether tonemapping is enabled or not
  47788. */
  47789. cameraToneMappingEnabled: boolean;
  47790. /**
  47791. * The camera exposure used on this material.
  47792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47793. * This corresponds to a photographic exposure.
  47794. */
  47795. /**
  47796. * The camera exposure used on this material.
  47797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47798. * This corresponds to a photographic exposure.
  47799. */
  47800. cameraExposure: number;
  47801. /**
  47802. * Gets The camera contrast used on this material.
  47803. */
  47804. /**
  47805. * Sets The camera contrast used on this material.
  47806. */
  47807. cameraContrast: number;
  47808. /**
  47809. * Gets the Color Grading 2D Lookup Texture.
  47810. */
  47811. /**
  47812. * Sets the Color Grading 2D Lookup Texture.
  47813. */
  47814. cameraColorGradingTexture: Nullable<BaseTexture>;
  47815. /**
  47816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47818. * 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;
  47819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47820. */
  47821. /**
  47822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47824. * 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;
  47825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47826. */
  47827. cameraColorCurves: Nullable<ColorCurves>;
  47828. /**
  47829. * Instantiates a new PBRMaterial instance.
  47830. *
  47831. * @param name The material name
  47832. * @param scene The scene the material will be use in.
  47833. */
  47834. constructor(name: string, scene: Scene);
  47835. /**
  47836. * Returns the name of this material class.
  47837. */
  47838. getClassName(): string;
  47839. /**
  47840. * Makes a duplicate of the current material.
  47841. * @param name - name to use for the new material.
  47842. */
  47843. clone(name: string): PBRMaterial;
  47844. /**
  47845. * Serializes this PBR Material.
  47846. * @returns - An object with the serialized material.
  47847. */
  47848. serialize(): any;
  47849. /**
  47850. * Parses a PBR Material from a serialized object.
  47851. * @param source - Serialized object.
  47852. * @param scene - BJS scene instance.
  47853. * @param rootUrl - url for the scene object
  47854. * @returns - PBRMaterial
  47855. */
  47856. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47857. }
  47858. }
  47859. declare module "babylonjs/Misc/dds" {
  47860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47861. import { Engine } from "babylonjs/Engines/engine";
  47862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47863. import { Nullable } from "babylonjs/types";
  47864. import { Scene } from "babylonjs/scene";
  47865. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  47866. /**
  47867. * Direct draw surface info
  47868. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47869. */
  47870. export interface DDSInfo {
  47871. /**
  47872. * Width of the texture
  47873. */
  47874. width: number;
  47875. /**
  47876. * Width of the texture
  47877. */
  47878. height: number;
  47879. /**
  47880. * Number of Mipmaps for the texture
  47881. * @see https://en.wikipedia.org/wiki/Mipmap
  47882. */
  47883. mipmapCount: number;
  47884. /**
  47885. * If the textures format is a known fourCC format
  47886. * @see https://www.fourcc.org/
  47887. */
  47888. isFourCC: boolean;
  47889. /**
  47890. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47891. */
  47892. isRGB: boolean;
  47893. /**
  47894. * If the texture is a lumincance format
  47895. */
  47896. isLuminance: boolean;
  47897. /**
  47898. * If this is a cube texture
  47899. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47900. */
  47901. isCube: boolean;
  47902. /**
  47903. * If the texture is a compressed format eg. FOURCC_DXT1
  47904. */
  47905. isCompressed: boolean;
  47906. /**
  47907. * The dxgiFormat of the texture
  47908. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47909. */
  47910. dxgiFormat: number;
  47911. /**
  47912. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47913. */
  47914. textureType: number;
  47915. /**
  47916. * Sphericle polynomial created for the dds texture
  47917. */
  47918. sphericalPolynomial?: SphericalPolynomial;
  47919. }
  47920. /**
  47921. * Class used to provide DDS decompression tools
  47922. */
  47923. export class DDSTools {
  47924. /**
  47925. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47926. */
  47927. static StoreLODInAlphaChannel: boolean;
  47928. /**
  47929. * Gets DDS information from an array buffer
  47930. * @param arrayBuffer defines the array buffer to read data from
  47931. * @returns the DDS information
  47932. */
  47933. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47934. private static _FloatView;
  47935. private static _Int32View;
  47936. private static _ToHalfFloat;
  47937. private static _FromHalfFloat;
  47938. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47939. private static _GetHalfFloatRGBAArrayBuffer;
  47940. private static _GetFloatRGBAArrayBuffer;
  47941. private static _GetFloatAsUIntRGBAArrayBuffer;
  47942. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47943. private static _GetRGBAArrayBuffer;
  47944. private static _ExtractLongWordOrder;
  47945. private static _GetRGBArrayBuffer;
  47946. private static _GetLuminanceArrayBuffer;
  47947. /**
  47948. * Uploads DDS Levels to a Babylon Texture
  47949. * @hidden
  47950. */
  47951. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47952. }
  47953. module "babylonjs/Engines/engine" {
  47954. interface Engine {
  47955. /**
  47956. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47957. * @param rootUrl defines the url where the file to load is located
  47958. * @param scene defines the current scene
  47959. * @param lodScale defines scale to apply to the mip map selection
  47960. * @param lodOffset defines offset to apply to the mip map selection
  47961. * @param onLoad defines an optional callback raised when the texture is loaded
  47962. * @param onError defines an optional callback raised if there is an issue to load the texture
  47963. * @param format defines the format of the data
  47964. * @param forcedExtension defines the extension to use to pick the right loader
  47965. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47966. * @returns the cube texture as an InternalTexture
  47967. */
  47968. 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;
  47969. }
  47970. }
  47971. }
  47972. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47973. import { Nullable } from "babylonjs/types";
  47974. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47975. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47976. /**
  47977. * Implementation of the DDS Texture Loader.
  47978. * @hidden
  47979. */
  47980. export class _DDSTextureLoader implements IInternalTextureLoader {
  47981. /**
  47982. * Defines wether the loader supports cascade loading the different faces.
  47983. */
  47984. readonly supportCascades: boolean;
  47985. /**
  47986. * This returns if the loader support the current file information.
  47987. * @param extension defines the file extension of the file being loaded
  47988. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47989. * @param fallback defines the fallback internal texture if any
  47990. * @param isBase64 defines whether the texture is encoded as a base64
  47991. * @param isBuffer defines whether the texture data are stored as a buffer
  47992. * @returns true if the loader can load the specified file
  47993. */
  47994. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47995. /**
  47996. * Transform the url before loading if required.
  47997. * @param rootUrl the url of the texture
  47998. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47999. * @returns the transformed texture
  48000. */
  48001. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48002. /**
  48003. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48004. * @param rootUrl the url of the texture
  48005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48006. * @returns the fallback texture
  48007. */
  48008. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48009. /**
  48010. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48011. * @param data contains the texture data
  48012. * @param texture defines the BabylonJS internal texture
  48013. * @param createPolynomials will be true if polynomials have been requested
  48014. * @param onLoad defines the callback to trigger once the texture is ready
  48015. * @param onError defines the callback to trigger in case of error
  48016. */
  48017. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48018. /**
  48019. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48020. * @param data contains the texture data
  48021. * @param texture defines the BabylonJS internal texture
  48022. * @param callback defines the method to call once ready to upload
  48023. */
  48024. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48025. }
  48026. }
  48027. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48028. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48029. /** @hidden */
  48030. export var rgbdEncodePixelShader: {
  48031. name: string;
  48032. shader: string;
  48033. };
  48034. }
  48035. declare module "babylonjs/Misc/environmentTextureTools" {
  48036. import { Nullable } from "babylonjs/types";
  48037. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48039. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48040. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48041. import "babylonjs/Shaders/rgbdEncode.fragment";
  48042. import "babylonjs/Shaders/rgbdDecode.fragment";
  48043. /**
  48044. * Raw texture data and descriptor sufficient for WebGL texture upload
  48045. */
  48046. export interface EnvironmentTextureInfo {
  48047. /**
  48048. * Version of the environment map
  48049. */
  48050. version: number;
  48051. /**
  48052. * Width of image
  48053. */
  48054. width: number;
  48055. /**
  48056. * Irradiance information stored in the file.
  48057. */
  48058. irradiance: any;
  48059. /**
  48060. * Specular information stored in the file.
  48061. */
  48062. specular: any;
  48063. }
  48064. /**
  48065. * Sets of helpers addressing the serialization and deserialization of environment texture
  48066. * stored in a BabylonJS env file.
  48067. * Those files are usually stored as .env files.
  48068. */
  48069. export class EnvironmentTextureTools {
  48070. /**
  48071. * Magic number identifying the env file.
  48072. */
  48073. private static _MagicBytes;
  48074. /**
  48075. * Gets the environment info from an env file.
  48076. * @param data The array buffer containing the .env bytes.
  48077. * @returns the environment file info (the json header) if successfully parsed.
  48078. */
  48079. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48080. /**
  48081. * Creates an environment texture from a loaded cube texture.
  48082. * @param texture defines the cube texture to convert in env file
  48083. * @return a promise containing the environment data if succesfull.
  48084. */
  48085. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48086. /**
  48087. * Creates a JSON representation of the spherical data.
  48088. * @param texture defines the texture containing the polynomials
  48089. * @return the JSON representation of the spherical info
  48090. */
  48091. private static _CreateEnvTextureIrradiance;
  48092. /**
  48093. * Uploads the texture info contained in the env file to the GPU.
  48094. * @param texture defines the internal texture to upload to
  48095. * @param arrayBuffer defines the buffer cotaining the data to load
  48096. * @param info defines the texture info retrieved through the GetEnvInfo method
  48097. * @returns a promise
  48098. */
  48099. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48100. /**
  48101. * Uploads the levels of image data to the GPU.
  48102. * @param texture defines the internal texture to upload to
  48103. * @param imageData defines the array buffer views of image data [mipmap][face]
  48104. * @returns a promise
  48105. */
  48106. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48107. /**
  48108. * Uploads spherical polynomials information to the texture.
  48109. * @param texture defines the texture we are trying to upload the information to
  48110. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48111. */
  48112. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48113. /** @hidden */
  48114. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48115. }
  48116. }
  48117. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48118. import { Nullable } from "babylonjs/types";
  48119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48120. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48121. /**
  48122. * Implementation of the ENV Texture Loader.
  48123. * @hidden
  48124. */
  48125. export class _ENVTextureLoader implements IInternalTextureLoader {
  48126. /**
  48127. * Defines wether the loader supports cascade loading the different faces.
  48128. */
  48129. readonly supportCascades: boolean;
  48130. /**
  48131. * This returns if the loader support the current file information.
  48132. * @param extension defines the file extension of the file being loaded
  48133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48134. * @param fallback defines the fallback internal texture if any
  48135. * @param isBase64 defines whether the texture is encoded as a base64
  48136. * @param isBuffer defines whether the texture data are stored as a buffer
  48137. * @returns true if the loader can load the specified file
  48138. */
  48139. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48140. /**
  48141. * Transform the url before loading if required.
  48142. * @param rootUrl the url of the texture
  48143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48144. * @returns the transformed texture
  48145. */
  48146. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48147. /**
  48148. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48149. * @param rootUrl the url of the texture
  48150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48151. * @returns the fallback texture
  48152. */
  48153. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48154. /**
  48155. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48156. * @param data contains the texture data
  48157. * @param texture defines the BabylonJS internal texture
  48158. * @param createPolynomials will be true if polynomials have been requested
  48159. * @param onLoad defines the callback to trigger once the texture is ready
  48160. * @param onError defines the callback to trigger in case of error
  48161. */
  48162. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48163. /**
  48164. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48165. * @param data contains the texture data
  48166. * @param texture defines the BabylonJS internal texture
  48167. * @param callback defines the method to call once ready to upload
  48168. */
  48169. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48170. }
  48171. }
  48172. declare module "babylonjs/Misc/khronosTextureContainer" {
  48173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48174. /**
  48175. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48176. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48177. */
  48178. export class KhronosTextureContainer {
  48179. /** contents of the KTX container file */
  48180. arrayBuffer: any;
  48181. private static HEADER_LEN;
  48182. private static COMPRESSED_2D;
  48183. private static COMPRESSED_3D;
  48184. private static TEX_2D;
  48185. private static TEX_3D;
  48186. /**
  48187. * Gets the openGL type
  48188. */
  48189. glType: number;
  48190. /**
  48191. * Gets the openGL type size
  48192. */
  48193. glTypeSize: number;
  48194. /**
  48195. * Gets the openGL format
  48196. */
  48197. glFormat: number;
  48198. /**
  48199. * Gets the openGL internal format
  48200. */
  48201. glInternalFormat: number;
  48202. /**
  48203. * Gets the base internal format
  48204. */
  48205. glBaseInternalFormat: number;
  48206. /**
  48207. * Gets image width in pixel
  48208. */
  48209. pixelWidth: number;
  48210. /**
  48211. * Gets image height in pixel
  48212. */
  48213. pixelHeight: number;
  48214. /**
  48215. * Gets image depth in pixels
  48216. */
  48217. pixelDepth: number;
  48218. /**
  48219. * Gets the number of array elements
  48220. */
  48221. numberOfArrayElements: number;
  48222. /**
  48223. * Gets the number of faces
  48224. */
  48225. numberOfFaces: number;
  48226. /**
  48227. * Gets the number of mipmap levels
  48228. */
  48229. numberOfMipmapLevels: number;
  48230. /**
  48231. * Gets the bytes of key value data
  48232. */
  48233. bytesOfKeyValueData: number;
  48234. /**
  48235. * Gets the load type
  48236. */
  48237. loadType: number;
  48238. /**
  48239. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48240. */
  48241. isInvalid: boolean;
  48242. /**
  48243. * Creates a new KhronosTextureContainer
  48244. * @param arrayBuffer contents of the KTX container file
  48245. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48246. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48247. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48248. */
  48249. constructor(
  48250. /** contents of the KTX container file */
  48251. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48252. /**
  48253. * Uploads KTX content to a Babylon Texture.
  48254. * It is assumed that the texture has already been created & is currently bound
  48255. * @hidden
  48256. */
  48257. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48258. private _upload2DCompressedLevels;
  48259. }
  48260. }
  48261. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48262. import { Nullable } from "babylonjs/types";
  48263. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48264. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48265. /**
  48266. * Implementation of the KTX Texture Loader.
  48267. * @hidden
  48268. */
  48269. export class _KTXTextureLoader implements IInternalTextureLoader {
  48270. /**
  48271. * Defines wether the loader supports cascade loading the different faces.
  48272. */
  48273. readonly supportCascades: boolean;
  48274. /**
  48275. * This returns if the loader support the current file information.
  48276. * @param extension defines the file extension of the file being loaded
  48277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48278. * @param fallback defines the fallback internal texture if any
  48279. * @param isBase64 defines whether the texture is encoded as a base64
  48280. * @param isBuffer defines whether the texture data are stored as a buffer
  48281. * @returns true if the loader can load the specified file
  48282. */
  48283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48284. /**
  48285. * Transform the url before loading if required.
  48286. * @param rootUrl the url of the texture
  48287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48288. * @returns the transformed texture
  48289. */
  48290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48291. /**
  48292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48293. * @param rootUrl the url of the texture
  48294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48295. * @returns the fallback texture
  48296. */
  48297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48298. /**
  48299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48300. * @param data contains the texture data
  48301. * @param texture defines the BabylonJS internal texture
  48302. * @param createPolynomials will be true if polynomials have been requested
  48303. * @param onLoad defines the callback to trigger once the texture is ready
  48304. * @param onError defines the callback to trigger in case of error
  48305. */
  48306. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48307. /**
  48308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48309. * @param data contains the texture data
  48310. * @param texture defines the BabylonJS internal texture
  48311. * @param callback defines the method to call once ready to upload
  48312. */
  48313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48314. }
  48315. }
  48316. declare module "babylonjs/Helpers/sceneHelpers" {
  48317. import { Nullable } from "babylonjs/types";
  48318. import { Mesh } from "babylonjs/Meshes/mesh";
  48319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48320. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48321. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48322. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48323. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48324. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48325. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48326. import "babylonjs/Meshes/Builders/boxBuilder";
  48327. /** @hidden */
  48328. export var _forceSceneHelpersToBundle: boolean;
  48329. module "babylonjs/scene" {
  48330. interface Scene {
  48331. /**
  48332. * Creates a default light for the scene.
  48333. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48334. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48335. */
  48336. createDefaultLight(replace?: boolean): void;
  48337. /**
  48338. * Creates a default camera for the scene.
  48339. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48340. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48341. * @param replace has default false, when true replaces the active camera in the scene
  48342. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48343. */
  48344. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48345. /**
  48346. * Creates a default camera and a default light.
  48347. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48348. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48349. * @param replace has the default false, when true replaces the active camera/light in the scene
  48350. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48351. */
  48352. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48353. /**
  48354. * Creates a new sky box
  48355. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48356. * @param environmentTexture defines the texture to use as environment texture
  48357. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48358. * @param scale defines the overall scale of the skybox
  48359. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48360. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48361. * @returns a new mesh holding the sky box
  48362. */
  48363. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48364. /**
  48365. * Creates a new environment
  48366. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48367. * @param options defines the options you can use to configure the environment
  48368. * @returns the new EnvironmentHelper
  48369. */
  48370. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48371. /**
  48372. * Creates a new VREXperienceHelper
  48373. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48374. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48375. * @returns a new VREXperienceHelper
  48376. */
  48377. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48378. /**
  48379. * Creates a new XREXperienceHelper
  48380. * @see http://doc.babylonjs.com/how_to/webxr
  48381. * @returns a promise for a new XREXperienceHelper
  48382. */
  48383. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48384. }
  48385. }
  48386. }
  48387. declare module "babylonjs/Helpers/videoDome" {
  48388. import { Scene } from "babylonjs/scene";
  48389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48390. import { Mesh } from "babylonjs/Meshes/mesh";
  48391. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48392. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48393. import "babylonjs/Meshes/Builders/sphereBuilder";
  48394. /**
  48395. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48396. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48397. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48398. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48399. */
  48400. export class VideoDome extends TransformNode {
  48401. /**
  48402. * Define the video source as a Monoscopic panoramic 360 video.
  48403. */
  48404. static readonly MODE_MONOSCOPIC: number;
  48405. /**
  48406. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48407. */
  48408. static readonly MODE_TOPBOTTOM: number;
  48409. /**
  48410. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48411. */
  48412. static readonly MODE_SIDEBYSIDE: number;
  48413. private _useDirectMapping;
  48414. /**
  48415. * The video texture being displayed on the sphere
  48416. */
  48417. protected _videoTexture: VideoTexture;
  48418. /**
  48419. * Gets the video texture being displayed on the sphere
  48420. */
  48421. readonly videoTexture: VideoTexture;
  48422. /**
  48423. * The skybox material
  48424. */
  48425. protected _material: BackgroundMaterial;
  48426. /**
  48427. * The surface used for the skybox
  48428. */
  48429. protected _mesh: Mesh;
  48430. /**
  48431. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48432. * Also see the options.resolution property.
  48433. */
  48434. fovMultiplier: number;
  48435. private _videoMode;
  48436. /**
  48437. * Gets or set the current video mode for the video. It can be:
  48438. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48439. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48440. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48441. */
  48442. videoMode: number;
  48443. /**
  48444. * Oberserver used in Stereoscopic VR Mode.
  48445. */
  48446. private _onBeforeCameraRenderObserver;
  48447. /**
  48448. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48449. * @param name Element's name, child elements will append suffixes for their own names.
  48450. * @param urlsOrVideo defines the url(s) or the video element to use
  48451. * @param options An object containing optional or exposed sub element properties
  48452. */
  48453. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48454. resolution?: number;
  48455. clickToPlay?: boolean;
  48456. autoPlay?: boolean;
  48457. loop?: boolean;
  48458. size?: number;
  48459. poster?: string;
  48460. faceForward?: boolean;
  48461. useDirectMapping?: boolean;
  48462. }, scene: Scene);
  48463. private _changeVideoMode;
  48464. /**
  48465. * Releases resources associated with this node.
  48466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48468. */
  48469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48470. }
  48471. }
  48472. declare module "babylonjs/Helpers/index" {
  48473. export * from "babylonjs/Helpers/environmentHelper";
  48474. export * from "babylonjs/Helpers/photoDome";
  48475. export * from "babylonjs/Helpers/sceneHelpers";
  48476. export * from "babylonjs/Helpers/videoDome";
  48477. }
  48478. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48479. import { PerfCounter } from "babylonjs/Misc/tools";
  48480. import { IDisposable } from "babylonjs/scene";
  48481. import { Engine } from "babylonjs/Engines/engine";
  48482. /**
  48483. * This class can be used to get instrumentation data from a Babylon engine
  48484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48485. */
  48486. export class EngineInstrumentation implements IDisposable {
  48487. /**
  48488. * Define the instrumented engine.
  48489. */
  48490. engine: Engine;
  48491. private _captureGPUFrameTime;
  48492. private _gpuFrameTimeToken;
  48493. private _gpuFrameTime;
  48494. private _captureShaderCompilationTime;
  48495. private _shaderCompilationTime;
  48496. private _onBeginFrameObserver;
  48497. private _onEndFrameObserver;
  48498. private _onBeforeShaderCompilationObserver;
  48499. private _onAfterShaderCompilationObserver;
  48500. /**
  48501. * Gets the perf counter used for GPU frame time
  48502. */
  48503. readonly gpuFrameTimeCounter: PerfCounter;
  48504. /**
  48505. * Gets the GPU frame time capture status
  48506. */
  48507. /**
  48508. * Enable or disable the GPU frame time capture
  48509. */
  48510. captureGPUFrameTime: boolean;
  48511. /**
  48512. * Gets the perf counter used for shader compilation time
  48513. */
  48514. readonly shaderCompilationTimeCounter: PerfCounter;
  48515. /**
  48516. * Gets the shader compilation time capture status
  48517. */
  48518. /**
  48519. * Enable or disable the shader compilation time capture
  48520. */
  48521. captureShaderCompilationTime: boolean;
  48522. /**
  48523. * Instantiates a new engine instrumentation.
  48524. * This class can be used to get instrumentation data from a Babylon engine
  48525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48526. * @param engine Defines the engine to instrument
  48527. */
  48528. constructor(
  48529. /**
  48530. * Define the instrumented engine.
  48531. */
  48532. engine: Engine);
  48533. /**
  48534. * Dispose and release associated resources.
  48535. */
  48536. dispose(): void;
  48537. }
  48538. }
  48539. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48540. import { PerfCounter } from "babylonjs/Misc/tools";
  48541. import { Scene, IDisposable } from "babylonjs/scene";
  48542. /**
  48543. * This class can be used to get instrumentation data from a Babylon engine
  48544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48545. */
  48546. export class SceneInstrumentation implements IDisposable {
  48547. /**
  48548. * Defines the scene to instrument
  48549. */
  48550. scene: Scene;
  48551. private _captureActiveMeshesEvaluationTime;
  48552. private _activeMeshesEvaluationTime;
  48553. private _captureRenderTargetsRenderTime;
  48554. private _renderTargetsRenderTime;
  48555. private _captureFrameTime;
  48556. private _frameTime;
  48557. private _captureRenderTime;
  48558. private _renderTime;
  48559. private _captureInterFrameTime;
  48560. private _interFrameTime;
  48561. private _captureParticlesRenderTime;
  48562. private _particlesRenderTime;
  48563. private _captureSpritesRenderTime;
  48564. private _spritesRenderTime;
  48565. private _capturePhysicsTime;
  48566. private _physicsTime;
  48567. private _captureAnimationsTime;
  48568. private _animationsTime;
  48569. private _captureCameraRenderTime;
  48570. private _cameraRenderTime;
  48571. private _onBeforeActiveMeshesEvaluationObserver;
  48572. private _onAfterActiveMeshesEvaluationObserver;
  48573. private _onBeforeRenderTargetsRenderObserver;
  48574. private _onAfterRenderTargetsRenderObserver;
  48575. private _onAfterRenderObserver;
  48576. private _onBeforeDrawPhaseObserver;
  48577. private _onAfterDrawPhaseObserver;
  48578. private _onBeforeAnimationsObserver;
  48579. private _onBeforeParticlesRenderingObserver;
  48580. private _onAfterParticlesRenderingObserver;
  48581. private _onBeforeSpritesRenderingObserver;
  48582. private _onAfterSpritesRenderingObserver;
  48583. private _onBeforePhysicsObserver;
  48584. private _onAfterPhysicsObserver;
  48585. private _onAfterAnimationsObserver;
  48586. private _onBeforeCameraRenderObserver;
  48587. private _onAfterCameraRenderObserver;
  48588. /**
  48589. * Gets the perf counter used for active meshes evaluation time
  48590. */
  48591. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48592. /**
  48593. * Gets the active meshes evaluation time capture status
  48594. */
  48595. /**
  48596. * Enable or disable the active meshes evaluation time capture
  48597. */
  48598. captureActiveMeshesEvaluationTime: boolean;
  48599. /**
  48600. * Gets the perf counter used for render targets render time
  48601. */
  48602. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48603. /**
  48604. * Gets the render targets render time capture status
  48605. */
  48606. /**
  48607. * Enable or disable the render targets render time capture
  48608. */
  48609. captureRenderTargetsRenderTime: boolean;
  48610. /**
  48611. * Gets the perf counter used for particles render time
  48612. */
  48613. readonly particlesRenderTimeCounter: PerfCounter;
  48614. /**
  48615. * Gets the particles render time capture status
  48616. */
  48617. /**
  48618. * Enable or disable the particles render time capture
  48619. */
  48620. captureParticlesRenderTime: boolean;
  48621. /**
  48622. * Gets the perf counter used for sprites render time
  48623. */
  48624. readonly spritesRenderTimeCounter: PerfCounter;
  48625. /**
  48626. * Gets the sprites render time capture status
  48627. */
  48628. /**
  48629. * Enable or disable the sprites render time capture
  48630. */
  48631. captureSpritesRenderTime: boolean;
  48632. /**
  48633. * Gets the perf counter used for physics time
  48634. */
  48635. readonly physicsTimeCounter: PerfCounter;
  48636. /**
  48637. * Gets the physics time capture status
  48638. */
  48639. /**
  48640. * Enable or disable the physics time capture
  48641. */
  48642. capturePhysicsTime: boolean;
  48643. /**
  48644. * Gets the perf counter used for animations time
  48645. */
  48646. readonly animationsTimeCounter: PerfCounter;
  48647. /**
  48648. * Gets the animations time capture status
  48649. */
  48650. /**
  48651. * Enable or disable the animations time capture
  48652. */
  48653. captureAnimationsTime: boolean;
  48654. /**
  48655. * Gets the perf counter used for frame time capture
  48656. */
  48657. readonly frameTimeCounter: PerfCounter;
  48658. /**
  48659. * Gets the frame time capture status
  48660. */
  48661. /**
  48662. * Enable or disable the frame time capture
  48663. */
  48664. captureFrameTime: boolean;
  48665. /**
  48666. * Gets the perf counter used for inter-frames time capture
  48667. */
  48668. readonly interFrameTimeCounter: PerfCounter;
  48669. /**
  48670. * Gets the inter-frames time capture status
  48671. */
  48672. /**
  48673. * Enable or disable the inter-frames time capture
  48674. */
  48675. captureInterFrameTime: boolean;
  48676. /**
  48677. * Gets the perf counter used for render time capture
  48678. */
  48679. readonly renderTimeCounter: PerfCounter;
  48680. /**
  48681. * Gets the render time capture status
  48682. */
  48683. /**
  48684. * Enable or disable the render time capture
  48685. */
  48686. captureRenderTime: boolean;
  48687. /**
  48688. * Gets the perf counter used for camera render time capture
  48689. */
  48690. readonly cameraRenderTimeCounter: PerfCounter;
  48691. /**
  48692. * Gets the camera render time capture status
  48693. */
  48694. /**
  48695. * Enable or disable the camera render time capture
  48696. */
  48697. captureCameraRenderTime: boolean;
  48698. /**
  48699. * Gets the perf counter used for draw calls
  48700. */
  48701. readonly drawCallsCounter: PerfCounter;
  48702. /**
  48703. * Instantiates a new scene instrumentation.
  48704. * This class can be used to get instrumentation data from a Babylon engine
  48705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48706. * @param scene Defines the scene to instrument
  48707. */
  48708. constructor(
  48709. /**
  48710. * Defines the scene to instrument
  48711. */
  48712. scene: Scene);
  48713. /**
  48714. * Dispose and release associated resources.
  48715. */
  48716. dispose(): void;
  48717. }
  48718. }
  48719. declare module "babylonjs/Instrumentation/index" {
  48720. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48721. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48722. export * from "babylonjs/Instrumentation/timeToken";
  48723. }
  48724. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48725. /** @hidden */
  48726. export var glowMapGenerationPixelShader: {
  48727. name: string;
  48728. shader: string;
  48729. };
  48730. }
  48731. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48739. /** @hidden */
  48740. export var glowMapGenerationVertexShader: {
  48741. name: string;
  48742. shader: string;
  48743. };
  48744. }
  48745. declare module "babylonjs/Layers/effectLayer" {
  48746. import { Observable } from "babylonjs/Misc/observable";
  48747. import { Nullable } from "babylonjs/types";
  48748. import { Camera } from "babylonjs/Cameras/camera";
  48749. import { Scene } from "babylonjs/scene";
  48750. import { Color4, ISize } from "babylonjs/Maths/math";
  48751. import { Engine } from "babylonjs/Engines/engine";
  48752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48754. import { Mesh } from "babylonjs/Meshes/mesh";
  48755. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48756. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48757. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48758. import { Effect } from "babylonjs/Materials/effect";
  48759. import { Material } from "babylonjs/Materials/material";
  48760. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48761. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48762. /**
  48763. * Effect layer options. This helps customizing the behaviour
  48764. * of the effect layer.
  48765. */
  48766. export interface IEffectLayerOptions {
  48767. /**
  48768. * Multiplication factor apply to the canvas size to compute the render target size
  48769. * used to generated the objects (the smaller the faster).
  48770. */
  48771. mainTextureRatio: number;
  48772. /**
  48773. * Enforces a fixed size texture to ensure effect stability across devices.
  48774. */
  48775. mainTextureFixedSize?: number;
  48776. /**
  48777. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48778. */
  48779. alphaBlendingMode: number;
  48780. /**
  48781. * The camera attached to the layer.
  48782. */
  48783. camera: Nullable<Camera>;
  48784. /**
  48785. * The rendering group to draw the layer in.
  48786. */
  48787. renderingGroupId: number;
  48788. }
  48789. /**
  48790. * The effect layer Helps adding post process effect blended with the main pass.
  48791. *
  48792. * This can be for instance use to generate glow or higlight effects on the scene.
  48793. *
  48794. * The effect layer class can not be used directly and is intented to inherited from to be
  48795. * customized per effects.
  48796. */
  48797. export abstract class EffectLayer {
  48798. private _vertexBuffers;
  48799. private _indexBuffer;
  48800. private _cachedDefines;
  48801. private _effectLayerMapGenerationEffect;
  48802. private _effectLayerOptions;
  48803. private _mergeEffect;
  48804. protected _scene: Scene;
  48805. protected _engine: Engine;
  48806. protected _maxSize: number;
  48807. protected _mainTextureDesiredSize: ISize;
  48808. protected _mainTexture: RenderTargetTexture;
  48809. protected _shouldRender: boolean;
  48810. protected _postProcesses: PostProcess[];
  48811. protected _textures: BaseTexture[];
  48812. protected _emissiveTextureAndColor: {
  48813. texture: Nullable<BaseTexture>;
  48814. color: Color4;
  48815. };
  48816. /**
  48817. * The name of the layer
  48818. */
  48819. name: string;
  48820. /**
  48821. * The clear color of the texture used to generate the glow map.
  48822. */
  48823. neutralColor: Color4;
  48824. /**
  48825. * Specifies wether the highlight layer is enabled or not.
  48826. */
  48827. isEnabled: boolean;
  48828. /**
  48829. * Gets the camera attached to the layer.
  48830. */
  48831. readonly camera: Nullable<Camera>;
  48832. /**
  48833. * Gets the rendering group id the layer should render in.
  48834. */
  48835. readonly renderingGroupId: number;
  48836. /**
  48837. * An event triggered when the effect layer has been disposed.
  48838. */
  48839. onDisposeObservable: Observable<EffectLayer>;
  48840. /**
  48841. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48842. */
  48843. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48844. /**
  48845. * An event triggered when the generated texture is being merged in the scene.
  48846. */
  48847. onBeforeComposeObservable: Observable<EffectLayer>;
  48848. /**
  48849. * An event triggered when the generated texture has been merged in the scene.
  48850. */
  48851. onAfterComposeObservable: Observable<EffectLayer>;
  48852. /**
  48853. * An event triggered when the efffect layer changes its size.
  48854. */
  48855. onSizeChangedObservable: Observable<EffectLayer>;
  48856. /** @hidden */
  48857. static _SceneComponentInitialization: (scene: Scene) => void;
  48858. /**
  48859. * Instantiates a new effect Layer and references it in the scene.
  48860. * @param name The name of the layer
  48861. * @param scene The scene to use the layer in
  48862. */
  48863. constructor(
  48864. /** The Friendly of the effect in the scene */
  48865. name: string, scene: Scene);
  48866. /**
  48867. * Get the effect name of the layer.
  48868. * @return The effect name
  48869. */
  48870. abstract getEffectName(): string;
  48871. /**
  48872. * Checks for the readiness of the element composing the layer.
  48873. * @param subMesh the mesh to check for
  48874. * @param useInstances specify wether or not to use instances to render the mesh
  48875. * @return true if ready otherwise, false
  48876. */
  48877. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48878. /**
  48879. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48880. * @returns true if the effect requires stencil during the main canvas render pass.
  48881. */
  48882. abstract needStencil(): boolean;
  48883. /**
  48884. * Create the merge effect. This is the shader use to blit the information back
  48885. * to the main canvas at the end of the scene rendering.
  48886. * @returns The effect containing the shader used to merge the effect on the main canvas
  48887. */
  48888. protected abstract _createMergeEffect(): Effect;
  48889. /**
  48890. * Creates the render target textures and post processes used in the effect layer.
  48891. */
  48892. protected abstract _createTextureAndPostProcesses(): void;
  48893. /**
  48894. * Implementation specific of rendering the generating effect on the main canvas.
  48895. * @param effect The effect used to render through
  48896. */
  48897. protected abstract _internalRender(effect: Effect): void;
  48898. /**
  48899. * Sets the required values for both the emissive texture and and the main color.
  48900. */
  48901. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48902. /**
  48903. * Free any resources and references associated to a mesh.
  48904. * Internal use
  48905. * @param mesh The mesh to free.
  48906. */
  48907. abstract _disposeMesh(mesh: Mesh): void;
  48908. /**
  48909. * Serializes this layer (Glow or Highlight for example)
  48910. * @returns a serialized layer object
  48911. */
  48912. abstract serialize?(): any;
  48913. /**
  48914. * Initializes the effect layer with the required options.
  48915. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48916. */
  48917. protected _init(options: Partial<IEffectLayerOptions>): void;
  48918. /**
  48919. * Generates the index buffer of the full screen quad blending to the main canvas.
  48920. */
  48921. private _generateIndexBuffer;
  48922. /**
  48923. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48924. */
  48925. private _generateVertexBuffer;
  48926. /**
  48927. * Sets the main texture desired size which is the closest power of two
  48928. * of the engine canvas size.
  48929. */
  48930. private _setMainTextureSize;
  48931. /**
  48932. * Creates the main texture for the effect layer.
  48933. */
  48934. protected _createMainTexture(): void;
  48935. /**
  48936. * Adds specific effects defines.
  48937. * @param defines The defines to add specifics to.
  48938. */
  48939. protected _addCustomEffectDefines(defines: string[]): void;
  48940. /**
  48941. * Checks for the readiness of the element composing the layer.
  48942. * @param subMesh the mesh to check for
  48943. * @param useInstances specify wether or not to use instances to render the mesh
  48944. * @param emissiveTexture the associated emissive texture used to generate the glow
  48945. * @return true if ready otherwise, false
  48946. */
  48947. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48948. /**
  48949. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48950. */
  48951. render(): void;
  48952. /**
  48953. * Determine if a given mesh will be used in the current effect.
  48954. * @param mesh mesh to test
  48955. * @returns true if the mesh will be used
  48956. */
  48957. hasMesh(mesh: AbstractMesh): boolean;
  48958. /**
  48959. * Returns true if the layer contains information to display, otherwise false.
  48960. * @returns true if the glow layer should be rendered
  48961. */
  48962. shouldRender(): boolean;
  48963. /**
  48964. * Returns true if the mesh should render, otherwise false.
  48965. * @param mesh The mesh to render
  48966. * @returns true if it should render otherwise false
  48967. */
  48968. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48969. /**
  48970. * Returns true if the mesh can be rendered, otherwise false.
  48971. * @param mesh The mesh to render
  48972. * @param material The material used on the mesh
  48973. * @returns true if it can be rendered otherwise false
  48974. */
  48975. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48976. /**
  48977. * Returns true if the mesh should render, otherwise false.
  48978. * @param mesh The mesh to render
  48979. * @returns true if it should render otherwise false
  48980. */
  48981. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48982. /**
  48983. * Renders the submesh passed in parameter to the generation map.
  48984. */
  48985. protected _renderSubMesh(subMesh: SubMesh): void;
  48986. /**
  48987. * Rebuild the required buffers.
  48988. * @hidden Internal use only.
  48989. */
  48990. _rebuild(): void;
  48991. /**
  48992. * Dispose only the render target textures and post process.
  48993. */
  48994. private _disposeTextureAndPostProcesses;
  48995. /**
  48996. * Dispose the highlight layer and free resources.
  48997. */
  48998. dispose(): void;
  48999. /**
  49000. * Gets the class name of the effect layer
  49001. * @returns the string with the class name of the effect layer
  49002. */
  49003. getClassName(): string;
  49004. /**
  49005. * Creates an effect layer from parsed effect layer data
  49006. * @param parsedEffectLayer defines effect layer data
  49007. * @param scene defines the current scene
  49008. * @param rootUrl defines the root URL containing the effect layer information
  49009. * @returns a parsed effect Layer
  49010. */
  49011. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49012. }
  49013. }
  49014. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49015. import { Scene } from "babylonjs/scene";
  49016. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49017. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49018. import { AbstractScene } from "babylonjs/abstractScene";
  49019. module "babylonjs/abstractScene" {
  49020. interface AbstractScene {
  49021. /**
  49022. * The list of effect layers (highlights/glow) added to the scene
  49023. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49024. * @see http://doc.babylonjs.com/how_to/glow_layer
  49025. */
  49026. effectLayers: Array<EffectLayer>;
  49027. /**
  49028. * Removes the given effect layer from this scene.
  49029. * @param toRemove defines the effect layer to remove
  49030. * @returns the index of the removed effect layer
  49031. */
  49032. removeEffectLayer(toRemove: EffectLayer): number;
  49033. /**
  49034. * Adds the given effect layer to this scene
  49035. * @param newEffectLayer defines the effect layer to add
  49036. */
  49037. addEffectLayer(newEffectLayer: EffectLayer): void;
  49038. }
  49039. }
  49040. /**
  49041. * Defines the layer scene component responsible to manage any effect layers
  49042. * in a given scene.
  49043. */
  49044. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49045. /**
  49046. * The component name helpfull to identify the component in the list of scene components.
  49047. */
  49048. readonly name: string;
  49049. /**
  49050. * The scene the component belongs to.
  49051. */
  49052. scene: Scene;
  49053. private _engine;
  49054. private _renderEffects;
  49055. private _needStencil;
  49056. private _previousStencilState;
  49057. /**
  49058. * Creates a new instance of the component for the given scene
  49059. * @param scene Defines the scene to register the component in
  49060. */
  49061. constructor(scene: Scene);
  49062. /**
  49063. * Registers the component in a given scene
  49064. */
  49065. register(): void;
  49066. /**
  49067. * Rebuilds the elements related to this component in case of
  49068. * context lost for instance.
  49069. */
  49070. rebuild(): void;
  49071. /**
  49072. * Serializes the component data to the specified json object
  49073. * @param serializationObject The object to serialize to
  49074. */
  49075. serialize(serializationObject: any): void;
  49076. /**
  49077. * Adds all the element from the container to the scene
  49078. * @param container the container holding the elements
  49079. */
  49080. addFromContainer(container: AbstractScene): void;
  49081. /**
  49082. * Removes all the elements in the container from the scene
  49083. * @param container contains the elements to remove
  49084. * @param dispose if the removed element should be disposed (default: false)
  49085. */
  49086. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49087. /**
  49088. * Disposes the component and the associated ressources.
  49089. */
  49090. dispose(): void;
  49091. private _isReadyForMesh;
  49092. private _renderMainTexture;
  49093. private _setStencil;
  49094. private _setStencilBack;
  49095. private _draw;
  49096. private _drawCamera;
  49097. private _drawRenderingGroup;
  49098. }
  49099. }
  49100. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49101. /** @hidden */
  49102. export var glowMapMergePixelShader: {
  49103. name: string;
  49104. shader: string;
  49105. };
  49106. }
  49107. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49108. /** @hidden */
  49109. export var glowMapMergeVertexShader: {
  49110. name: string;
  49111. shader: string;
  49112. };
  49113. }
  49114. declare module "babylonjs/Layers/glowLayer" {
  49115. import { Nullable } from "babylonjs/types";
  49116. import { Camera } from "babylonjs/Cameras/camera";
  49117. import { Scene } from "babylonjs/scene";
  49118. import { Color4 } from "babylonjs/Maths/math";
  49119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49121. import { Mesh } from "babylonjs/Meshes/mesh";
  49122. import { Texture } from "babylonjs/Materials/Textures/texture";
  49123. import { Effect } from "babylonjs/Materials/effect";
  49124. import { Material } from "babylonjs/Materials/material";
  49125. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49126. import "babylonjs/Shaders/glowMapMerge.fragment";
  49127. import "babylonjs/Shaders/glowMapMerge.vertex";
  49128. import "babylonjs/Layers/effectLayerSceneComponent";
  49129. module "babylonjs/abstractScene" {
  49130. interface AbstractScene {
  49131. /**
  49132. * Return a the first highlight layer of the scene with a given name.
  49133. * @param name The name of the highlight layer to look for.
  49134. * @return The highlight layer if found otherwise null.
  49135. */
  49136. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49137. }
  49138. }
  49139. /**
  49140. * Glow layer options. This helps customizing the behaviour
  49141. * of the glow layer.
  49142. */
  49143. export interface IGlowLayerOptions {
  49144. /**
  49145. * Multiplication factor apply to the canvas size to compute the render target size
  49146. * used to generated the glowing objects (the smaller the faster).
  49147. */
  49148. mainTextureRatio: number;
  49149. /**
  49150. * Enforces a fixed size texture to ensure resize independant blur.
  49151. */
  49152. mainTextureFixedSize?: number;
  49153. /**
  49154. * How big is the kernel of the blur texture.
  49155. */
  49156. blurKernelSize: number;
  49157. /**
  49158. * The camera attached to the layer.
  49159. */
  49160. camera: Nullable<Camera>;
  49161. /**
  49162. * Enable MSAA by chosing the number of samples.
  49163. */
  49164. mainTextureSamples?: number;
  49165. /**
  49166. * The rendering group to draw the layer in.
  49167. */
  49168. renderingGroupId: number;
  49169. }
  49170. /**
  49171. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49172. *
  49173. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49174. * glowy meshes to your scene.
  49175. *
  49176. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49177. */
  49178. export class GlowLayer extends EffectLayer {
  49179. /**
  49180. * Effect Name of the layer.
  49181. */
  49182. static readonly EffectName: string;
  49183. /**
  49184. * The default blur kernel size used for the glow.
  49185. */
  49186. static DefaultBlurKernelSize: number;
  49187. /**
  49188. * The default texture size ratio used for the glow.
  49189. */
  49190. static DefaultTextureRatio: number;
  49191. /**
  49192. * Sets the kernel size of the blur.
  49193. */
  49194. /**
  49195. * Gets the kernel size of the blur.
  49196. */
  49197. blurKernelSize: number;
  49198. /**
  49199. * Sets the glow intensity.
  49200. */
  49201. /**
  49202. * Gets the glow intensity.
  49203. */
  49204. intensity: number;
  49205. private _options;
  49206. private _intensity;
  49207. private _horizontalBlurPostprocess1;
  49208. private _verticalBlurPostprocess1;
  49209. private _horizontalBlurPostprocess2;
  49210. private _verticalBlurPostprocess2;
  49211. private _blurTexture1;
  49212. private _blurTexture2;
  49213. private _postProcesses1;
  49214. private _postProcesses2;
  49215. private _includedOnlyMeshes;
  49216. private _excludedMeshes;
  49217. /**
  49218. * Callback used to let the user override the color selection on a per mesh basis
  49219. */
  49220. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49221. /**
  49222. * Callback used to let the user override the texture selection on a per mesh basis
  49223. */
  49224. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49225. /**
  49226. * Instantiates a new glow Layer and references it to the scene.
  49227. * @param name The name of the layer
  49228. * @param scene The scene to use the layer in
  49229. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49230. */
  49231. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49232. /**
  49233. * Get the effect name of the layer.
  49234. * @return The effect name
  49235. */
  49236. getEffectName(): string;
  49237. /**
  49238. * Create the merge effect. This is the shader use to blit the information back
  49239. * to the main canvas at the end of the scene rendering.
  49240. */
  49241. protected _createMergeEffect(): Effect;
  49242. /**
  49243. * Creates the render target textures and post processes used in the glow layer.
  49244. */
  49245. protected _createTextureAndPostProcesses(): void;
  49246. /**
  49247. * Checks for the readiness of the element composing the layer.
  49248. * @param subMesh the mesh to check for
  49249. * @param useInstances specify wether or not to use instances to render the mesh
  49250. * @param emissiveTexture the associated emissive texture used to generate the glow
  49251. * @return true if ready otherwise, false
  49252. */
  49253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49254. /**
  49255. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49256. */
  49257. needStencil(): boolean;
  49258. /**
  49259. * Returns true if the mesh can be rendered, otherwise false.
  49260. * @param mesh The mesh to render
  49261. * @param material The material used on the mesh
  49262. * @returns true if it can be rendered otherwise false
  49263. */
  49264. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49265. /**
  49266. * Implementation specific of rendering the generating effect on the main canvas.
  49267. * @param effect The effect used to render through
  49268. */
  49269. protected _internalRender(effect: Effect): void;
  49270. /**
  49271. * Sets the required values for both the emissive texture and and the main color.
  49272. */
  49273. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49274. /**
  49275. * Returns true if the mesh should render, otherwise false.
  49276. * @param mesh The mesh to render
  49277. * @returns true if it should render otherwise false
  49278. */
  49279. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49280. /**
  49281. * Adds specific effects defines.
  49282. * @param defines The defines to add specifics to.
  49283. */
  49284. protected _addCustomEffectDefines(defines: string[]): void;
  49285. /**
  49286. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49287. * @param mesh The mesh to exclude from the glow layer
  49288. */
  49289. addExcludedMesh(mesh: Mesh): void;
  49290. /**
  49291. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49292. * @param mesh The mesh to remove
  49293. */
  49294. removeExcludedMesh(mesh: Mesh): void;
  49295. /**
  49296. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49297. * @param mesh The mesh to include in the glow layer
  49298. */
  49299. addIncludedOnlyMesh(mesh: Mesh): void;
  49300. /**
  49301. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49302. * @param mesh The mesh to remove
  49303. */
  49304. removeIncludedOnlyMesh(mesh: Mesh): void;
  49305. /**
  49306. * Determine if a given mesh will be used in the glow layer
  49307. * @param mesh The mesh to test
  49308. * @returns true if the mesh will be highlighted by the current glow layer
  49309. */
  49310. hasMesh(mesh: AbstractMesh): boolean;
  49311. /**
  49312. * Free any resources and references associated to a mesh.
  49313. * Internal use
  49314. * @param mesh The mesh to free.
  49315. * @hidden
  49316. */
  49317. _disposeMesh(mesh: Mesh): void;
  49318. /**
  49319. * Gets the class name of the effect layer
  49320. * @returns the string with the class name of the effect layer
  49321. */
  49322. getClassName(): string;
  49323. /**
  49324. * Serializes this glow layer
  49325. * @returns a serialized glow layer object
  49326. */
  49327. serialize(): any;
  49328. /**
  49329. * Creates a Glow Layer from parsed glow layer data
  49330. * @param parsedGlowLayer defines glow layer data
  49331. * @param scene defines the current scene
  49332. * @param rootUrl defines the root URL containing the glow layer information
  49333. * @returns a parsed Glow Layer
  49334. */
  49335. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49336. }
  49337. }
  49338. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49339. /** @hidden */
  49340. export var glowBlurPostProcessPixelShader: {
  49341. name: string;
  49342. shader: string;
  49343. };
  49344. }
  49345. declare module "babylonjs/Layers/highlightLayer" {
  49346. import { Observable } from "babylonjs/Misc/observable";
  49347. import { Nullable } from "babylonjs/types";
  49348. import { Camera } from "babylonjs/Cameras/camera";
  49349. import { Scene } from "babylonjs/scene";
  49350. import { Color3, Color4 } from "babylonjs/Maths/math";
  49351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49353. import { Mesh } from "babylonjs/Meshes/mesh";
  49354. import { Effect } from "babylonjs/Materials/effect";
  49355. import { Material } from "babylonjs/Materials/material";
  49356. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49357. import "babylonjs/Shaders/glowMapMerge.fragment";
  49358. import "babylonjs/Shaders/glowMapMerge.vertex";
  49359. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49360. module "babylonjs/abstractScene" {
  49361. interface AbstractScene {
  49362. /**
  49363. * Return a the first highlight layer of the scene with a given name.
  49364. * @param name The name of the highlight layer to look for.
  49365. * @return The highlight layer if found otherwise null.
  49366. */
  49367. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49368. }
  49369. }
  49370. /**
  49371. * Highlight layer options. This helps customizing the behaviour
  49372. * of the highlight layer.
  49373. */
  49374. export interface IHighlightLayerOptions {
  49375. /**
  49376. * Multiplication factor apply to the canvas size to compute the render target size
  49377. * used to generated the glowing objects (the smaller the faster).
  49378. */
  49379. mainTextureRatio: number;
  49380. /**
  49381. * Enforces a fixed size texture to ensure resize independant blur.
  49382. */
  49383. mainTextureFixedSize?: number;
  49384. /**
  49385. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49386. * of the picture to blur (the smaller the faster).
  49387. */
  49388. blurTextureSizeRatio: number;
  49389. /**
  49390. * How big in texel of the blur texture is the vertical blur.
  49391. */
  49392. blurVerticalSize: number;
  49393. /**
  49394. * How big in texel of the blur texture is the horizontal blur.
  49395. */
  49396. blurHorizontalSize: number;
  49397. /**
  49398. * Alpha blending mode used to apply the blur. Default is combine.
  49399. */
  49400. alphaBlendingMode: number;
  49401. /**
  49402. * The camera attached to the layer.
  49403. */
  49404. camera: Nullable<Camera>;
  49405. /**
  49406. * Should we display highlight as a solid stroke?
  49407. */
  49408. isStroke?: boolean;
  49409. /**
  49410. * The rendering group to draw the layer in.
  49411. */
  49412. renderingGroupId: number;
  49413. }
  49414. /**
  49415. * The highlight layer Helps adding a glow effect around a mesh.
  49416. *
  49417. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49418. * glowy meshes to your scene.
  49419. *
  49420. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49421. */
  49422. export class HighlightLayer extends EffectLayer {
  49423. name: string;
  49424. /**
  49425. * Effect Name of the highlight layer.
  49426. */
  49427. static readonly EffectName: string;
  49428. /**
  49429. * The neutral color used during the preparation of the glow effect.
  49430. * This is black by default as the blend operation is a blend operation.
  49431. */
  49432. static NeutralColor: Color4;
  49433. /**
  49434. * Stencil value used for glowing meshes.
  49435. */
  49436. static GlowingMeshStencilReference: number;
  49437. /**
  49438. * Stencil value used for the other meshes in the scene.
  49439. */
  49440. static NormalMeshStencilReference: number;
  49441. /**
  49442. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49443. */
  49444. innerGlow: boolean;
  49445. /**
  49446. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49447. */
  49448. outerGlow: boolean;
  49449. /**
  49450. * Specifies the horizontal size of the blur.
  49451. */
  49452. /**
  49453. * Gets the horizontal size of the blur.
  49454. */
  49455. blurHorizontalSize: number;
  49456. /**
  49457. * Specifies the vertical size of the blur.
  49458. */
  49459. /**
  49460. * Gets the vertical size of the blur.
  49461. */
  49462. blurVerticalSize: number;
  49463. /**
  49464. * An event triggered when the highlight layer is being blurred.
  49465. */
  49466. onBeforeBlurObservable: Observable<HighlightLayer>;
  49467. /**
  49468. * An event triggered when the highlight layer has been blurred.
  49469. */
  49470. onAfterBlurObservable: Observable<HighlightLayer>;
  49471. private _instanceGlowingMeshStencilReference;
  49472. private _options;
  49473. private _downSamplePostprocess;
  49474. private _horizontalBlurPostprocess;
  49475. private _verticalBlurPostprocess;
  49476. private _blurTexture;
  49477. private _meshes;
  49478. private _excludedMeshes;
  49479. /**
  49480. * Instantiates a new highlight Layer and references it to the scene..
  49481. * @param name The name of the layer
  49482. * @param scene The scene to use the layer in
  49483. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49484. */
  49485. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49486. /**
  49487. * Get the effect name of the layer.
  49488. * @return The effect name
  49489. */
  49490. getEffectName(): string;
  49491. /**
  49492. * Create the merge effect. This is the shader use to blit the information back
  49493. * to the main canvas at the end of the scene rendering.
  49494. */
  49495. protected _createMergeEffect(): Effect;
  49496. /**
  49497. * Creates the render target textures and post processes used in the highlight layer.
  49498. */
  49499. protected _createTextureAndPostProcesses(): void;
  49500. /**
  49501. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49502. */
  49503. needStencil(): boolean;
  49504. /**
  49505. * Checks for the readiness of the element composing the layer.
  49506. * @param subMesh the mesh to check for
  49507. * @param useInstances specify wether or not to use instances to render the mesh
  49508. * @param emissiveTexture the associated emissive texture used to generate the glow
  49509. * @return true if ready otherwise, false
  49510. */
  49511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49512. /**
  49513. * Implementation specific of rendering the generating effect on the main canvas.
  49514. * @param effect The effect used to render through
  49515. */
  49516. protected _internalRender(effect: Effect): void;
  49517. /**
  49518. * Returns true if the layer contains information to display, otherwise false.
  49519. */
  49520. shouldRender(): boolean;
  49521. /**
  49522. * Returns true if the mesh should render, otherwise false.
  49523. * @param mesh The mesh to render
  49524. * @returns true if it should render otherwise false
  49525. */
  49526. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49527. /**
  49528. * Sets the required values for both the emissive texture and and the main color.
  49529. */
  49530. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49531. /**
  49532. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49533. * @param mesh The mesh to exclude from the highlight layer
  49534. */
  49535. addExcludedMesh(mesh: Mesh): void;
  49536. /**
  49537. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49538. * @param mesh The mesh to highlight
  49539. */
  49540. removeExcludedMesh(mesh: Mesh): void;
  49541. /**
  49542. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49543. * @param mesh mesh to test
  49544. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49545. */
  49546. hasMesh(mesh: AbstractMesh): boolean;
  49547. /**
  49548. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49549. * @param mesh The mesh to highlight
  49550. * @param color The color of the highlight
  49551. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49552. */
  49553. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49554. /**
  49555. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49556. * @param mesh The mesh to highlight
  49557. */
  49558. removeMesh(mesh: Mesh): void;
  49559. /**
  49560. * Force the stencil to the normal expected value for none glowing parts
  49561. */
  49562. private _defaultStencilReference;
  49563. /**
  49564. * Free any resources and references associated to a mesh.
  49565. * Internal use
  49566. * @param mesh The mesh to free.
  49567. * @hidden
  49568. */
  49569. _disposeMesh(mesh: Mesh): void;
  49570. /**
  49571. * Dispose the highlight layer and free resources.
  49572. */
  49573. dispose(): void;
  49574. /**
  49575. * Gets the class name of the effect layer
  49576. * @returns the string with the class name of the effect layer
  49577. */
  49578. getClassName(): string;
  49579. /**
  49580. * Serializes this Highlight layer
  49581. * @returns a serialized Highlight layer object
  49582. */
  49583. serialize(): any;
  49584. /**
  49585. * Creates a Highlight layer from parsed Highlight layer data
  49586. * @param parsedHightlightLayer defines the Highlight layer data
  49587. * @param scene defines the current scene
  49588. * @param rootUrl defines the root URL containing the Highlight layer information
  49589. * @returns a parsed Highlight layer
  49590. */
  49591. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49592. }
  49593. }
  49594. declare module "babylonjs/Layers/index" {
  49595. export * from "babylonjs/Layers/effectLayer";
  49596. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49597. export * from "babylonjs/Layers/glowLayer";
  49598. export * from "babylonjs/Layers/highlightLayer";
  49599. export * from "babylonjs/Layers/layer";
  49600. export * from "babylonjs/Layers/layerSceneComponent";
  49601. }
  49602. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49603. /** @hidden */
  49604. export var lensFlarePixelShader: {
  49605. name: string;
  49606. shader: string;
  49607. };
  49608. }
  49609. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49610. /** @hidden */
  49611. export var lensFlareVertexShader: {
  49612. name: string;
  49613. shader: string;
  49614. };
  49615. }
  49616. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49617. import { Scene } from "babylonjs/scene";
  49618. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49620. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49621. import "babylonjs/Shaders/lensFlare.fragment";
  49622. import "babylonjs/Shaders/lensFlare.vertex";
  49623. /**
  49624. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49625. * It is usually composed of several `lensFlare`.
  49626. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49627. */
  49628. export class LensFlareSystem {
  49629. /**
  49630. * Define the name of the lens flare system
  49631. */
  49632. name: string;
  49633. /**
  49634. * List of lens flares used in this system.
  49635. */
  49636. lensFlares: LensFlare[];
  49637. /**
  49638. * Define a limit from the border the lens flare can be visible.
  49639. */
  49640. borderLimit: number;
  49641. /**
  49642. * Define a viewport border we do not want to see the lens flare in.
  49643. */
  49644. viewportBorder: number;
  49645. /**
  49646. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49647. */
  49648. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49649. /**
  49650. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49651. */
  49652. layerMask: number;
  49653. /**
  49654. * Define the id of the lens flare system in the scene.
  49655. * (equal to name by default)
  49656. */
  49657. id: string;
  49658. private _scene;
  49659. private _emitter;
  49660. private _vertexBuffers;
  49661. private _indexBuffer;
  49662. private _effect;
  49663. private _positionX;
  49664. private _positionY;
  49665. private _isEnabled;
  49666. /** @hidden */
  49667. static _SceneComponentInitialization: (scene: Scene) => void;
  49668. /**
  49669. * Instantiates a lens flare system.
  49670. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49671. * It is usually composed of several `lensFlare`.
  49672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49673. * @param name Define the name of the lens flare system in the scene
  49674. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49675. * @param scene Define the scene the lens flare system belongs to
  49676. */
  49677. constructor(
  49678. /**
  49679. * Define the name of the lens flare system
  49680. */
  49681. name: string, emitter: any, scene: Scene);
  49682. /**
  49683. * Define if the lens flare system is enabled.
  49684. */
  49685. isEnabled: boolean;
  49686. /**
  49687. * Get the scene the effects belongs to.
  49688. * @returns the scene holding the lens flare system
  49689. */
  49690. getScene(): Scene;
  49691. /**
  49692. * Get the emitter of the lens flare system.
  49693. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49694. * @returns the emitter of the lens flare system
  49695. */
  49696. getEmitter(): any;
  49697. /**
  49698. * Set the emitter of the lens flare system.
  49699. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49700. * @param newEmitter Define the new emitter of the system
  49701. */
  49702. setEmitter(newEmitter: any): void;
  49703. /**
  49704. * Get the lens flare system emitter position.
  49705. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49706. * @returns the position
  49707. */
  49708. getEmitterPosition(): Vector3;
  49709. /**
  49710. * @hidden
  49711. */
  49712. computeEffectivePosition(globalViewport: Viewport): boolean;
  49713. /** @hidden */
  49714. _isVisible(): boolean;
  49715. /**
  49716. * @hidden
  49717. */
  49718. render(): boolean;
  49719. /**
  49720. * Dispose and release the lens flare with its associated resources.
  49721. */
  49722. dispose(): void;
  49723. /**
  49724. * Parse a lens flare system from a JSON repressentation
  49725. * @param parsedLensFlareSystem Define the JSON to parse
  49726. * @param scene Define the scene the parsed system should be instantiated in
  49727. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49728. * @returns the parsed system
  49729. */
  49730. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49731. /**
  49732. * Serialize the current Lens Flare System into a JSON representation.
  49733. * @returns the serialized JSON
  49734. */
  49735. serialize(): any;
  49736. }
  49737. }
  49738. declare module "babylonjs/LensFlares/lensFlare" {
  49739. import { Nullable } from "babylonjs/types";
  49740. import { Color3 } from "babylonjs/Maths/math";
  49741. import { Texture } from "babylonjs/Materials/Textures/texture";
  49742. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49743. /**
  49744. * This represents one of the lens effect in a `lensFlareSystem`.
  49745. * It controls one of the indiviual texture used in the effect.
  49746. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49747. */
  49748. export class LensFlare {
  49749. /**
  49750. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49751. */
  49752. size: number;
  49753. /**
  49754. * 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.
  49755. */
  49756. position: number;
  49757. /**
  49758. * Define the lens color.
  49759. */
  49760. color: Color3;
  49761. /**
  49762. * Define the lens texture.
  49763. */
  49764. texture: Nullable<Texture>;
  49765. /**
  49766. * Define the alpha mode to render this particular lens.
  49767. */
  49768. alphaMode: number;
  49769. private _system;
  49770. /**
  49771. * Creates a new Lens Flare.
  49772. * This represents one of the lens effect in a `lensFlareSystem`.
  49773. * It controls one of the indiviual texture used in the effect.
  49774. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49775. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49776. * @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.
  49777. * @param color Define the lens color
  49778. * @param imgUrl Define the lens texture url
  49779. * @param system Define the `lensFlareSystem` this flare is part of
  49780. * @returns The newly created Lens Flare
  49781. */
  49782. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49783. /**
  49784. * Instantiates a new Lens Flare.
  49785. * This represents one of the lens effect in a `lensFlareSystem`.
  49786. * It controls one of the indiviual texture used in the effect.
  49787. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49788. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49789. * @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.
  49790. * @param color Define the lens color
  49791. * @param imgUrl Define the lens texture url
  49792. * @param system Define the `lensFlareSystem` this flare is part of
  49793. */
  49794. constructor(
  49795. /**
  49796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49797. */
  49798. size: number,
  49799. /**
  49800. * 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.
  49801. */
  49802. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49803. /**
  49804. * Dispose and release the lens flare with its associated resources.
  49805. */
  49806. dispose(): void;
  49807. }
  49808. }
  49809. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49810. import { Nullable } from "babylonjs/types";
  49811. import { Scene } from "babylonjs/scene";
  49812. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49813. import { AbstractScene } from "babylonjs/abstractScene";
  49814. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49815. module "babylonjs/abstractScene" {
  49816. interface AbstractScene {
  49817. /**
  49818. * The list of lens flare system added to the scene
  49819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49820. */
  49821. lensFlareSystems: Array<LensFlareSystem>;
  49822. /**
  49823. * Removes the given lens flare system from this scene.
  49824. * @param toRemove The lens flare system to remove
  49825. * @returns The index of the removed lens flare system
  49826. */
  49827. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49828. /**
  49829. * Adds the given lens flare system to this scene
  49830. * @param newLensFlareSystem The lens flare system to add
  49831. */
  49832. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49833. /**
  49834. * Gets a lens flare system using its name
  49835. * @param name defines the name to look for
  49836. * @returns the lens flare system or null if not found
  49837. */
  49838. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49839. /**
  49840. * Gets a lens flare system using its id
  49841. * @param id defines the id to look for
  49842. * @returns the lens flare system or null if not found
  49843. */
  49844. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49845. }
  49846. }
  49847. /**
  49848. * Defines the lens flare scene component responsible to manage any lens flares
  49849. * in a given scene.
  49850. */
  49851. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49852. /**
  49853. * The component name helpfull to identify the component in the list of scene components.
  49854. */
  49855. readonly name: string;
  49856. /**
  49857. * The scene the component belongs to.
  49858. */
  49859. scene: Scene;
  49860. /**
  49861. * Creates a new instance of the component for the given scene
  49862. * @param scene Defines the scene to register the component in
  49863. */
  49864. constructor(scene: Scene);
  49865. /**
  49866. * Registers the component in a given scene
  49867. */
  49868. register(): void;
  49869. /**
  49870. * Rebuilds the elements related to this component in case of
  49871. * context lost for instance.
  49872. */
  49873. rebuild(): void;
  49874. /**
  49875. * Adds all the element from the container to the scene
  49876. * @param container the container holding the elements
  49877. */
  49878. addFromContainer(container: AbstractScene): void;
  49879. /**
  49880. * Removes all the elements in the container from the scene
  49881. * @param container contains the elements to remove
  49882. * @param dispose if the removed element should be disposed (default: false)
  49883. */
  49884. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49885. /**
  49886. * Serializes the component data to the specified json object
  49887. * @param serializationObject The object to serialize to
  49888. */
  49889. serialize(serializationObject: any): void;
  49890. /**
  49891. * Disposes the component and the associated ressources.
  49892. */
  49893. dispose(): void;
  49894. private _draw;
  49895. }
  49896. }
  49897. declare module "babylonjs/LensFlares/index" {
  49898. export * from "babylonjs/LensFlares/lensFlare";
  49899. export * from "babylonjs/LensFlares/lensFlareSystem";
  49900. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49901. }
  49902. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49903. import { Scene } from "babylonjs/scene";
  49904. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49905. import { AbstractScene } from "babylonjs/abstractScene";
  49906. /**
  49907. * Defines the shadow generator component responsible to manage any shadow generators
  49908. * in a given scene.
  49909. */
  49910. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49911. /**
  49912. * The component name helpfull to identify the component in the list of scene components.
  49913. */
  49914. readonly name: string;
  49915. /**
  49916. * The scene the component belongs to.
  49917. */
  49918. scene: Scene;
  49919. /**
  49920. * Creates a new instance of the component for the given scene
  49921. * @param scene Defines the scene to register the component in
  49922. */
  49923. constructor(scene: Scene);
  49924. /**
  49925. * Registers the component in a given scene
  49926. */
  49927. register(): void;
  49928. /**
  49929. * Rebuilds the elements related to this component in case of
  49930. * context lost for instance.
  49931. */
  49932. rebuild(): void;
  49933. /**
  49934. * Serializes the component data to the specified json object
  49935. * @param serializationObject The object to serialize to
  49936. */
  49937. serialize(serializationObject: any): void;
  49938. /**
  49939. * Adds all the element from the container to the scene
  49940. * @param container the container holding the elements
  49941. */
  49942. addFromContainer(container: AbstractScene): void;
  49943. /**
  49944. * Removes all the elements in the container from the scene
  49945. * @param container contains the elements to remove
  49946. * @param dispose if the removed element should be disposed (default: false)
  49947. */
  49948. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49949. /**
  49950. * Rebuilds the elements related to this component in case of
  49951. * context lost for instance.
  49952. */
  49953. dispose(): void;
  49954. private _gatherRenderTargets;
  49955. }
  49956. }
  49957. declare module "babylonjs/Lights/Shadows/index" {
  49958. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49959. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49960. }
  49961. declare module "babylonjs/Lights/pointLight" {
  49962. import { Scene } from "babylonjs/scene";
  49963. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49965. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49966. import { Effect } from "babylonjs/Materials/effect";
  49967. /**
  49968. * A point light is a light defined by an unique point in world space.
  49969. * The light is emitted in every direction from this point.
  49970. * A good example of a point light is a standard light bulb.
  49971. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49972. */
  49973. export class PointLight extends ShadowLight {
  49974. private _shadowAngle;
  49975. /**
  49976. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49977. * This specifies what angle the shadow will use to be created.
  49978. *
  49979. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49980. */
  49981. /**
  49982. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49983. * This specifies what angle the shadow will use to be created.
  49984. *
  49985. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49986. */
  49987. shadowAngle: number;
  49988. /**
  49989. * Gets the direction if it has been set.
  49990. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49991. */
  49992. /**
  49993. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49994. */
  49995. direction: Vector3;
  49996. /**
  49997. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49998. * A PointLight emits the light in every direction.
  49999. * It can cast shadows.
  50000. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50001. * ```javascript
  50002. * var pointLight = new PointLight("pl", camera.position, scene);
  50003. * ```
  50004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50005. * @param name The light friendly name
  50006. * @param position The position of the point light in the scene
  50007. * @param scene The scene the lights belongs to
  50008. */
  50009. constructor(name: string, position: Vector3, scene: Scene);
  50010. /**
  50011. * Returns the string "PointLight"
  50012. * @returns the class name
  50013. */
  50014. getClassName(): string;
  50015. /**
  50016. * Returns the integer 0.
  50017. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50018. */
  50019. getTypeID(): number;
  50020. /**
  50021. * Specifies wether or not the shadowmap should be a cube texture.
  50022. * @returns true if the shadowmap needs to be a cube texture.
  50023. */
  50024. needCube(): boolean;
  50025. /**
  50026. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50027. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50028. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50029. */
  50030. getShadowDirection(faceIndex?: number): Vector3;
  50031. /**
  50032. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50033. * - fov = PI / 2
  50034. * - aspect ratio : 1.0
  50035. * - z-near and far equal to the active camera minZ and maxZ.
  50036. * Returns the PointLight.
  50037. */
  50038. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50039. protected _buildUniformLayout(): void;
  50040. /**
  50041. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50042. * @param effect The effect to update
  50043. * @param lightIndex The index of the light in the effect to update
  50044. * @returns The point light
  50045. */
  50046. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50047. /**
  50048. * Prepares the list of defines specific to the light type.
  50049. * @param defines the list of defines
  50050. * @param lightIndex defines the index of the light for the effect
  50051. */
  50052. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50053. }
  50054. }
  50055. declare module "babylonjs/Lights/index" {
  50056. export * from "babylonjs/Lights/light";
  50057. export * from "babylonjs/Lights/shadowLight";
  50058. export * from "babylonjs/Lights/Shadows/index";
  50059. export * from "babylonjs/Lights/directionalLight";
  50060. export * from "babylonjs/Lights/hemisphericLight";
  50061. export * from "babylonjs/Lights/pointLight";
  50062. export * from "babylonjs/Lights/spotLight";
  50063. }
  50064. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50065. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50066. /**
  50067. * Header information of HDR texture files.
  50068. */
  50069. export interface HDRInfo {
  50070. /**
  50071. * The height of the texture in pixels.
  50072. */
  50073. height: number;
  50074. /**
  50075. * The width of the texture in pixels.
  50076. */
  50077. width: number;
  50078. /**
  50079. * The index of the beginning of the data in the binary file.
  50080. */
  50081. dataPosition: number;
  50082. }
  50083. /**
  50084. * This groups tools to convert HDR texture to native colors array.
  50085. */
  50086. export class HDRTools {
  50087. private static Ldexp;
  50088. private static Rgbe2float;
  50089. private static readStringLine;
  50090. /**
  50091. * Reads header information from an RGBE texture stored in a native array.
  50092. * More information on this format are available here:
  50093. * https://en.wikipedia.org/wiki/RGBE_image_format
  50094. *
  50095. * @param uint8array The binary file stored in native array.
  50096. * @return The header information.
  50097. */
  50098. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50099. /**
  50100. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50101. * This RGBE texture needs to store the information as a panorama.
  50102. *
  50103. * More information on this format are available here:
  50104. * https://en.wikipedia.org/wiki/RGBE_image_format
  50105. *
  50106. * @param buffer The binary file stored in an array buffer.
  50107. * @param size The expected size of the extracted cubemap.
  50108. * @return The Cube Map information.
  50109. */
  50110. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50111. /**
  50112. * Returns the pixels data extracted from an RGBE texture.
  50113. * This pixels will be stored left to right up to down in the R G B order in one array.
  50114. *
  50115. * More information on this format are available here:
  50116. * https://en.wikipedia.org/wiki/RGBE_image_format
  50117. *
  50118. * @param uint8array The binary file stored in an array buffer.
  50119. * @param hdrInfo The header information of the file.
  50120. * @return The pixels data in RGB right to left up to down order.
  50121. */
  50122. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50123. private static RGBE_ReadPixels_RLE;
  50124. }
  50125. }
  50126. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50127. import { Nullable } from "babylonjs/types";
  50128. import { Scene } from "babylonjs/scene";
  50129. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50131. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50132. /**
  50133. * This represents a texture coming from an HDR input.
  50134. *
  50135. * The only supported format is currently panorama picture stored in RGBE format.
  50136. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50137. */
  50138. export class HDRCubeTexture extends BaseTexture {
  50139. private static _facesMapping;
  50140. private _generateHarmonics;
  50141. private _noMipmap;
  50142. private _textureMatrix;
  50143. private _size;
  50144. private _onLoad;
  50145. private _onError;
  50146. /**
  50147. * The texture URL.
  50148. */
  50149. url: string;
  50150. /**
  50151. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50152. */
  50153. coordinatesMode: number;
  50154. protected _isBlocking: boolean;
  50155. /**
  50156. * Sets wether or not the texture is blocking during loading.
  50157. */
  50158. /**
  50159. * Gets wether or not the texture is blocking during loading.
  50160. */
  50161. isBlocking: boolean;
  50162. protected _rotationY: number;
  50163. /**
  50164. * Sets texture matrix rotation angle around Y axis in radians.
  50165. */
  50166. /**
  50167. * Gets texture matrix rotation angle around Y axis radians.
  50168. */
  50169. rotationY: number;
  50170. /**
  50171. * Gets or sets the center of the bounding box associated with the cube texture
  50172. * It must define where the camera used to render the texture was set
  50173. */
  50174. boundingBoxPosition: Vector3;
  50175. private _boundingBoxSize;
  50176. /**
  50177. * Gets or sets the size of the bounding box associated with the cube texture
  50178. * When defined, the cubemap will switch to local mode
  50179. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50180. * @example https://www.babylonjs-playground.com/#RNASML
  50181. */
  50182. boundingBoxSize: Vector3;
  50183. /**
  50184. * Instantiates an HDRTexture from the following parameters.
  50185. *
  50186. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50187. * @param scene The scene the texture will be used in
  50188. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50189. * @param noMipmap Forces to not generate the mipmap if true
  50190. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50191. * @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)
  50192. * @param reserved Reserved flag for internal use.
  50193. */
  50194. 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>);
  50195. /**
  50196. * Get the current class name of the texture useful for serialization or dynamic coding.
  50197. * @returns "HDRCubeTexture"
  50198. */
  50199. getClassName(): string;
  50200. /**
  50201. * Occurs when the file is raw .hdr file.
  50202. */
  50203. private loadTexture;
  50204. clone(): HDRCubeTexture;
  50205. delayLoad(): void;
  50206. /**
  50207. * Get the texture reflection matrix used to rotate/transform the reflection.
  50208. * @returns the reflection matrix
  50209. */
  50210. getReflectionTextureMatrix(): Matrix;
  50211. /**
  50212. * Set the texture reflection matrix used to rotate/transform the reflection.
  50213. * @param value Define the reflection matrix to set
  50214. */
  50215. setReflectionTextureMatrix(value: Matrix): void;
  50216. /**
  50217. * Parses a JSON representation of an HDR Texture in order to create the texture
  50218. * @param parsedTexture Define the JSON representation
  50219. * @param scene Define the scene the texture should be created in
  50220. * @param rootUrl Define the root url in case we need to load relative dependencies
  50221. * @returns the newly created texture after parsing
  50222. */
  50223. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50224. serialize(): any;
  50225. }
  50226. }
  50227. declare module "babylonjs/Physics/physicsEngine" {
  50228. import { Nullable } from "babylonjs/types";
  50229. import { Vector3 } from "babylonjs/Maths/math";
  50230. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50231. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50232. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50233. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50234. /**
  50235. * Class used to control physics engine
  50236. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50237. */
  50238. export class PhysicsEngine implements IPhysicsEngine {
  50239. private _physicsPlugin;
  50240. /**
  50241. * Global value used to control the smallest number supported by the simulation
  50242. */
  50243. static Epsilon: number;
  50244. private _impostors;
  50245. private _joints;
  50246. /**
  50247. * Gets the gravity vector used by the simulation
  50248. */
  50249. gravity: Vector3;
  50250. /**
  50251. * Factory used to create the default physics plugin.
  50252. * @returns The default physics plugin
  50253. */
  50254. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50255. /**
  50256. * Creates a new Physics Engine
  50257. * @param gravity defines the gravity vector used by the simulation
  50258. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50259. */
  50260. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50261. /**
  50262. * Sets the gravity vector used by the simulation
  50263. * @param gravity defines the gravity vector to use
  50264. */
  50265. setGravity(gravity: Vector3): void;
  50266. /**
  50267. * Set the time step of the physics engine.
  50268. * Default is 1/60.
  50269. * To slow it down, enter 1/600 for example.
  50270. * To speed it up, 1/30
  50271. * @param newTimeStep defines the new timestep to apply to this world.
  50272. */
  50273. setTimeStep(newTimeStep?: number): void;
  50274. /**
  50275. * Get the time step of the physics engine.
  50276. * @returns the current time step
  50277. */
  50278. getTimeStep(): number;
  50279. /**
  50280. * Release all resources
  50281. */
  50282. dispose(): void;
  50283. /**
  50284. * Gets the name of the current physics plugin
  50285. * @returns the name of the plugin
  50286. */
  50287. getPhysicsPluginName(): string;
  50288. /**
  50289. * Adding a new impostor for the impostor tracking.
  50290. * This will be done by the impostor itself.
  50291. * @param impostor the impostor to add
  50292. */
  50293. addImpostor(impostor: PhysicsImpostor): void;
  50294. /**
  50295. * Remove an impostor from the engine.
  50296. * This impostor and its mesh will not longer be updated by the physics engine.
  50297. * @param impostor the impostor to remove
  50298. */
  50299. removeImpostor(impostor: PhysicsImpostor): void;
  50300. /**
  50301. * Add a joint to the physics engine
  50302. * @param mainImpostor defines the main impostor to which the joint is added.
  50303. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50304. * @param joint defines the joint that will connect both impostors.
  50305. */
  50306. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50307. /**
  50308. * Removes a joint from the simulation
  50309. * @param mainImpostor defines the impostor used with the joint
  50310. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50311. * @param joint defines the joint to remove
  50312. */
  50313. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50314. /**
  50315. * Called by the scene. No need to call it.
  50316. * @param delta defines the timespam between frames
  50317. */
  50318. _step(delta: number): void;
  50319. /**
  50320. * Gets the current plugin used to run the simulation
  50321. * @returns current plugin
  50322. */
  50323. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50324. /**
  50325. * Gets the list of physic impostors
  50326. * @returns an array of PhysicsImpostor
  50327. */
  50328. getImpostors(): Array<PhysicsImpostor>;
  50329. /**
  50330. * Gets the impostor for a physics enabled object
  50331. * @param object defines the object impersonated by the impostor
  50332. * @returns the PhysicsImpostor or null if not found
  50333. */
  50334. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50335. /**
  50336. * Gets the impostor for a physics body object
  50337. * @param body defines physics body used by the impostor
  50338. * @returns the PhysicsImpostor or null if not found
  50339. */
  50340. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50341. /**
  50342. * Does a raycast in the physics world
  50343. * @param from when should the ray start?
  50344. * @param to when should the ray end?
  50345. * @returns PhysicsRaycastResult
  50346. */
  50347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50348. }
  50349. }
  50350. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50351. import { Nullable } from "babylonjs/types";
  50352. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50354. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50355. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50356. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50357. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50358. /** @hidden */
  50359. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50360. private _useDeltaForWorldStep;
  50361. world: any;
  50362. name: string;
  50363. private _physicsMaterials;
  50364. private _fixedTimeStep;
  50365. private _cannonRaycastResult;
  50366. private _raycastResult;
  50367. private _removeAfterStep;
  50368. BJSCANNON: any;
  50369. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50370. setGravity(gravity: Vector3): void;
  50371. setTimeStep(timeStep: number): void;
  50372. getTimeStep(): number;
  50373. executeStep(delta: number): void;
  50374. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50375. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50376. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50377. private _processChildMeshes;
  50378. removePhysicsBody(impostor: PhysicsImpostor): void;
  50379. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50380. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50381. private _addMaterial;
  50382. private _checkWithEpsilon;
  50383. private _createShape;
  50384. private _createHeightmap;
  50385. private _minus90X;
  50386. private _plus90X;
  50387. private _tmpPosition;
  50388. private _tmpDeltaPosition;
  50389. private _tmpUnityRotation;
  50390. private _updatePhysicsBodyTransformation;
  50391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50392. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50393. isSupported(): boolean;
  50394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50396. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50397. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50398. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50399. getBodyMass(impostor: PhysicsImpostor): number;
  50400. getBodyFriction(impostor: PhysicsImpostor): number;
  50401. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50402. getBodyRestitution(impostor: PhysicsImpostor): number;
  50403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50404. sleepBody(impostor: PhysicsImpostor): void;
  50405. wakeUpBody(impostor: PhysicsImpostor): void;
  50406. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50407. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50408. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50409. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50410. getRadius(impostor: PhysicsImpostor): number;
  50411. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50412. dispose(): void;
  50413. private _extendNamespace;
  50414. /**
  50415. * Does a raycast in the physics world
  50416. * @param from when should the ray start?
  50417. * @param to when should the ray end?
  50418. * @returns PhysicsRaycastResult
  50419. */
  50420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50421. }
  50422. }
  50423. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50424. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50425. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50426. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50428. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50429. import { Nullable } from "babylonjs/types";
  50430. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50431. /** @hidden */
  50432. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50433. world: any;
  50434. name: string;
  50435. BJSOIMO: any;
  50436. private _raycastResult;
  50437. constructor(iterations?: number, oimoInjection?: any);
  50438. setGravity(gravity: Vector3): void;
  50439. setTimeStep(timeStep: number): void;
  50440. getTimeStep(): number;
  50441. private _tmpImpostorsArray;
  50442. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50443. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50444. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50445. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50446. private _tmpPositionVector;
  50447. removePhysicsBody(impostor: PhysicsImpostor): void;
  50448. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50449. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50450. isSupported(): boolean;
  50451. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50452. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50453. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50455. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50456. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50457. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50458. getBodyMass(impostor: PhysicsImpostor): number;
  50459. getBodyFriction(impostor: PhysicsImpostor): number;
  50460. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50461. getBodyRestitution(impostor: PhysicsImpostor): number;
  50462. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50463. sleepBody(impostor: PhysicsImpostor): void;
  50464. wakeUpBody(impostor: PhysicsImpostor): void;
  50465. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50466. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50468. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50469. getRadius(impostor: PhysicsImpostor): number;
  50470. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50471. dispose(): void;
  50472. /**
  50473. * Does a raycast in the physics world
  50474. * @param from when should the ray start?
  50475. * @param to when should the ray end?
  50476. * @returns PhysicsRaycastResult
  50477. */
  50478. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50479. }
  50480. }
  50481. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50482. import { Nullable } from "babylonjs/types";
  50483. import { Scene } from "babylonjs/scene";
  50484. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50485. import { Mesh } from "babylonjs/Meshes/mesh";
  50486. /**
  50487. * Class containing static functions to help procedurally build meshes
  50488. */
  50489. export class RibbonBuilder {
  50490. /**
  50491. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50492. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50493. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50494. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50495. * * 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
  50496. * * 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
  50497. * * 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
  50498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50501. * * 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
  50502. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50503. * * 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
  50504. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50506. * @param name defines the name of the mesh
  50507. * @param options defines the options used to create the mesh
  50508. * @param scene defines the hosting scene
  50509. * @returns the ribbon mesh
  50510. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50512. */
  50513. static CreateRibbon(name: string, options: {
  50514. pathArray: Vector3[][];
  50515. closeArray?: boolean;
  50516. closePath?: boolean;
  50517. offset?: number;
  50518. updatable?: boolean;
  50519. sideOrientation?: number;
  50520. frontUVs?: Vector4;
  50521. backUVs?: Vector4;
  50522. instance?: Mesh;
  50523. invertUV?: boolean;
  50524. uvs?: Vector2[];
  50525. colors?: Color4[];
  50526. }, scene?: Nullable<Scene>): Mesh;
  50527. }
  50528. }
  50529. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50530. import { Nullable } from "babylonjs/types";
  50531. import { Scene } from "babylonjs/scene";
  50532. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50533. import { Mesh } from "babylonjs/Meshes/mesh";
  50534. /**
  50535. * Class containing static functions to help procedurally build meshes
  50536. */
  50537. export class ShapeBuilder {
  50538. /**
  50539. * 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.
  50540. * * 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.
  50541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50542. * * 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.
  50543. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50544. * * 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
  50545. * * 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
  50546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50551. * @param name defines the name of the mesh
  50552. * @param options defines the options used to create the mesh
  50553. * @param scene defines the hosting scene
  50554. * @returns the extruded shape mesh
  50555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50557. */
  50558. static ExtrudeShape(name: string, options: {
  50559. shape: Vector3[];
  50560. path: Vector3[];
  50561. scale?: number;
  50562. rotation?: number;
  50563. cap?: number;
  50564. updatable?: boolean;
  50565. sideOrientation?: number;
  50566. frontUVs?: Vector4;
  50567. backUVs?: Vector4;
  50568. instance?: Mesh;
  50569. invertUV?: boolean;
  50570. }, scene?: Nullable<Scene>): Mesh;
  50571. /**
  50572. * Creates an custom extruded shape mesh.
  50573. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50574. * * 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.
  50575. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50576. * * 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
  50577. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50578. * * 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
  50579. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50580. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50581. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50582. * * 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
  50583. * * 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
  50584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50589. * @param name defines the name of the mesh
  50590. * @param options defines the options used to create the mesh
  50591. * @param scene defines the hosting scene
  50592. * @returns the custom extruded shape mesh
  50593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50596. */
  50597. static ExtrudeShapeCustom(name: string, options: {
  50598. shape: Vector3[];
  50599. path: Vector3[];
  50600. scaleFunction?: any;
  50601. rotationFunction?: any;
  50602. ribbonCloseArray?: boolean;
  50603. ribbonClosePath?: boolean;
  50604. cap?: number;
  50605. updatable?: boolean;
  50606. sideOrientation?: number;
  50607. frontUVs?: Vector4;
  50608. backUVs?: Vector4;
  50609. instance?: Mesh;
  50610. invertUV?: boolean;
  50611. }, scene?: Nullable<Scene>): Mesh;
  50612. private static _ExtrudeShapeGeneric;
  50613. }
  50614. }
  50615. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50616. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50617. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50618. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50619. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50620. import { Nullable } from "babylonjs/types";
  50621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50622. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50623. /**
  50624. * AmmoJS Physics plugin
  50625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50626. * @see https://github.com/kripken/ammo.js/
  50627. */
  50628. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50629. private _useDeltaForWorldStep;
  50630. /**
  50631. * Reference to the Ammo library
  50632. */
  50633. bjsAMMO: any;
  50634. /**
  50635. * Created ammoJS world which physics bodies are added to
  50636. */
  50637. world: any;
  50638. /**
  50639. * Name of the plugin
  50640. */
  50641. name: string;
  50642. private _timeStep;
  50643. private _fixedTimeStep;
  50644. private _maxSteps;
  50645. private _tmpQuaternion;
  50646. private _tmpAmmoTransform;
  50647. private _tmpAmmoQuaternion;
  50648. private _tmpAmmoConcreteContactResultCallback;
  50649. private _collisionConfiguration;
  50650. private _dispatcher;
  50651. private _overlappingPairCache;
  50652. private _solver;
  50653. private _softBodySolver;
  50654. private _tmpAmmoVectorA;
  50655. private _tmpAmmoVectorB;
  50656. private _tmpAmmoVectorC;
  50657. private _tmpAmmoVectorD;
  50658. private _tmpContactCallbackResult;
  50659. private _tmpAmmoVectorRCA;
  50660. private _tmpAmmoVectorRCB;
  50661. private _raycastResult;
  50662. private static readonly DISABLE_COLLISION_FLAG;
  50663. private static readonly KINEMATIC_FLAG;
  50664. private static readonly DISABLE_DEACTIVATION_FLAG;
  50665. /**
  50666. * Initializes the ammoJS plugin
  50667. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50668. * @param ammoInjection can be used to inject your own ammo reference
  50669. */
  50670. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50671. /**
  50672. * Sets the gravity of the physics world (m/(s^2))
  50673. * @param gravity Gravity to set
  50674. */
  50675. setGravity(gravity: Vector3): void;
  50676. /**
  50677. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50678. * @param timeStep timestep to use in seconds
  50679. */
  50680. setTimeStep(timeStep: number): void;
  50681. /**
  50682. * 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)
  50683. * @param fixedTimeStep fixedTimeStep to use in seconds
  50684. */
  50685. setFixedTimeStep(fixedTimeStep: number): void;
  50686. /**
  50687. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50688. * @param maxSteps the maximum number of steps by the physics engine per frame
  50689. */
  50690. setMaxSteps(maxSteps: number): void;
  50691. /**
  50692. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50693. * @returns the current timestep in seconds
  50694. */
  50695. getTimeStep(): number;
  50696. private _isImpostorInContact;
  50697. private _isImpostorPairInContact;
  50698. private _stepSimulation;
  50699. /**
  50700. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50701. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50702. * After the step the babylon meshes are set to the position of the physics imposters
  50703. * @param delta amount of time to step forward
  50704. * @param impostors array of imposters to update before/after the step
  50705. */
  50706. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50707. /**
  50708. * Update babylon mesh to match physics world object
  50709. * @param impostor imposter to match
  50710. */
  50711. private _afterSoftStep;
  50712. /**
  50713. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50714. * @param impostor imposter to match
  50715. */
  50716. private _ropeStep;
  50717. /**
  50718. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50719. * @param impostor imposter to match
  50720. */
  50721. private _softbodyOrClothStep;
  50722. private _tmpVector;
  50723. private _tmpMatrix;
  50724. /**
  50725. * Applies an impulse on the imposter
  50726. * @param impostor imposter to apply impulse to
  50727. * @param force amount of force to be applied to the imposter
  50728. * @param contactPoint the location to apply the impulse on the imposter
  50729. */
  50730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50731. /**
  50732. * Applies a force on the imposter
  50733. * @param impostor imposter to apply force
  50734. * @param force amount of force to be applied to the imposter
  50735. * @param contactPoint the location to apply the force on the imposter
  50736. */
  50737. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50738. /**
  50739. * Creates a physics body using the plugin
  50740. * @param impostor the imposter to create the physics body on
  50741. */
  50742. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50743. /**
  50744. * Removes the physics body from the imposter and disposes of the body's memory
  50745. * @param impostor imposter to remove the physics body from
  50746. */
  50747. removePhysicsBody(impostor: PhysicsImpostor): void;
  50748. /**
  50749. * Generates a joint
  50750. * @param impostorJoint the imposter joint to create the joint with
  50751. */
  50752. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50753. /**
  50754. * Removes a joint
  50755. * @param impostorJoint the imposter joint to remove the joint from
  50756. */
  50757. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50758. private _addMeshVerts;
  50759. /**
  50760. * Initialise the soft body vertices to match its object's (mesh) vertices
  50761. * Softbody vertices (nodes) are in world space and to match this
  50762. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50763. * @param impostor to create the softbody for
  50764. */
  50765. private _softVertexData;
  50766. /**
  50767. * Create an impostor's soft body
  50768. * @param impostor to create the softbody for
  50769. */
  50770. private _createSoftbody;
  50771. /**
  50772. * Create cloth for an impostor
  50773. * @param impostor to create the softbody for
  50774. */
  50775. private _createCloth;
  50776. /**
  50777. * Create rope for an impostor
  50778. * @param impostor to create the softbody for
  50779. */
  50780. private _createRope;
  50781. private _addHullVerts;
  50782. private _createShape;
  50783. /**
  50784. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50785. * @param impostor imposter containing the physics body and babylon object
  50786. */
  50787. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50788. /**
  50789. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50790. * @param impostor imposter containing the physics body and babylon object
  50791. * @param newPosition new position
  50792. * @param newRotation new rotation
  50793. */
  50794. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50795. /**
  50796. * If this plugin is supported
  50797. * @returns true if its supported
  50798. */
  50799. isSupported(): boolean;
  50800. /**
  50801. * Sets the linear velocity of the physics body
  50802. * @param impostor imposter to set the velocity on
  50803. * @param velocity velocity to set
  50804. */
  50805. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50806. /**
  50807. * Sets the angular velocity of the physics body
  50808. * @param impostor imposter to set the velocity on
  50809. * @param velocity velocity to set
  50810. */
  50811. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50812. /**
  50813. * gets the linear velocity
  50814. * @param impostor imposter to get linear velocity from
  50815. * @returns linear velocity
  50816. */
  50817. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50818. /**
  50819. * gets the angular velocity
  50820. * @param impostor imposter to get angular velocity from
  50821. * @returns angular velocity
  50822. */
  50823. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50824. /**
  50825. * Sets the mass of physics body
  50826. * @param impostor imposter to set the mass on
  50827. * @param mass mass to set
  50828. */
  50829. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50830. /**
  50831. * Gets the mass of the physics body
  50832. * @param impostor imposter to get the mass from
  50833. * @returns mass
  50834. */
  50835. getBodyMass(impostor: PhysicsImpostor): number;
  50836. /**
  50837. * Gets friction of the impostor
  50838. * @param impostor impostor to get friction from
  50839. * @returns friction value
  50840. */
  50841. getBodyFriction(impostor: PhysicsImpostor): number;
  50842. /**
  50843. * Sets friction of the impostor
  50844. * @param impostor impostor to set friction on
  50845. * @param friction friction value
  50846. */
  50847. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50848. /**
  50849. * Gets restitution of the impostor
  50850. * @param impostor impostor to get restitution from
  50851. * @returns restitution value
  50852. */
  50853. getBodyRestitution(impostor: PhysicsImpostor): number;
  50854. /**
  50855. * Sets resitution of the impostor
  50856. * @param impostor impostor to set resitution on
  50857. * @param restitution resitution value
  50858. */
  50859. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50860. /**
  50861. * Gets pressure inside the impostor
  50862. * @param impostor impostor to get pressure from
  50863. * @returns pressure value
  50864. */
  50865. getBodyPressure(impostor: PhysicsImpostor): number;
  50866. /**
  50867. * Sets pressure inside a soft body impostor
  50868. * Cloth and rope must remain 0 pressure
  50869. * @param impostor impostor to set pressure on
  50870. * @param pressure pressure value
  50871. */
  50872. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50873. /**
  50874. * Gets stiffness of the impostor
  50875. * @param impostor impostor to get stiffness from
  50876. * @returns pressure value
  50877. */
  50878. getBodyStiffness(impostor: PhysicsImpostor): number;
  50879. /**
  50880. * Sets stiffness of the impostor
  50881. * @param impostor impostor to set stiffness on
  50882. * @param stiffness stiffness value from 0 to 1
  50883. */
  50884. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50885. /**
  50886. * Gets velocityIterations of the impostor
  50887. * @param impostor impostor to get velocity iterations from
  50888. * @returns velocityIterations value
  50889. */
  50890. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50891. /**
  50892. * Sets velocityIterations of the impostor
  50893. * @param impostor impostor to set velocity iterations on
  50894. * @param velocityIterations velocityIterations value
  50895. */
  50896. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50897. /**
  50898. * Gets positionIterations of the impostor
  50899. * @param impostor impostor to get position iterations from
  50900. * @returns positionIterations value
  50901. */
  50902. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50903. /**
  50904. * Sets positionIterations of the impostor
  50905. * @param impostor impostor to set position on
  50906. * @param positionIterations positionIterations value
  50907. */
  50908. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50909. /**
  50910. * Append an anchor to a cloth object
  50911. * @param impostor is the cloth impostor to add anchor to
  50912. * @param otherImpostor is the rigid impostor to anchor to
  50913. * @param width ratio across width from 0 to 1
  50914. * @param height ratio up height from 0 to 1
  50915. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50916. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50917. */
  50918. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50919. /**
  50920. * Append an hook to a rope object
  50921. * @param impostor is the rope impostor to add hook to
  50922. * @param otherImpostor is the rigid impostor to hook to
  50923. * @param length ratio along the rope from 0 to 1
  50924. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50925. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50926. */
  50927. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50928. /**
  50929. * Sleeps the physics body and stops it from being active
  50930. * @param impostor impostor to sleep
  50931. */
  50932. sleepBody(impostor: PhysicsImpostor): void;
  50933. /**
  50934. * Activates the physics body
  50935. * @param impostor impostor to activate
  50936. */
  50937. wakeUpBody(impostor: PhysicsImpostor): void;
  50938. /**
  50939. * Updates the distance parameters of the joint
  50940. * @param joint joint to update
  50941. * @param maxDistance maximum distance of the joint
  50942. * @param minDistance minimum distance of the joint
  50943. */
  50944. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50945. /**
  50946. * Sets a motor on the joint
  50947. * @param joint joint to set motor on
  50948. * @param speed speed of the motor
  50949. * @param maxForce maximum force of the motor
  50950. * @param motorIndex index of the motor
  50951. */
  50952. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50953. /**
  50954. * Sets the motors limit
  50955. * @param joint joint to set limit on
  50956. * @param upperLimit upper limit
  50957. * @param lowerLimit lower limit
  50958. */
  50959. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50960. /**
  50961. * Syncs the position and rotation of a mesh with the impostor
  50962. * @param mesh mesh to sync
  50963. * @param impostor impostor to update the mesh with
  50964. */
  50965. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50966. /**
  50967. * Gets the radius of the impostor
  50968. * @param impostor impostor to get radius from
  50969. * @returns the radius
  50970. */
  50971. getRadius(impostor: PhysicsImpostor): number;
  50972. /**
  50973. * Gets the box size of the impostor
  50974. * @param impostor impostor to get box size from
  50975. * @param result the resulting box size
  50976. */
  50977. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50978. /**
  50979. * Disposes of the impostor
  50980. */
  50981. dispose(): void;
  50982. /**
  50983. * Does a raycast in the physics world
  50984. * @param from when should the ray start?
  50985. * @param to when should the ray end?
  50986. * @returns PhysicsRaycastResult
  50987. */
  50988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50989. }
  50990. }
  50991. declare module "babylonjs/Probes/reflectionProbe" {
  50992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50993. import { Vector3 } from "babylonjs/Maths/math";
  50994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50995. import { Nullable } from "babylonjs/types";
  50996. import { Scene } from "babylonjs/scene";
  50997. module "babylonjs/abstractScene" {
  50998. interface AbstractScene {
  50999. /**
  51000. * The list of reflection probes added to the scene
  51001. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51002. */
  51003. reflectionProbes: Array<ReflectionProbe>;
  51004. /**
  51005. * Removes the given reflection probe from this scene.
  51006. * @param toRemove The reflection probe to remove
  51007. * @returns The index of the removed reflection probe
  51008. */
  51009. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51010. /**
  51011. * Adds the given reflection probe to this scene.
  51012. * @param newReflectionProbe The reflection probe to add
  51013. */
  51014. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51015. }
  51016. }
  51017. /**
  51018. * Class used to generate realtime reflection / refraction cube textures
  51019. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51020. */
  51021. export class ReflectionProbe {
  51022. /** defines the name of the probe */
  51023. name: string;
  51024. private _scene;
  51025. private _renderTargetTexture;
  51026. private _projectionMatrix;
  51027. private _viewMatrix;
  51028. private _target;
  51029. private _add;
  51030. private _attachedMesh;
  51031. private _invertYAxis;
  51032. /** Gets or sets probe position (center of the cube map) */
  51033. position: Vector3;
  51034. /**
  51035. * Creates a new reflection probe
  51036. * @param name defines the name of the probe
  51037. * @param size defines the texture resolution (for each face)
  51038. * @param scene defines the hosting scene
  51039. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51040. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51041. */
  51042. constructor(
  51043. /** defines the name of the probe */
  51044. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51045. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51046. samples: number;
  51047. /** Gets or sets the refresh rate to use (on every frame by default) */
  51048. refreshRate: number;
  51049. /**
  51050. * Gets the hosting scene
  51051. * @returns a Scene
  51052. */
  51053. getScene(): Scene;
  51054. /** Gets the internal CubeTexture used to render to */
  51055. readonly cubeTexture: RenderTargetTexture;
  51056. /** Gets the list of meshes to render */
  51057. readonly renderList: Nullable<AbstractMesh[]>;
  51058. /**
  51059. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51060. * @param mesh defines the mesh to attach to
  51061. */
  51062. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51063. /**
  51064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51065. * @param renderingGroupId The rendering group id corresponding to its index
  51066. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51067. */
  51068. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51069. /**
  51070. * Clean all associated resources
  51071. */
  51072. dispose(): void;
  51073. /**
  51074. * Converts the reflection probe information to a readable string for debug purpose.
  51075. * @param fullDetails Supports for multiple levels of logging within scene loading
  51076. * @returns the human readable reflection probe info
  51077. */
  51078. toString(fullDetails?: boolean): string;
  51079. /**
  51080. * Get the class name of the relfection probe.
  51081. * @returns "ReflectionProbe"
  51082. */
  51083. getClassName(): string;
  51084. /**
  51085. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51086. * @returns The JSON representation of the texture
  51087. */
  51088. serialize(): any;
  51089. /**
  51090. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51091. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51092. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51093. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51094. * @returns The parsed reflection probe if successful
  51095. */
  51096. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51097. }
  51098. }
  51099. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51100. /** @hidden */
  51101. export var _BabylonLoaderRegistered: boolean;
  51102. }
  51103. declare module "babylonjs/Loading/Plugins/index" {
  51104. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51105. }
  51106. declare module "babylonjs/Loading/index" {
  51107. export * from "babylonjs/Loading/loadingScreen";
  51108. export * from "babylonjs/Loading/Plugins/index";
  51109. export * from "babylonjs/Loading/sceneLoader";
  51110. export * from "babylonjs/Loading/sceneLoaderFlags";
  51111. }
  51112. declare module "babylonjs/Materials/Background/index" {
  51113. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51114. }
  51115. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51116. import { Scene } from "babylonjs/scene";
  51117. import { Color3 } from "babylonjs/Maths/math";
  51118. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51120. /**
  51121. * The Physically based simple base material of BJS.
  51122. *
  51123. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51124. * It is used as the base class for both the specGloss and metalRough conventions.
  51125. */
  51126. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51127. /**
  51128. * Number of Simultaneous lights allowed on the material.
  51129. */
  51130. maxSimultaneousLights: number;
  51131. /**
  51132. * If sets to true, disables all the lights affecting the material.
  51133. */
  51134. disableLighting: boolean;
  51135. /**
  51136. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51137. */
  51138. environmentTexture: BaseTexture;
  51139. /**
  51140. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51141. */
  51142. invertNormalMapX: boolean;
  51143. /**
  51144. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51145. */
  51146. invertNormalMapY: boolean;
  51147. /**
  51148. * Normal map used in the model.
  51149. */
  51150. normalTexture: BaseTexture;
  51151. /**
  51152. * Emissivie color used to self-illuminate the model.
  51153. */
  51154. emissiveColor: Color3;
  51155. /**
  51156. * Emissivie texture used to self-illuminate the model.
  51157. */
  51158. emissiveTexture: BaseTexture;
  51159. /**
  51160. * Occlusion Channel Strenght.
  51161. */
  51162. occlusionStrength: number;
  51163. /**
  51164. * Occlusion Texture of the material (adding extra occlusion effects).
  51165. */
  51166. occlusionTexture: BaseTexture;
  51167. /**
  51168. * Defines the alpha limits in alpha test mode.
  51169. */
  51170. alphaCutOff: number;
  51171. /**
  51172. * Gets the current double sided mode.
  51173. */
  51174. /**
  51175. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51176. */
  51177. doubleSided: boolean;
  51178. /**
  51179. * Stores the pre-calculated light information of a mesh in a texture.
  51180. */
  51181. lightmapTexture: BaseTexture;
  51182. /**
  51183. * If true, the light map contains occlusion information instead of lighting info.
  51184. */
  51185. useLightmapAsShadowmap: boolean;
  51186. /**
  51187. * Instantiates a new PBRMaterial instance.
  51188. *
  51189. * @param name The material name
  51190. * @param scene The scene the material will be use in.
  51191. */
  51192. constructor(name: string, scene: Scene);
  51193. getClassName(): string;
  51194. }
  51195. }
  51196. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51197. import { Scene } from "babylonjs/scene";
  51198. import { Color3 } from "babylonjs/Maths/math";
  51199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51200. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51201. /**
  51202. * The PBR material of BJS following the metal roughness convention.
  51203. *
  51204. * This fits to the PBR convention in the GLTF definition:
  51205. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51206. */
  51207. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51208. /**
  51209. * The base color has two different interpretations depending on the value of metalness.
  51210. * When the material is a metal, the base color is the specific measured reflectance value
  51211. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51212. * of the material.
  51213. */
  51214. baseColor: Color3;
  51215. /**
  51216. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51217. * well as opacity information in the alpha channel.
  51218. */
  51219. baseTexture: BaseTexture;
  51220. /**
  51221. * Specifies the metallic scalar value of the material.
  51222. * Can also be used to scale the metalness values of the metallic texture.
  51223. */
  51224. metallic: number;
  51225. /**
  51226. * Specifies the roughness scalar value of the material.
  51227. * Can also be used to scale the roughness values of the metallic texture.
  51228. */
  51229. roughness: number;
  51230. /**
  51231. * Texture containing both the metallic value in the B channel and the
  51232. * roughness value in the G channel to keep better precision.
  51233. */
  51234. metallicRoughnessTexture: BaseTexture;
  51235. /**
  51236. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51237. *
  51238. * @param name The material name
  51239. * @param scene The scene the material will be use in.
  51240. */
  51241. constructor(name: string, scene: Scene);
  51242. /**
  51243. * Return the currrent class name of the material.
  51244. */
  51245. getClassName(): string;
  51246. /**
  51247. * Makes a duplicate of the current material.
  51248. * @param name - name to use for the new material.
  51249. */
  51250. clone(name: string): PBRMetallicRoughnessMaterial;
  51251. /**
  51252. * Serialize the material to a parsable JSON object.
  51253. */
  51254. serialize(): any;
  51255. /**
  51256. * Parses a JSON object correponding to the serialize function.
  51257. */
  51258. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51259. }
  51260. }
  51261. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51262. import { Scene } from "babylonjs/scene";
  51263. import { Color3 } from "babylonjs/Maths/math";
  51264. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51265. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51266. /**
  51267. * The PBR material of BJS following the specular glossiness convention.
  51268. *
  51269. * This fits to the PBR convention in the GLTF definition:
  51270. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51271. */
  51272. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51273. /**
  51274. * Specifies the diffuse color of the material.
  51275. */
  51276. diffuseColor: Color3;
  51277. /**
  51278. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51279. * channel.
  51280. */
  51281. diffuseTexture: BaseTexture;
  51282. /**
  51283. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51284. */
  51285. specularColor: Color3;
  51286. /**
  51287. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51288. */
  51289. glossiness: number;
  51290. /**
  51291. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51292. */
  51293. specularGlossinessTexture: BaseTexture;
  51294. /**
  51295. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51296. *
  51297. * @param name The material name
  51298. * @param scene The scene the material will be use in.
  51299. */
  51300. constructor(name: string, scene: Scene);
  51301. /**
  51302. * Return the currrent class name of the material.
  51303. */
  51304. getClassName(): string;
  51305. /**
  51306. * Makes a duplicate of the current material.
  51307. * @param name - name to use for the new material.
  51308. */
  51309. clone(name: string): PBRSpecularGlossinessMaterial;
  51310. /**
  51311. * Serialize the material to a parsable JSON object.
  51312. */
  51313. serialize(): any;
  51314. /**
  51315. * Parses a JSON object correponding to the serialize function.
  51316. */
  51317. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51318. }
  51319. }
  51320. declare module "babylonjs/Materials/PBR/index" {
  51321. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51322. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51323. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51324. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51325. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51326. }
  51327. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51328. import { Nullable } from "babylonjs/types";
  51329. import { Scene } from "babylonjs/scene";
  51330. import { Matrix } from "babylonjs/Maths/math";
  51331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51332. /**
  51333. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51334. * It can help converting any input color in a desired output one. This can then be used to create effects
  51335. * from sepia, black and white to sixties or futuristic rendering...
  51336. *
  51337. * The only supported format is currently 3dl.
  51338. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51339. */
  51340. export class ColorGradingTexture extends BaseTexture {
  51341. /**
  51342. * The current texture matrix. (will always be identity in color grading texture)
  51343. */
  51344. private _textureMatrix;
  51345. /**
  51346. * The texture URL.
  51347. */
  51348. url: string;
  51349. /**
  51350. * Empty line regex stored for GC.
  51351. */
  51352. private static _noneEmptyLineRegex;
  51353. private _engine;
  51354. /**
  51355. * Instantiates a ColorGradingTexture from the following parameters.
  51356. *
  51357. * @param url The location of the color gradind data (currently only supporting 3dl)
  51358. * @param scene The scene the texture will be used in
  51359. */
  51360. constructor(url: string, scene: Scene);
  51361. /**
  51362. * Returns the texture matrix used in most of the material.
  51363. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51364. */
  51365. getTextureMatrix(): Matrix;
  51366. /**
  51367. * Occurs when the file being loaded is a .3dl LUT file.
  51368. */
  51369. private load3dlTexture;
  51370. /**
  51371. * Starts the loading process of the texture.
  51372. */
  51373. private loadTexture;
  51374. /**
  51375. * Clones the color gradind texture.
  51376. */
  51377. clone(): ColorGradingTexture;
  51378. /**
  51379. * Called during delayed load for textures.
  51380. */
  51381. delayLoad(): void;
  51382. /**
  51383. * Parses a color grading texture serialized by Babylon.
  51384. * @param parsedTexture The texture information being parsedTexture
  51385. * @param scene The scene to load the texture in
  51386. * @param rootUrl The root url of the data assets to load
  51387. * @return A color gradind texture
  51388. */
  51389. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51390. /**
  51391. * Serializes the LUT texture to json format.
  51392. */
  51393. serialize(): any;
  51394. }
  51395. }
  51396. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { Nullable } from "babylonjs/types";
  51400. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51401. /**
  51402. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51403. */
  51404. export class EquiRectangularCubeTexture extends BaseTexture {
  51405. /** The six faces of the cube. */
  51406. private static _FacesMapping;
  51407. private _noMipmap;
  51408. private _onLoad;
  51409. private _onError;
  51410. /** The size of the cubemap. */
  51411. private _size;
  51412. /** The buffer of the image. */
  51413. private _buffer;
  51414. /** The width of the input image. */
  51415. private _width;
  51416. /** The height of the input image. */
  51417. private _height;
  51418. /** The URL to the image. */
  51419. url: string;
  51420. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51421. coordinatesMode: number;
  51422. /**
  51423. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51424. * @param url The location of the image
  51425. * @param scene The scene the texture will be used in
  51426. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51427. * @param noMipmap Forces to not generate the mipmap if true
  51428. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51429. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51430. * @param onLoad — defines a callback called when texture is loaded
  51431. * @param onError — defines a callback called if there is an error
  51432. */
  51433. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51434. /**
  51435. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51436. */
  51437. private loadImage;
  51438. /**
  51439. * Convert the image buffer into a cubemap and create a CubeTexture.
  51440. */
  51441. private loadTexture;
  51442. /**
  51443. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51444. * @param buffer The ArrayBuffer that should be converted.
  51445. * @returns The buffer as Float32Array.
  51446. */
  51447. private getFloat32ArrayFromArrayBuffer;
  51448. /**
  51449. * Get the current class name of the texture useful for serialization or dynamic coding.
  51450. * @returns "EquiRectangularCubeTexture"
  51451. */
  51452. getClassName(): string;
  51453. /**
  51454. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51455. * @returns A clone of the current EquiRectangularCubeTexture.
  51456. */
  51457. clone(): EquiRectangularCubeTexture;
  51458. }
  51459. }
  51460. declare module "babylonjs/Misc/tga" {
  51461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51462. /**
  51463. * Based on jsTGALoader - Javascript loader for TGA file
  51464. * By Vincent Thibault
  51465. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51466. */
  51467. export class TGATools {
  51468. private static _TYPE_INDEXED;
  51469. private static _TYPE_RGB;
  51470. private static _TYPE_GREY;
  51471. private static _TYPE_RLE_INDEXED;
  51472. private static _TYPE_RLE_RGB;
  51473. private static _TYPE_RLE_GREY;
  51474. private static _ORIGIN_MASK;
  51475. private static _ORIGIN_SHIFT;
  51476. private static _ORIGIN_BL;
  51477. private static _ORIGIN_BR;
  51478. private static _ORIGIN_UL;
  51479. private static _ORIGIN_UR;
  51480. /**
  51481. * Gets the header of a TGA file
  51482. * @param data defines the TGA data
  51483. * @returns the header
  51484. */
  51485. static GetTGAHeader(data: Uint8Array): any;
  51486. /**
  51487. * Uploads TGA content to a Babylon Texture
  51488. * @hidden
  51489. */
  51490. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51491. /** @hidden */
  51492. 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;
  51493. /** @hidden */
  51494. 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;
  51495. /** @hidden */
  51496. 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;
  51497. /** @hidden */
  51498. 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;
  51499. /** @hidden */
  51500. 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;
  51501. /** @hidden */
  51502. 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;
  51503. }
  51504. }
  51505. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51506. import { Nullable } from "babylonjs/types";
  51507. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51508. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51509. /**
  51510. * Implementation of the TGA Texture Loader.
  51511. * @hidden
  51512. */
  51513. export class _TGATextureLoader implements IInternalTextureLoader {
  51514. /**
  51515. * Defines wether the loader supports cascade loading the different faces.
  51516. */
  51517. readonly supportCascades: boolean;
  51518. /**
  51519. * This returns if the loader support the current file information.
  51520. * @param extension defines the file extension of the file being loaded
  51521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51522. * @param fallback defines the fallback internal texture if any
  51523. * @param isBase64 defines whether the texture is encoded as a base64
  51524. * @param isBuffer defines whether the texture data are stored as a buffer
  51525. * @returns true if the loader can load the specified file
  51526. */
  51527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51528. /**
  51529. * Transform the url before loading if required.
  51530. * @param rootUrl the url of the texture
  51531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51532. * @returns the transformed texture
  51533. */
  51534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51535. /**
  51536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51537. * @param rootUrl the url of the texture
  51538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51539. * @returns the fallback texture
  51540. */
  51541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51542. /**
  51543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51544. * @param data contains the texture data
  51545. * @param texture defines the BabylonJS internal texture
  51546. * @param createPolynomials will be true if polynomials have been requested
  51547. * @param onLoad defines the callback to trigger once the texture is ready
  51548. * @param onError defines the callback to trigger in case of error
  51549. */
  51550. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51551. /**
  51552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51553. * @param data contains the texture data
  51554. * @param texture defines the BabylonJS internal texture
  51555. * @param callback defines the method to call once ready to upload
  51556. */
  51557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51558. }
  51559. }
  51560. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51561. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51562. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51563. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51564. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51565. }
  51566. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51567. import { Scene } from "babylonjs/scene";
  51568. import { Texture } from "babylonjs/Materials/Textures/texture";
  51569. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51570. /**
  51571. * 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.
  51572. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51573. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51574. */
  51575. export class CustomProceduralTexture extends ProceduralTexture {
  51576. private _animate;
  51577. private _time;
  51578. private _config;
  51579. private _texturePath;
  51580. /**
  51581. * Instantiates a new Custom Procedural Texture.
  51582. * 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.
  51583. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51584. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51585. * @param name Define the name of the texture
  51586. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51587. * @param size Define the size of the texture to create
  51588. * @param scene Define the scene the texture belongs to
  51589. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51590. * @param generateMipMaps Define if the texture should creates mip maps or not
  51591. */
  51592. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51593. private _loadJson;
  51594. /**
  51595. * Is the texture ready to be used ? (rendered at least once)
  51596. * @returns true if ready, otherwise, false.
  51597. */
  51598. isReady(): boolean;
  51599. /**
  51600. * Render the texture to its associated render target.
  51601. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51602. */
  51603. render(useCameraPostProcess?: boolean): void;
  51604. /**
  51605. * Update the list of dependant textures samplers in the shader.
  51606. */
  51607. updateTextures(): void;
  51608. /**
  51609. * Update the uniform values of the procedural texture in the shader.
  51610. */
  51611. updateShaderUniforms(): void;
  51612. /**
  51613. * Define if the texture animates or not.
  51614. */
  51615. animate: boolean;
  51616. }
  51617. }
  51618. declare module "babylonjs/Shaders/noise.fragment" {
  51619. /** @hidden */
  51620. export var noisePixelShader: {
  51621. name: string;
  51622. shader: string;
  51623. };
  51624. }
  51625. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51626. import { Nullable } from "babylonjs/types";
  51627. import { Scene } from "babylonjs/scene";
  51628. import { Texture } from "babylonjs/Materials/Textures/texture";
  51629. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51630. import "babylonjs/Shaders/noise.fragment";
  51631. /**
  51632. * Class used to generate noise procedural textures
  51633. */
  51634. export class NoiseProceduralTexture extends ProceduralTexture {
  51635. private _time;
  51636. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51637. brightness: number;
  51638. /** Defines the number of octaves to process */
  51639. octaves: number;
  51640. /** Defines the level of persistence (0.8 by default) */
  51641. persistence: number;
  51642. /** Gets or sets animation speed factor (default is 1) */
  51643. animationSpeedFactor: number;
  51644. /**
  51645. * Creates a new NoiseProceduralTexture
  51646. * @param name defines the name fo the texture
  51647. * @param size defines the size of the texture (default is 256)
  51648. * @param scene defines the hosting scene
  51649. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51650. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51651. */
  51652. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51653. private _updateShaderUniforms;
  51654. protected _getDefines(): string;
  51655. /** Generate the current state of the procedural texture */
  51656. render(useCameraPostProcess?: boolean): void;
  51657. /**
  51658. * Serializes this noise procedural texture
  51659. * @returns a serialized noise procedural texture object
  51660. */
  51661. serialize(): any;
  51662. /**
  51663. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51664. * @param parsedTexture defines parsed texture data
  51665. * @param scene defines the current scene
  51666. * @param rootUrl defines the root URL containing noise procedural texture information
  51667. * @returns a parsed NoiseProceduralTexture
  51668. */
  51669. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51670. }
  51671. }
  51672. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51673. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51674. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51675. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51676. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51677. }
  51678. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51679. import { Nullable } from "babylonjs/types";
  51680. import { Scene } from "babylonjs/scene";
  51681. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51683. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51684. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51685. /**
  51686. * Raw cube texture where the raw buffers are passed in
  51687. */
  51688. export class RawCubeTexture extends CubeTexture {
  51689. /**
  51690. * Creates a cube texture where the raw buffers are passed in.
  51691. * @param scene defines the scene the texture is attached to
  51692. * @param data defines the array of data to use to create each face
  51693. * @param size defines the size of the textures
  51694. * @param format defines the format of the data
  51695. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51696. * @param generateMipMaps defines if the engine should generate the mip levels
  51697. * @param invertY defines if data must be stored with Y axis inverted
  51698. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51699. * @param compression defines the compression used (null by default)
  51700. */
  51701. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51702. /**
  51703. * Updates the raw cube texture.
  51704. * @param data defines the data to store
  51705. * @param format defines the data format
  51706. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51707. * @param invertY defines if data must be stored with Y axis inverted
  51708. * @param compression defines the compression used (null by default)
  51709. * @param level defines which level of the texture to update
  51710. */
  51711. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51712. /**
  51713. * Updates a raw cube texture with RGBD encoded data.
  51714. * @param data defines the array of data [mipmap][face] to use to create each face
  51715. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51718. * @returns a promsie that resolves when the operation is complete
  51719. */
  51720. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51721. /**
  51722. * Clones the raw cube texture.
  51723. * @return a new cube texture
  51724. */
  51725. clone(): CubeTexture;
  51726. /** @hidden */
  51727. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51728. }
  51729. }
  51730. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51731. import { Scene } from "babylonjs/scene";
  51732. import { Texture } from "babylonjs/Materials/Textures/texture";
  51733. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51734. /**
  51735. * Class used to store 3D textures containing user data
  51736. */
  51737. export class RawTexture3D extends Texture {
  51738. /** Gets or sets the texture format to use */
  51739. format: number;
  51740. private _engine;
  51741. /**
  51742. * Create a new RawTexture3D
  51743. * @param data defines the data of the texture
  51744. * @param width defines the width of the texture
  51745. * @param height defines the height of the texture
  51746. * @param depth defines the depth of the texture
  51747. * @param format defines the texture format to use
  51748. * @param scene defines the hosting scene
  51749. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51750. * @param invertY defines if texture must be stored with Y axis inverted
  51751. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51752. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51753. */
  51754. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51755. /** Gets or sets the texture format to use */
  51756. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51757. /**
  51758. * Update the texture with new data
  51759. * @param data defines the data to store in the texture
  51760. */
  51761. update(data: ArrayBufferView): void;
  51762. }
  51763. }
  51764. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51765. import { Scene } from "babylonjs/scene";
  51766. import { Plane } from "babylonjs/Maths/math";
  51767. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51768. /**
  51769. * Creates a refraction texture used by refraction channel of the standard material.
  51770. * It is like a mirror but to see through a material.
  51771. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51772. */
  51773. export class RefractionTexture extends RenderTargetTexture {
  51774. /**
  51775. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51776. * 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.
  51777. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51778. */
  51779. refractionPlane: Plane;
  51780. /**
  51781. * Define how deep under the surface we should see.
  51782. */
  51783. depth: number;
  51784. /**
  51785. * Creates a refraction texture used by refraction channel of the standard material.
  51786. * It is like a mirror but to see through a material.
  51787. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51788. * @param name Define the texture name
  51789. * @param size Define the size of the underlying texture
  51790. * @param scene Define the scene the refraction belongs to
  51791. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51792. */
  51793. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51794. /**
  51795. * Clone the refraction texture.
  51796. * @returns the cloned texture
  51797. */
  51798. clone(): RefractionTexture;
  51799. /**
  51800. * Serialize the texture to a JSON representation you could use in Parse later on
  51801. * @returns the serialized JSON representation
  51802. */
  51803. serialize(): any;
  51804. }
  51805. }
  51806. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51807. import { Nullable } from "babylonjs/types";
  51808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51809. import { Matrix } from "babylonjs/Maths/math";
  51810. import { Engine } from "babylonjs/Engines/engine";
  51811. import { Scene } from "babylonjs/scene";
  51812. /**
  51813. * Defines the options related to the creation of an HtmlElementTexture
  51814. */
  51815. export interface IHtmlElementTextureOptions {
  51816. /**
  51817. * Defines wether mip maps should be created or not.
  51818. */
  51819. generateMipMaps?: boolean;
  51820. /**
  51821. * Defines the sampling mode of the texture.
  51822. */
  51823. samplingMode?: number;
  51824. /**
  51825. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51826. */
  51827. engine: Nullable<Engine>;
  51828. /**
  51829. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51830. */
  51831. scene: Nullable<Scene>;
  51832. }
  51833. /**
  51834. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51835. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51836. * is automatically managed.
  51837. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51838. * in your application.
  51839. *
  51840. * As the update is not automatic, you need to call them manually.
  51841. */
  51842. export class HtmlElementTexture extends BaseTexture {
  51843. /**
  51844. * The texture URL.
  51845. */
  51846. element: HTMLVideoElement | HTMLCanvasElement;
  51847. private static readonly DefaultOptions;
  51848. private _textureMatrix;
  51849. private _engine;
  51850. private _isVideo;
  51851. private _generateMipMaps;
  51852. private _samplingMode;
  51853. /**
  51854. * Instantiates a HtmlElementTexture from the following parameters.
  51855. *
  51856. * @param name Defines the name of the texture
  51857. * @param element Defines the video or canvas the texture is filled with
  51858. * @param options Defines the other none mandatory texture creation options
  51859. */
  51860. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51861. private _createInternalTexture;
  51862. /**
  51863. * Returns the texture matrix used in most of the material.
  51864. */
  51865. getTextureMatrix(): Matrix;
  51866. /**
  51867. * Updates the content of the texture.
  51868. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51869. */
  51870. update(invertY?: Nullable<boolean>): void;
  51871. }
  51872. }
  51873. declare module "babylonjs/Materials/Textures/index" {
  51874. export * from "babylonjs/Materials/Textures/baseTexture";
  51875. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51876. export * from "babylonjs/Materials/Textures/cubeTexture";
  51877. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51878. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51879. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51880. export * from "babylonjs/Materials/Textures/internalTexture";
  51881. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51882. export * from "babylonjs/Materials/Textures/Loaders/index";
  51883. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51884. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51885. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51886. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51887. export * from "babylonjs/Materials/Textures/rawTexture";
  51888. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51889. export * from "babylonjs/Materials/Textures/refractionTexture";
  51890. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51891. export * from "babylonjs/Materials/Textures/texture";
  51892. export * from "babylonjs/Materials/Textures/videoTexture";
  51893. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51894. }
  51895. declare module "babylonjs/Materials/index" {
  51896. export * from "babylonjs/Materials/Background/index";
  51897. export * from "babylonjs/Materials/colorCurves";
  51898. export * from "babylonjs/Materials/effect";
  51899. export * from "babylonjs/Materials/fresnelParameters";
  51900. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51901. export * from "babylonjs/Materials/material";
  51902. export * from "babylonjs/Materials/materialDefines";
  51903. export * from "babylonjs/Materials/materialHelper";
  51904. export * from "babylonjs/Materials/multiMaterial";
  51905. export * from "babylonjs/Materials/PBR/index";
  51906. export * from "babylonjs/Materials/pushMaterial";
  51907. export * from "babylonjs/Materials/shaderMaterial";
  51908. export * from "babylonjs/Materials/standardMaterial";
  51909. export * from "babylonjs/Materials/Textures/index";
  51910. export * from "babylonjs/Materials/uniformBuffer";
  51911. export * from "babylonjs/Materials/materialFlags";
  51912. }
  51913. declare module "babylonjs/Maths/index" {
  51914. export * from "babylonjs/Maths/math.scalar";
  51915. export * from "babylonjs/Maths/math";
  51916. export * from "babylonjs/Maths/sphericalPolynomial";
  51917. }
  51918. declare module "babylonjs/Misc/workerPool" {
  51919. import { IDisposable } from "babylonjs/scene";
  51920. /**
  51921. * Helper class to push actions to a pool of workers.
  51922. */
  51923. export class WorkerPool implements IDisposable {
  51924. private _workerInfos;
  51925. private _pendingActions;
  51926. /**
  51927. * Constructor
  51928. * @param workers Array of workers to use for actions
  51929. */
  51930. constructor(workers: Array<Worker>);
  51931. /**
  51932. * Terminates all workers and clears any pending actions.
  51933. */
  51934. dispose(): void;
  51935. /**
  51936. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51937. * pended until a worker has completed its action.
  51938. * @param action The action to perform. Call onComplete when the action is complete.
  51939. */
  51940. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51941. private _execute;
  51942. }
  51943. }
  51944. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51945. import { IDisposable } from "babylonjs/scene";
  51946. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51947. /**
  51948. * Configuration for Draco compression
  51949. */
  51950. export interface IDracoCompressionConfiguration {
  51951. /**
  51952. * Configuration for the decoder.
  51953. */
  51954. decoder?: {
  51955. /**
  51956. * The url to the WebAssembly module.
  51957. */
  51958. wasmUrl?: string;
  51959. /**
  51960. * The url to the WebAssembly binary.
  51961. */
  51962. wasmBinaryUrl?: string;
  51963. /**
  51964. * The url to the fallback JavaScript module.
  51965. */
  51966. fallbackUrl?: string;
  51967. };
  51968. }
  51969. /**
  51970. * Draco compression (https://google.github.io/draco/)
  51971. *
  51972. * This class wraps the Draco module.
  51973. *
  51974. * **Encoder**
  51975. *
  51976. * The encoder is not currently implemented.
  51977. *
  51978. * **Decoder**
  51979. *
  51980. * 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.
  51981. *
  51982. * To update the configuration, use the following code:
  51983. * ```javascript
  51984. * DracoCompression.Configuration = {
  51985. * decoder: {
  51986. * wasmUrl: "<url to the WebAssembly library>",
  51987. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51988. * fallbackUrl: "<url to the fallback JavaScript library>",
  51989. * }
  51990. * };
  51991. * ```
  51992. *
  51993. * 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.
  51994. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51995. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51996. *
  51997. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51998. * ```javascript
  51999. * var dracoCompression = new DracoCompression();
  52000. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  52001. * [VertexBuffer.PositionKind]: 0
  52002. * });
  52003. * ```
  52004. *
  52005. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52006. */
  52007. export class DracoCompression implements IDisposable {
  52008. private _workerPoolPromise;
  52009. /**
  52010. * The configuration. Defaults to the following urls:
  52011. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52012. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52013. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52014. */
  52015. static Configuration: IDracoCompressionConfiguration;
  52016. /**
  52017. * Returns true if the decoder is available.
  52018. */
  52019. static readonly DecoderAvailable: boolean;
  52020. /**
  52021. * Default number of workers to create when creating the draco compression object.
  52022. */
  52023. static DefaultNumWorkers: number;
  52024. private static GetDefaultNumWorkers;
  52025. private static _Default;
  52026. /**
  52027. * Default instance for the draco compression object.
  52028. */
  52029. static readonly Default: DracoCompression;
  52030. /**
  52031. * Constructor
  52032. * @param numWorkers The number of workers for async operations
  52033. */
  52034. constructor(numWorkers?: number);
  52035. /**
  52036. * Stop all async operations and release resources.
  52037. */
  52038. dispose(): void;
  52039. /**
  52040. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52041. * @returns a promise that resolves when ready
  52042. */
  52043. whenReadyAsync(): Promise<void>;
  52044. /**
  52045. * Decode Draco compressed mesh data to vertex data.
  52046. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52047. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52048. * @returns A promise that resolves with the decoded vertex data
  52049. */
  52050. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52051. [kind: string]: number;
  52052. }): Promise<VertexData>;
  52053. /**
  52054. * The worker function that gets converted to a blob url to pass into a worker.
  52055. */
  52056. private static _Worker;
  52057. private _loadDecoderWasmBinaryAsync;
  52058. }
  52059. }
  52060. declare module "babylonjs/Meshes/Compression/index" {
  52061. export * from "babylonjs/Meshes/Compression/dracoCompression";
  52062. }
  52063. declare module "babylonjs/Meshes/csg" {
  52064. import { Nullable } from "babylonjs/types";
  52065. import { Scene } from "babylonjs/scene";
  52066. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  52067. import { Mesh } from "babylonjs/Meshes/mesh";
  52068. import { Material } from "babylonjs/Materials/material";
  52069. /**
  52070. * Class for building Constructive Solid Geometry
  52071. */
  52072. export class CSG {
  52073. private polygons;
  52074. /**
  52075. * The world matrix
  52076. */
  52077. matrix: Matrix;
  52078. /**
  52079. * Stores the position
  52080. */
  52081. position: Vector3;
  52082. /**
  52083. * Stores the rotation
  52084. */
  52085. rotation: Vector3;
  52086. /**
  52087. * Stores the rotation quaternion
  52088. */
  52089. rotationQuaternion: Nullable<Quaternion>;
  52090. /**
  52091. * Stores the scaling vector
  52092. */
  52093. scaling: Vector3;
  52094. /**
  52095. * Convert the Mesh to CSG
  52096. * @param mesh The Mesh to convert to CSG
  52097. * @returns A new CSG from the Mesh
  52098. */
  52099. static FromMesh(mesh: Mesh): CSG;
  52100. /**
  52101. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52102. * @param polygons Polygons used to construct a CSG solid
  52103. */
  52104. private static FromPolygons;
  52105. /**
  52106. * Clones, or makes a deep copy, of the CSG
  52107. * @returns A new CSG
  52108. */
  52109. clone(): CSG;
  52110. /**
  52111. * Unions this CSG with another CSG
  52112. * @param csg The CSG to union against this CSG
  52113. * @returns The unioned CSG
  52114. */
  52115. union(csg: CSG): CSG;
  52116. /**
  52117. * Unions this CSG with another CSG in place
  52118. * @param csg The CSG to union against this CSG
  52119. */
  52120. unionInPlace(csg: CSG): void;
  52121. /**
  52122. * Subtracts this CSG with another CSG
  52123. * @param csg The CSG to subtract against this CSG
  52124. * @returns A new CSG
  52125. */
  52126. subtract(csg: CSG): CSG;
  52127. /**
  52128. * Subtracts this CSG with another CSG in place
  52129. * @param csg The CSG to subtact against this CSG
  52130. */
  52131. subtractInPlace(csg: CSG): void;
  52132. /**
  52133. * Intersect this CSG with another CSG
  52134. * @param csg The CSG to intersect against this CSG
  52135. * @returns A new CSG
  52136. */
  52137. intersect(csg: CSG): CSG;
  52138. /**
  52139. * Intersects this CSG with another CSG in place
  52140. * @param csg The CSG to intersect against this CSG
  52141. */
  52142. intersectInPlace(csg: CSG): void;
  52143. /**
  52144. * Return a new CSG solid with solid and empty space switched. This solid is
  52145. * not modified.
  52146. * @returns A new CSG solid with solid and empty space switched
  52147. */
  52148. inverse(): CSG;
  52149. /**
  52150. * Inverses the CSG in place
  52151. */
  52152. inverseInPlace(): void;
  52153. /**
  52154. * This is used to keep meshes transformations so they can be restored
  52155. * when we build back a Babylon Mesh
  52156. * NB : All CSG operations are performed in world coordinates
  52157. * @param csg The CSG to copy the transform attributes from
  52158. * @returns This CSG
  52159. */
  52160. copyTransformAttributes(csg: CSG): CSG;
  52161. /**
  52162. * Build Raw mesh from CSG
  52163. * Coordinates here are in world space
  52164. * @param name The name of the mesh geometry
  52165. * @param scene The Scene
  52166. * @param keepSubMeshes Specifies if the submeshes should be kept
  52167. * @returns A new Mesh
  52168. */
  52169. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52170. /**
  52171. * Build Mesh from CSG taking material and transforms into account
  52172. * @param name The name of the Mesh
  52173. * @param material The material of the Mesh
  52174. * @param scene The Scene
  52175. * @param keepSubMeshes Specifies if submeshes should be kept
  52176. * @returns The new Mesh
  52177. */
  52178. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52179. }
  52180. }
  52181. declare module "babylonjs/Meshes/trailMesh" {
  52182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52183. import { Mesh } from "babylonjs/Meshes/mesh";
  52184. import { Scene } from "babylonjs/scene";
  52185. /**
  52186. * Class used to create a trail following a mesh
  52187. */
  52188. export class TrailMesh extends Mesh {
  52189. private _generator;
  52190. private _autoStart;
  52191. private _running;
  52192. private _diameter;
  52193. private _length;
  52194. private _sectionPolygonPointsCount;
  52195. private _sectionVectors;
  52196. private _sectionNormalVectors;
  52197. private _beforeRenderObserver;
  52198. /**
  52199. * @constructor
  52200. * @param name The value used by scene.getMeshByName() to do a lookup.
  52201. * @param generator The mesh to generate a trail.
  52202. * @param scene The scene to add this mesh to.
  52203. * @param diameter Diameter of trailing mesh. Default is 1.
  52204. * @param length Length of trailing mesh. Default is 60.
  52205. * @param autoStart Automatically start trailing mesh. Default true.
  52206. */
  52207. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52208. /**
  52209. * "TrailMesh"
  52210. * @returns "TrailMesh"
  52211. */
  52212. getClassName(): string;
  52213. private _createMesh;
  52214. /**
  52215. * Start trailing mesh.
  52216. */
  52217. start(): void;
  52218. /**
  52219. * Stop trailing mesh.
  52220. */
  52221. stop(): void;
  52222. /**
  52223. * Update trailing mesh geometry.
  52224. */
  52225. update(): void;
  52226. /**
  52227. * Returns a new TrailMesh object.
  52228. * @param name is a string, the name given to the new mesh
  52229. * @param newGenerator use new generator object for cloned trail mesh
  52230. * @returns a new mesh
  52231. */
  52232. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52233. /**
  52234. * Serializes this trail mesh
  52235. * @param serializationObject object to write serialization to
  52236. */
  52237. serialize(serializationObject: any): void;
  52238. /**
  52239. * Parses a serialized trail mesh
  52240. * @param parsedMesh the serialized mesh
  52241. * @param scene the scene to create the trail mesh in
  52242. * @returns the created trail mesh
  52243. */
  52244. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52245. }
  52246. }
  52247. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  52248. import { Vector4 } from "babylonjs/Maths/math";
  52249. import { Mesh } from "babylonjs/Meshes/mesh";
  52250. /**
  52251. * Class containing static functions to help procedurally build meshes
  52252. */
  52253. export class TorusKnotBuilder {
  52254. /**
  52255. * Creates a torus knot mesh
  52256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52263. * @param name defines the name of the mesh
  52264. * @param options defines the options used to create the mesh
  52265. * @param scene defines the hosting scene
  52266. * @returns the torus knot mesh
  52267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52268. */
  52269. static CreateTorusKnot(name: string, options: {
  52270. radius?: number;
  52271. tube?: number;
  52272. radialSegments?: number;
  52273. tubularSegments?: number;
  52274. p?: number;
  52275. q?: number;
  52276. updatable?: boolean;
  52277. sideOrientation?: number;
  52278. frontUVs?: Vector4;
  52279. backUVs?: Vector4;
  52280. }, scene: any): Mesh;
  52281. }
  52282. }
  52283. declare module "babylonjs/Meshes/polygonMesh" {
  52284. import { Scene } from "babylonjs/scene";
  52285. import { Vector2, Path2 } from "babylonjs/Maths/math";
  52286. import { Mesh } from "babylonjs/Meshes/mesh";
  52287. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  52288. /**
  52289. * Polygon
  52290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52291. */
  52292. export class Polygon {
  52293. /**
  52294. * Creates a rectangle
  52295. * @param xmin bottom X coord
  52296. * @param ymin bottom Y coord
  52297. * @param xmax top X coord
  52298. * @param ymax top Y coord
  52299. * @returns points that make the resulting rectation
  52300. */
  52301. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52302. /**
  52303. * Creates a circle
  52304. * @param radius radius of circle
  52305. * @param cx scale in x
  52306. * @param cy scale in y
  52307. * @param numberOfSides number of sides that make up the circle
  52308. * @returns points that make the resulting circle
  52309. */
  52310. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52311. /**
  52312. * Creates a polygon from input string
  52313. * @param input Input polygon data
  52314. * @returns the parsed points
  52315. */
  52316. static Parse(input: string): Vector2[];
  52317. /**
  52318. * Starts building a polygon from x and y coordinates
  52319. * @param x x coordinate
  52320. * @param y y coordinate
  52321. * @returns the started path2
  52322. */
  52323. static StartingAt(x: number, y: number): Path2;
  52324. }
  52325. /**
  52326. * Builds a polygon
  52327. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52328. */
  52329. export class PolygonMeshBuilder {
  52330. private _points;
  52331. private _outlinepoints;
  52332. private _holes;
  52333. private _name;
  52334. private _scene;
  52335. private _epoints;
  52336. private _eholes;
  52337. private _addToepoint;
  52338. /**
  52339. * Babylon reference to the earcut plugin.
  52340. */
  52341. bjsEarcut: any;
  52342. /**
  52343. * Creates a PolygonMeshBuilder
  52344. * @param name name of the builder
  52345. * @param contours Path of the polygon
  52346. * @param scene scene to add to when creating the mesh
  52347. * @param earcutInjection can be used to inject your own earcut reference
  52348. */
  52349. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52350. /**
  52351. * Adds a whole within the polygon
  52352. * @param hole Array of points defining the hole
  52353. * @returns this
  52354. */
  52355. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52356. /**
  52357. * Creates the polygon
  52358. * @param updatable If the mesh should be updatable
  52359. * @param depth The depth of the mesh created
  52360. * @returns the created mesh
  52361. */
  52362. build(updatable?: boolean, depth?: number): Mesh;
  52363. /**
  52364. * Creates the polygon
  52365. * @param depth The depth of the mesh created
  52366. * @returns the created VertexData
  52367. */
  52368. buildVertexData(depth?: number): VertexData;
  52369. /**
  52370. * Adds a side to the polygon
  52371. * @param positions points that make the polygon
  52372. * @param normals normals of the polygon
  52373. * @param uvs uvs of the polygon
  52374. * @param indices indices of the polygon
  52375. * @param bounds bounds of the polygon
  52376. * @param points points of the polygon
  52377. * @param depth depth of the polygon
  52378. * @param flip flip of the polygon
  52379. */
  52380. private addSide;
  52381. }
  52382. }
  52383. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52384. import { Scene } from "babylonjs/scene";
  52385. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52386. import { Mesh } from "babylonjs/Meshes/mesh";
  52387. import { Nullable } from "babylonjs/types";
  52388. /**
  52389. * Class containing static functions to help procedurally build meshes
  52390. */
  52391. export class PolygonBuilder {
  52392. /**
  52393. * Creates a polygon mesh
  52394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52395. * * 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
  52396. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52399. * * Remember you can only change the shape positions, not their number when updating a polygon
  52400. * @param name defines the name of the mesh
  52401. * @param options defines the options used to create the mesh
  52402. * @param scene defines the hosting scene
  52403. * @param earcutInjection can be used to inject your own earcut reference
  52404. * @returns the polygon mesh
  52405. */
  52406. static CreatePolygon(name: string, options: {
  52407. shape: Vector3[];
  52408. holes?: Vector3[][];
  52409. depth?: number;
  52410. faceUV?: Vector4[];
  52411. faceColors?: Color4[];
  52412. updatable?: boolean;
  52413. sideOrientation?: number;
  52414. frontUVs?: Vector4;
  52415. backUVs?: Vector4;
  52416. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52417. /**
  52418. * Creates an extruded polygon mesh, with depth in the Y direction.
  52419. * * 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)
  52420. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52421. * @param name defines the name of the mesh
  52422. * @param options defines the options used to create the mesh
  52423. * @param scene defines the hosting scene
  52424. * @param earcutInjection can be used to inject your own earcut reference
  52425. * @returns the polygon mesh
  52426. */
  52427. static ExtrudePolygon(name: string, options: {
  52428. shape: Vector3[];
  52429. holes?: Vector3[][];
  52430. depth?: number;
  52431. faceUV?: Vector4[];
  52432. faceColors?: Color4[];
  52433. updatable?: boolean;
  52434. sideOrientation?: number;
  52435. frontUVs?: Vector4;
  52436. backUVs?: Vector4;
  52437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52438. }
  52439. }
  52440. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52441. import { Scene } from "babylonjs/scene";
  52442. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52443. import { Mesh } from "babylonjs/Meshes/mesh";
  52444. import { Nullable } from "babylonjs/types";
  52445. /**
  52446. * Class containing static functions to help procedurally build meshes
  52447. */
  52448. export class LatheBuilder {
  52449. /**
  52450. * Creates lathe mesh.
  52451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52452. * * 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
  52453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52456. * * 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
  52457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52458. * * 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
  52459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52463. * @param name defines the name of the mesh
  52464. * @param options defines the options used to create the mesh
  52465. * @param scene defines the hosting scene
  52466. * @returns the lathe mesh
  52467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52468. */
  52469. static CreateLathe(name: string, options: {
  52470. shape: Vector3[];
  52471. radius?: number;
  52472. tessellation?: number;
  52473. clip?: number;
  52474. arc?: number;
  52475. closed?: boolean;
  52476. updatable?: boolean;
  52477. sideOrientation?: number;
  52478. frontUVs?: Vector4;
  52479. backUVs?: Vector4;
  52480. cap?: number;
  52481. invertUV?: boolean;
  52482. }, scene?: Nullable<Scene>): Mesh;
  52483. }
  52484. }
  52485. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52486. import { Nullable } from "babylonjs/types";
  52487. import { Scene } from "babylonjs/scene";
  52488. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52489. import { Mesh } from "babylonjs/Meshes/mesh";
  52490. /**
  52491. * Class containing static functions to help procedurally build meshes
  52492. */
  52493. export class TubeBuilder {
  52494. /**
  52495. * Creates a tube mesh.
  52496. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52497. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52498. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52499. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52500. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52501. * * 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)
  52502. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52503. * * 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
  52504. * * 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
  52505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52509. * @param name defines the name of the mesh
  52510. * @param options defines the options used to create the mesh
  52511. * @param scene defines the hosting scene
  52512. * @returns the tube mesh
  52513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52514. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52515. */
  52516. static CreateTube(name: string, options: {
  52517. path: Vector3[];
  52518. radius?: number;
  52519. tessellation?: number;
  52520. radiusFunction?: {
  52521. (i: number, distance: number): number;
  52522. };
  52523. cap?: number;
  52524. arc?: number;
  52525. updatable?: boolean;
  52526. sideOrientation?: number;
  52527. frontUVs?: Vector4;
  52528. backUVs?: Vector4;
  52529. instance?: Mesh;
  52530. invertUV?: boolean;
  52531. }, scene?: Nullable<Scene>): Mesh;
  52532. }
  52533. }
  52534. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52535. import { Scene } from "babylonjs/scene";
  52536. import { Vector4 } from "babylonjs/Maths/math";
  52537. import { Mesh } from "babylonjs/Meshes/mesh";
  52538. import { Nullable } from "babylonjs/types";
  52539. /**
  52540. * Class containing static functions to help procedurally build meshes
  52541. */
  52542. export class IcoSphereBuilder {
  52543. /**
  52544. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52545. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52546. * * 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`)
  52547. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52548. * * 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
  52549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52552. * @param name defines the name of the mesh
  52553. * @param options defines the options used to create the mesh
  52554. * @param scene defines the hosting scene
  52555. * @returns the icosahedron mesh
  52556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52557. */
  52558. static CreateIcoSphere(name: string, options: {
  52559. radius?: number;
  52560. radiusX?: number;
  52561. radiusY?: number;
  52562. radiusZ?: number;
  52563. flat?: boolean;
  52564. subdivisions?: number;
  52565. sideOrientation?: number;
  52566. frontUVs?: Vector4;
  52567. backUVs?: Vector4;
  52568. updatable?: boolean;
  52569. }, scene?: Nullable<Scene>): Mesh;
  52570. }
  52571. }
  52572. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52573. import { Vector3 } from "babylonjs/Maths/math";
  52574. import { Mesh } from "babylonjs/Meshes/mesh";
  52575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52576. /**
  52577. * Class containing static functions to help procedurally build meshes
  52578. */
  52579. export class DecalBuilder {
  52580. /**
  52581. * Creates a decal mesh.
  52582. * 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
  52583. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52584. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52585. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52586. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52587. * @param name defines the name of the mesh
  52588. * @param sourceMesh defines the mesh where the decal must be applied
  52589. * @param options defines the options used to create the mesh
  52590. * @param scene defines the hosting scene
  52591. * @returns the decal mesh
  52592. * @see https://doc.babylonjs.com/how_to/decals
  52593. */
  52594. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52595. position?: Vector3;
  52596. normal?: Vector3;
  52597. size?: Vector3;
  52598. angle?: number;
  52599. }): Mesh;
  52600. }
  52601. }
  52602. declare module "babylonjs/Meshes/meshBuilder" {
  52603. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52604. import { Nullable } from "babylonjs/types";
  52605. import { Scene } from "babylonjs/scene";
  52606. import { Mesh } from "babylonjs/Meshes/mesh";
  52607. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52608. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52610. /**
  52611. * Class containing static functions to help procedurally build meshes
  52612. */
  52613. export class MeshBuilder {
  52614. /**
  52615. * Creates a box mesh
  52616. * * The parameter `size` sets the size (float) of each box side (default 1)
  52617. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52618. * * 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)
  52619. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52623. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52624. * @param name defines the name of the mesh
  52625. * @param options defines the options used to create the mesh
  52626. * @param scene defines the hosting scene
  52627. * @returns the box mesh
  52628. */
  52629. static CreateBox(name: string, options: {
  52630. size?: number;
  52631. width?: number;
  52632. height?: number;
  52633. depth?: number;
  52634. faceUV?: Vector4[];
  52635. faceColors?: Color4[];
  52636. sideOrientation?: number;
  52637. frontUVs?: Vector4;
  52638. backUVs?: Vector4;
  52639. updatable?: boolean;
  52640. }, scene?: Nullable<Scene>): Mesh;
  52641. /**
  52642. * Creates a sphere mesh
  52643. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52644. * * 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`)
  52645. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52646. * * 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
  52647. * * 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)
  52648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52651. * @param name defines the name of the mesh
  52652. * @param options defines the options used to create the mesh
  52653. * @param scene defines the hosting scene
  52654. * @returns the sphere mesh
  52655. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52656. */
  52657. static CreateSphere(name: string, options: {
  52658. segments?: number;
  52659. diameter?: number;
  52660. diameterX?: number;
  52661. diameterY?: number;
  52662. diameterZ?: number;
  52663. arc?: number;
  52664. slice?: number;
  52665. sideOrientation?: number;
  52666. frontUVs?: Vector4;
  52667. backUVs?: Vector4;
  52668. updatable?: boolean;
  52669. }, scene?: Nullable<Scene>): Mesh;
  52670. /**
  52671. * Creates a plane polygonal mesh. By default, this is a disc
  52672. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52673. * * 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
  52674. * * 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
  52675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52678. * @param name defines the name of the mesh
  52679. * @param options defines the options used to create the mesh
  52680. * @param scene defines the hosting scene
  52681. * @returns the plane polygonal mesh
  52682. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52683. */
  52684. static CreateDisc(name: string, options: {
  52685. radius?: number;
  52686. tessellation?: number;
  52687. arc?: number;
  52688. updatable?: boolean;
  52689. sideOrientation?: number;
  52690. frontUVs?: Vector4;
  52691. backUVs?: Vector4;
  52692. }, scene?: Nullable<Scene>): Mesh;
  52693. /**
  52694. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52695. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52696. * * 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`)
  52697. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52698. * * 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
  52699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52702. * @param name defines the name of the mesh
  52703. * @param options defines the options used to create the mesh
  52704. * @param scene defines the hosting scene
  52705. * @returns the icosahedron mesh
  52706. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52707. */
  52708. static CreateIcoSphere(name: string, options: {
  52709. radius?: number;
  52710. radiusX?: number;
  52711. radiusY?: number;
  52712. radiusZ?: number;
  52713. flat?: boolean;
  52714. subdivisions?: number;
  52715. sideOrientation?: number;
  52716. frontUVs?: Vector4;
  52717. backUVs?: Vector4;
  52718. updatable?: boolean;
  52719. }, scene?: Nullable<Scene>): Mesh;
  52720. /**
  52721. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52722. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52723. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52724. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52725. * * 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
  52726. * * 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
  52727. * * 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
  52728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52731. * * 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
  52732. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52733. * * 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
  52734. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52736. * @param name defines the name of the mesh
  52737. * @param options defines the options used to create the mesh
  52738. * @param scene defines the hosting scene
  52739. * @returns the ribbon mesh
  52740. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52742. */
  52743. static CreateRibbon(name: string, options: {
  52744. pathArray: Vector3[][];
  52745. closeArray?: boolean;
  52746. closePath?: boolean;
  52747. offset?: number;
  52748. updatable?: boolean;
  52749. sideOrientation?: number;
  52750. frontUVs?: Vector4;
  52751. backUVs?: Vector4;
  52752. instance?: Mesh;
  52753. invertUV?: boolean;
  52754. uvs?: Vector2[];
  52755. colors?: Color4[];
  52756. }, scene?: Nullable<Scene>): Mesh;
  52757. /**
  52758. * Creates a cylinder or a cone mesh
  52759. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52760. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52761. * * 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.
  52762. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52763. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52764. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52765. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52766. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52767. * * 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).
  52768. * * 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
  52769. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52770. * * 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
  52771. * * 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.
  52772. * * If `enclose` is false, a ring surface is one element.
  52773. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52774. * * 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
  52775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52778. * @param name defines the name of the mesh
  52779. * @param options defines the options used to create the mesh
  52780. * @param scene defines the hosting scene
  52781. * @returns the cylinder mesh
  52782. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52783. */
  52784. static CreateCylinder(name: string, options: {
  52785. height?: number;
  52786. diameterTop?: number;
  52787. diameterBottom?: number;
  52788. diameter?: number;
  52789. tessellation?: number;
  52790. subdivisions?: number;
  52791. arc?: number;
  52792. faceColors?: Color4[];
  52793. faceUV?: Vector4[];
  52794. updatable?: boolean;
  52795. hasRings?: boolean;
  52796. enclose?: boolean;
  52797. sideOrientation?: number;
  52798. frontUVs?: Vector4;
  52799. backUVs?: Vector4;
  52800. }, scene?: Nullable<Scene>): Mesh;
  52801. /**
  52802. * Creates a torus mesh
  52803. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52804. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52805. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52809. * @param name defines the name of the mesh
  52810. * @param options defines the options used to create the mesh
  52811. * @param scene defines the hosting scene
  52812. * @returns the torus mesh
  52813. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52814. */
  52815. static CreateTorus(name: string, options: {
  52816. diameter?: number;
  52817. thickness?: number;
  52818. tessellation?: number;
  52819. updatable?: boolean;
  52820. sideOrientation?: number;
  52821. frontUVs?: Vector4;
  52822. backUVs?: Vector4;
  52823. }, scene?: Nullable<Scene>): Mesh;
  52824. /**
  52825. * Creates a torus knot mesh
  52826. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52827. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52828. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52829. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52833. * @param name defines the name of the mesh
  52834. * @param options defines the options used to create the mesh
  52835. * @param scene defines the hosting scene
  52836. * @returns the torus knot mesh
  52837. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52838. */
  52839. static CreateTorusKnot(name: string, options: {
  52840. radius?: number;
  52841. tube?: number;
  52842. radialSegments?: number;
  52843. tubularSegments?: number;
  52844. p?: number;
  52845. q?: number;
  52846. updatable?: boolean;
  52847. sideOrientation?: number;
  52848. frontUVs?: Vector4;
  52849. backUVs?: Vector4;
  52850. }, scene?: Nullable<Scene>): Mesh;
  52851. /**
  52852. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52853. * * 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
  52854. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52855. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52856. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52857. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52858. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52859. * * 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
  52860. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52863. * @param name defines the name of the new line system
  52864. * @param options defines the options used to create the line system
  52865. * @param scene defines the hosting scene
  52866. * @returns a new line system mesh
  52867. */
  52868. static CreateLineSystem(name: string, options: {
  52869. lines: Vector3[][];
  52870. updatable?: boolean;
  52871. instance?: Nullable<LinesMesh>;
  52872. colors?: Nullable<Color4[][]>;
  52873. useVertexAlpha?: boolean;
  52874. }, scene: Nullable<Scene>): LinesMesh;
  52875. /**
  52876. * Creates a line mesh
  52877. * 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
  52878. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52879. * * The parameter `points` is an array successive Vector3
  52880. * * 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
  52881. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52882. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52883. * * When updating an instance, remember that only point positions can change, not the number of points
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52886. * @param name defines the name of the new line system
  52887. * @param options defines the options used to create the line system
  52888. * @param scene defines the hosting scene
  52889. * @returns a new line mesh
  52890. */
  52891. static CreateLines(name: string, options: {
  52892. points: Vector3[];
  52893. updatable?: boolean;
  52894. instance?: Nullable<LinesMesh>;
  52895. colors?: Color4[];
  52896. useVertexAlpha?: boolean;
  52897. }, scene?: Nullable<Scene>): LinesMesh;
  52898. /**
  52899. * Creates a dashed line mesh
  52900. * * 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
  52901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52902. * * The parameter `points` is an array successive Vector3
  52903. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52904. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52905. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52906. * * 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
  52907. * * When updating an instance, remember that only point positions can change, not the number of points
  52908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52909. * @param name defines the name of the mesh
  52910. * @param options defines the options used to create the mesh
  52911. * @param scene defines the hosting scene
  52912. * @returns the dashed line mesh
  52913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52914. */
  52915. static CreateDashedLines(name: string, options: {
  52916. points: Vector3[];
  52917. dashSize?: number;
  52918. gapSize?: number;
  52919. dashNb?: number;
  52920. updatable?: boolean;
  52921. instance?: LinesMesh;
  52922. }, scene?: Nullable<Scene>): LinesMesh;
  52923. /**
  52924. * 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.
  52925. * * 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.
  52926. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52927. * * 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.
  52928. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52929. * * 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
  52930. * * 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
  52931. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52936. * @param name defines the name of the mesh
  52937. * @param options defines the options used to create the mesh
  52938. * @param scene defines the hosting scene
  52939. * @returns the extruded shape mesh
  52940. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52942. */
  52943. static ExtrudeShape(name: string, options: {
  52944. shape: Vector3[];
  52945. path: Vector3[];
  52946. scale?: number;
  52947. rotation?: number;
  52948. cap?: number;
  52949. updatable?: boolean;
  52950. sideOrientation?: number;
  52951. frontUVs?: Vector4;
  52952. backUVs?: Vector4;
  52953. instance?: Mesh;
  52954. invertUV?: boolean;
  52955. }, scene?: Nullable<Scene>): Mesh;
  52956. /**
  52957. * Creates an custom extruded shape mesh.
  52958. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52959. * * 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.
  52960. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52961. * * 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
  52962. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52963. * * 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
  52964. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52965. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52966. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52967. * * 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
  52968. * * 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
  52969. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52972. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52974. * @param name defines the name of the mesh
  52975. * @param options defines the options used to create the mesh
  52976. * @param scene defines the hosting scene
  52977. * @returns the custom extruded shape mesh
  52978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52981. */
  52982. static ExtrudeShapeCustom(name: string, options: {
  52983. shape: Vector3[];
  52984. path: Vector3[];
  52985. scaleFunction?: any;
  52986. rotationFunction?: any;
  52987. ribbonCloseArray?: boolean;
  52988. ribbonClosePath?: boolean;
  52989. cap?: number;
  52990. updatable?: boolean;
  52991. sideOrientation?: number;
  52992. frontUVs?: Vector4;
  52993. backUVs?: Vector4;
  52994. instance?: Mesh;
  52995. invertUV?: boolean;
  52996. }, scene?: Nullable<Scene>): Mesh;
  52997. /**
  52998. * Creates lathe mesh.
  52999. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53000. * * 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
  53001. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53002. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53003. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53004. * * 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
  53005. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53006. * * 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
  53007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53009. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53011. * @param name defines the name of the mesh
  53012. * @param options defines the options used to create the mesh
  53013. * @param scene defines the hosting scene
  53014. * @returns the lathe mesh
  53015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53016. */
  53017. static CreateLathe(name: string, options: {
  53018. shape: Vector3[];
  53019. radius?: number;
  53020. tessellation?: number;
  53021. clip?: number;
  53022. arc?: number;
  53023. closed?: boolean;
  53024. updatable?: boolean;
  53025. sideOrientation?: number;
  53026. frontUVs?: Vector4;
  53027. backUVs?: Vector4;
  53028. cap?: number;
  53029. invertUV?: boolean;
  53030. }, scene?: Nullable<Scene>): Mesh;
  53031. /**
  53032. * Creates a plane mesh
  53033. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53034. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53035. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53039. * @param name defines the name of the mesh
  53040. * @param options defines the options used to create the mesh
  53041. * @param scene defines the hosting scene
  53042. * @returns the plane mesh
  53043. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53044. */
  53045. static CreatePlane(name: string, options: {
  53046. size?: number;
  53047. width?: number;
  53048. height?: number;
  53049. sideOrientation?: number;
  53050. frontUVs?: Vector4;
  53051. backUVs?: Vector4;
  53052. updatable?: boolean;
  53053. sourcePlane?: Plane;
  53054. }, scene?: Nullable<Scene>): Mesh;
  53055. /**
  53056. * Creates a ground mesh
  53057. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53058. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53060. * @param name defines the name of the mesh
  53061. * @param options defines the options used to create the mesh
  53062. * @param scene defines the hosting scene
  53063. * @returns the ground mesh
  53064. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53065. */
  53066. static CreateGround(name: string, options: {
  53067. width?: number;
  53068. height?: number;
  53069. subdivisions?: number;
  53070. subdivisionsX?: number;
  53071. subdivisionsY?: number;
  53072. updatable?: boolean;
  53073. }, scene?: Nullable<Scene>): Mesh;
  53074. /**
  53075. * Creates a tiled ground mesh
  53076. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53077. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53078. * * 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
  53079. * * 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
  53080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53081. * @param name defines the name of the mesh
  53082. * @param options defines the options used to create the mesh
  53083. * @param scene defines the hosting scene
  53084. * @returns the tiled ground mesh
  53085. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53086. */
  53087. static CreateTiledGround(name: string, options: {
  53088. xmin: number;
  53089. zmin: number;
  53090. xmax: number;
  53091. zmax: number;
  53092. subdivisions?: {
  53093. w: number;
  53094. h: number;
  53095. };
  53096. precision?: {
  53097. w: number;
  53098. h: number;
  53099. };
  53100. updatable?: boolean;
  53101. }, scene?: Nullable<Scene>): Mesh;
  53102. /**
  53103. * Creates a ground mesh from a height map
  53104. * * The parameter `url` sets the URL of the height map image resource.
  53105. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53106. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53107. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53108. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53109. * * 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.
  53110. * * 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).
  53111. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53113. * @param name defines the name of the mesh
  53114. * @param url defines the url to the height map
  53115. * @param options defines the options used to create the mesh
  53116. * @param scene defines the hosting scene
  53117. * @returns the ground mesh
  53118. * @see https://doc.babylonjs.com/babylon101/height_map
  53119. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53120. */
  53121. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53122. width?: number;
  53123. height?: number;
  53124. subdivisions?: number;
  53125. minHeight?: number;
  53126. maxHeight?: number;
  53127. colorFilter?: Color3;
  53128. alphaFilter?: number;
  53129. updatable?: boolean;
  53130. onReady?: (mesh: GroundMesh) => void;
  53131. }, scene?: Nullable<Scene>): GroundMesh;
  53132. /**
  53133. * Creates a polygon mesh
  53134. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53135. * * 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
  53136. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  53139. * * Remember you can only change the shape positions, not their number when updating a polygon
  53140. * @param name defines the name of the mesh
  53141. * @param options defines the options used to create the mesh
  53142. * @param scene defines the hosting scene
  53143. * @param earcutInjection can be used to inject your own earcut reference
  53144. * @returns the polygon mesh
  53145. */
  53146. static CreatePolygon(name: string, options: {
  53147. shape: Vector3[];
  53148. holes?: Vector3[][];
  53149. depth?: number;
  53150. faceUV?: Vector4[];
  53151. faceColors?: Color4[];
  53152. updatable?: boolean;
  53153. sideOrientation?: number;
  53154. frontUVs?: Vector4;
  53155. backUVs?: Vector4;
  53156. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53157. /**
  53158. * Creates an extruded polygon mesh, with depth in the Y direction.
  53159. * * 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)
  53160. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53161. * @param name defines the name of the mesh
  53162. * @param options defines the options used to create the mesh
  53163. * @param scene defines the hosting scene
  53164. * @param earcutInjection can be used to inject your own earcut reference
  53165. * @returns the polygon mesh
  53166. */
  53167. static ExtrudePolygon(name: string, options: {
  53168. shape: Vector3[];
  53169. holes?: Vector3[][];
  53170. depth?: number;
  53171. faceUV?: Vector4[];
  53172. faceColors?: Color4[];
  53173. updatable?: boolean;
  53174. sideOrientation?: number;
  53175. frontUVs?: Vector4;
  53176. backUVs?: Vector4;
  53177. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53178. /**
  53179. * Creates a tube mesh.
  53180. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53181. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53182. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53183. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53184. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53185. * * 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)
  53186. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53187. * * 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
  53188. * * 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
  53189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53193. * @param name defines the name of the mesh
  53194. * @param options defines the options used to create the mesh
  53195. * @param scene defines the hosting scene
  53196. * @returns the tube mesh
  53197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53198. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53199. */
  53200. static CreateTube(name: string, options: {
  53201. path: Vector3[];
  53202. radius?: number;
  53203. tessellation?: number;
  53204. radiusFunction?: {
  53205. (i: number, distance: number): number;
  53206. };
  53207. cap?: number;
  53208. arc?: number;
  53209. updatable?: boolean;
  53210. sideOrientation?: number;
  53211. frontUVs?: Vector4;
  53212. backUVs?: Vector4;
  53213. instance?: Mesh;
  53214. invertUV?: boolean;
  53215. }, scene?: Nullable<Scene>): Mesh;
  53216. /**
  53217. * Creates a polyhedron mesh
  53218. * * 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
  53219. * * The parameter `size` (positive float, default 1) sets the polygon size
  53220. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53221. * * 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`
  53222. * * 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
  53223. * * 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)`)
  53224. * * 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
  53225. * * 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
  53226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53229. * @param name defines the name of the mesh
  53230. * @param options defines the options used to create the mesh
  53231. * @param scene defines the hosting scene
  53232. * @returns the polyhedron mesh
  53233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53234. */
  53235. static CreatePolyhedron(name: string, options: {
  53236. type?: number;
  53237. size?: number;
  53238. sizeX?: number;
  53239. sizeY?: number;
  53240. sizeZ?: number;
  53241. custom?: any;
  53242. faceUV?: Vector4[];
  53243. faceColors?: Color4[];
  53244. flat?: boolean;
  53245. updatable?: boolean;
  53246. sideOrientation?: number;
  53247. frontUVs?: Vector4;
  53248. backUVs?: Vector4;
  53249. }, scene?: Nullable<Scene>): Mesh;
  53250. /**
  53251. * Creates a decal mesh.
  53252. * 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
  53253. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53254. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53255. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53256. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53257. * @param name defines the name of the mesh
  53258. * @param sourceMesh defines the mesh where the decal must be applied
  53259. * @param options defines the options used to create the mesh
  53260. * @param scene defines the hosting scene
  53261. * @returns the decal mesh
  53262. * @see https://doc.babylonjs.com/how_to/decals
  53263. */
  53264. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53265. position?: Vector3;
  53266. normal?: Vector3;
  53267. size?: Vector3;
  53268. angle?: number;
  53269. }): Mesh;
  53270. }
  53271. }
  53272. declare module "babylonjs/Meshes/meshSimplification" {
  53273. import { Mesh } from "babylonjs/Meshes/mesh";
  53274. /**
  53275. * A simplifier interface for future simplification implementations
  53276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53277. */
  53278. export interface ISimplifier {
  53279. /**
  53280. * Simplification of a given mesh according to the given settings.
  53281. * Since this requires computation, it is assumed that the function runs async.
  53282. * @param settings The settings of the simplification, including quality and distance
  53283. * @param successCallback A callback that will be called after the mesh was simplified.
  53284. * @param errorCallback in case of an error, this callback will be called. optional.
  53285. */
  53286. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53287. }
  53288. /**
  53289. * Expected simplification settings.
  53290. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53292. */
  53293. export interface ISimplificationSettings {
  53294. /**
  53295. * Gets or sets the expected quality
  53296. */
  53297. quality: number;
  53298. /**
  53299. * Gets or sets the distance when this optimized version should be used
  53300. */
  53301. distance: number;
  53302. /**
  53303. * Gets an already optimized mesh
  53304. */
  53305. optimizeMesh?: boolean;
  53306. }
  53307. /**
  53308. * Class used to specify simplification options
  53309. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53310. */
  53311. export class SimplificationSettings implements ISimplificationSettings {
  53312. /** expected quality */
  53313. quality: number;
  53314. /** distance when this optimized version should be used */
  53315. distance: number;
  53316. /** already optimized mesh */
  53317. optimizeMesh?: boolean | undefined;
  53318. /**
  53319. * Creates a SimplificationSettings
  53320. * @param quality expected quality
  53321. * @param distance distance when this optimized version should be used
  53322. * @param optimizeMesh already optimized mesh
  53323. */
  53324. constructor(
  53325. /** expected quality */
  53326. quality: number,
  53327. /** distance when this optimized version should be used */
  53328. distance: number,
  53329. /** already optimized mesh */
  53330. optimizeMesh?: boolean | undefined);
  53331. }
  53332. /**
  53333. * Interface used to define a simplification task
  53334. */
  53335. export interface ISimplificationTask {
  53336. /**
  53337. * Array of settings
  53338. */
  53339. settings: Array<ISimplificationSettings>;
  53340. /**
  53341. * Simplification type
  53342. */
  53343. simplificationType: SimplificationType;
  53344. /**
  53345. * Mesh to simplify
  53346. */
  53347. mesh: Mesh;
  53348. /**
  53349. * Callback called on success
  53350. */
  53351. successCallback?: () => void;
  53352. /**
  53353. * Defines if parallel processing can be used
  53354. */
  53355. parallelProcessing: boolean;
  53356. }
  53357. /**
  53358. * Queue used to order the simplification tasks
  53359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53360. */
  53361. export class SimplificationQueue {
  53362. private _simplificationArray;
  53363. /**
  53364. * Gets a boolean indicating that the process is still running
  53365. */
  53366. running: boolean;
  53367. /**
  53368. * Creates a new queue
  53369. */
  53370. constructor();
  53371. /**
  53372. * Adds a new simplification task
  53373. * @param task defines a task to add
  53374. */
  53375. addTask(task: ISimplificationTask): void;
  53376. /**
  53377. * Execute next task
  53378. */
  53379. executeNext(): void;
  53380. /**
  53381. * Execute a simplification task
  53382. * @param task defines the task to run
  53383. */
  53384. runSimplification(task: ISimplificationTask): void;
  53385. private getSimplifier;
  53386. }
  53387. /**
  53388. * The implemented types of simplification
  53389. * At the moment only Quadratic Error Decimation is implemented
  53390. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53391. */
  53392. export enum SimplificationType {
  53393. /** Quadratic error decimation */
  53394. QUADRATIC = 0
  53395. }
  53396. }
  53397. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53398. import { Scene } from "babylonjs/scene";
  53399. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53400. import { ISceneComponent } from "babylonjs/sceneComponent";
  53401. module "babylonjs/scene" {
  53402. interface Scene {
  53403. /** @hidden (Backing field) */
  53404. _simplificationQueue: SimplificationQueue;
  53405. /**
  53406. * Gets or sets the simplification queue attached to the scene
  53407. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53408. */
  53409. simplificationQueue: SimplificationQueue;
  53410. }
  53411. }
  53412. module "babylonjs/Meshes/mesh" {
  53413. interface Mesh {
  53414. /**
  53415. * Simplify the mesh according to the given array of settings.
  53416. * Function will return immediately and will simplify async
  53417. * @param settings a collection of simplification settings
  53418. * @param parallelProcessing should all levels calculate parallel or one after the other
  53419. * @param simplificationType the type of simplification to run
  53420. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53421. * @returns the current mesh
  53422. */
  53423. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53424. }
  53425. }
  53426. /**
  53427. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53428. * created in a scene
  53429. */
  53430. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53431. /**
  53432. * The component name helpfull to identify the component in the list of scene components.
  53433. */
  53434. readonly name: string;
  53435. /**
  53436. * The scene the component belongs to.
  53437. */
  53438. scene: Scene;
  53439. /**
  53440. * Creates a new instance of the component for the given scene
  53441. * @param scene Defines the scene to register the component in
  53442. */
  53443. constructor(scene: Scene);
  53444. /**
  53445. * Registers the component in a given scene
  53446. */
  53447. register(): void;
  53448. /**
  53449. * Rebuilds the elements related to this component in case of
  53450. * context lost for instance.
  53451. */
  53452. rebuild(): void;
  53453. /**
  53454. * Disposes the component and the associated ressources
  53455. */
  53456. dispose(): void;
  53457. private _beforeCameraUpdate;
  53458. }
  53459. }
  53460. declare module "babylonjs/Meshes/Builders/index" {
  53461. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53462. export * from "babylonjs/Meshes/Builders/discBuilder";
  53463. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53464. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53465. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53466. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53467. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53468. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53469. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53470. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53471. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53472. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53473. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53474. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53475. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53476. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53477. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53478. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53479. }
  53480. declare module "babylonjs/Meshes/index" {
  53481. export * from "babylonjs/Meshes/abstractMesh";
  53482. export * from "babylonjs/Meshes/buffer";
  53483. export * from "babylonjs/Meshes/Compression/index";
  53484. export * from "babylonjs/Meshes/csg";
  53485. export * from "babylonjs/Meshes/geometry";
  53486. export * from "babylonjs/Meshes/groundMesh";
  53487. export * from "babylonjs/Meshes/trailMesh";
  53488. export * from "babylonjs/Meshes/instancedMesh";
  53489. export * from "babylonjs/Meshes/linesMesh";
  53490. export * from "babylonjs/Meshes/mesh";
  53491. export * from "babylonjs/Meshes/mesh.vertexData";
  53492. export * from "babylonjs/Meshes/meshBuilder";
  53493. export * from "babylonjs/Meshes/meshSimplification";
  53494. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53495. export * from "babylonjs/Meshes/polygonMesh";
  53496. export * from "babylonjs/Meshes/subMesh";
  53497. export * from "babylonjs/Meshes/meshLODLevel";
  53498. export * from "babylonjs/Meshes/transformNode";
  53499. export * from "babylonjs/Meshes/Builders/index";
  53500. export * from "babylonjs/Meshes/dataBuffer";
  53501. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  53502. }
  53503. declare module "babylonjs/Morph/index" {
  53504. export * from "babylonjs/Morph/morphTarget";
  53505. export * from "babylonjs/Morph/morphTargetManager";
  53506. }
  53507. declare module "babylonjs/Offline/database" {
  53508. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53509. /**
  53510. * Class used to enable access to IndexedDB
  53511. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53512. */
  53513. export class Database implements IOfflineProvider {
  53514. private _callbackManifestChecked;
  53515. private _currentSceneUrl;
  53516. private _db;
  53517. private _enableSceneOffline;
  53518. private _enableTexturesOffline;
  53519. private _manifestVersionFound;
  53520. private _mustUpdateRessources;
  53521. private _hasReachedQuota;
  53522. private _isSupported;
  53523. private _idbFactory;
  53524. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53525. private static IsUASupportingBlobStorage;
  53526. /**
  53527. * Gets a boolean indicating if Database storate is enabled (off by default)
  53528. */
  53529. static IDBStorageEnabled: boolean;
  53530. /**
  53531. * Gets a boolean indicating if scene must be saved in the database
  53532. */
  53533. readonly enableSceneOffline: boolean;
  53534. /**
  53535. * Gets a boolean indicating if textures must be saved in the database
  53536. */
  53537. readonly enableTexturesOffline: boolean;
  53538. /**
  53539. * Creates a new Database
  53540. * @param urlToScene defines the url to load the scene
  53541. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53542. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53543. */
  53544. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53545. private static _ParseURL;
  53546. private static _ReturnFullUrlLocation;
  53547. private _checkManifestFile;
  53548. /**
  53549. * Open the database and make it available
  53550. * @param successCallback defines the callback to call on success
  53551. * @param errorCallback defines the callback to call on error
  53552. */
  53553. open(successCallback: () => void, errorCallback: () => void): void;
  53554. /**
  53555. * Loads an image from the database
  53556. * @param url defines the url to load from
  53557. * @param image defines the target DOM image
  53558. */
  53559. loadImage(url: string, image: HTMLImageElement): void;
  53560. private _loadImageFromDBAsync;
  53561. private _saveImageIntoDBAsync;
  53562. private _checkVersionFromDB;
  53563. private _loadVersionFromDBAsync;
  53564. private _saveVersionIntoDBAsync;
  53565. /**
  53566. * Loads a file from database
  53567. * @param url defines the URL to load from
  53568. * @param sceneLoaded defines a callback to call on success
  53569. * @param progressCallBack defines a callback to call when progress changed
  53570. * @param errorCallback defines a callback to call on error
  53571. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53572. */
  53573. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53574. private _loadFileAsync;
  53575. private _saveFileAsync;
  53576. /**
  53577. * Validates if xhr data is correct
  53578. * @param xhr defines the request to validate
  53579. * @param dataType defines the expected data type
  53580. * @returns true if data is correct
  53581. */
  53582. private static _ValidateXHRData;
  53583. }
  53584. }
  53585. declare module "babylonjs/Offline/index" {
  53586. export * from "babylonjs/Offline/database";
  53587. export * from "babylonjs/Offline/IOfflineProvider";
  53588. }
  53589. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53590. /** @hidden */
  53591. export var gpuUpdateParticlesPixelShader: {
  53592. name: string;
  53593. shader: string;
  53594. };
  53595. }
  53596. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53597. /** @hidden */
  53598. export var gpuUpdateParticlesVertexShader: {
  53599. name: string;
  53600. shader: string;
  53601. };
  53602. }
  53603. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53604. /** @hidden */
  53605. export var clipPlaneFragmentDeclaration2: {
  53606. name: string;
  53607. shader: string;
  53608. };
  53609. }
  53610. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53611. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53612. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53613. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53614. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53615. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53616. /** @hidden */
  53617. export var gpuRenderParticlesPixelShader: {
  53618. name: string;
  53619. shader: string;
  53620. };
  53621. }
  53622. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53623. /** @hidden */
  53624. export var clipPlaneVertexDeclaration2: {
  53625. name: string;
  53626. shader: string;
  53627. };
  53628. }
  53629. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53631. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53632. /** @hidden */
  53633. export var gpuRenderParticlesVertexShader: {
  53634. name: string;
  53635. shader: string;
  53636. };
  53637. }
  53638. declare module "babylonjs/Particles/gpuParticleSystem" {
  53639. import { Nullable } from "babylonjs/types";
  53640. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53641. import { Observable } from "babylonjs/Misc/observable";
  53642. import { Color4, Color3 } from "babylonjs/Maths/math";
  53643. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53644. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53645. import { Scene, IDisposable } from "babylonjs/scene";
  53646. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53647. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53648. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53649. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53650. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53651. /**
  53652. * This represents a GPU particle system in Babylon
  53653. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53654. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53655. */
  53656. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53657. /**
  53658. * The layer mask we are rendering the particles through.
  53659. */
  53660. layerMask: number;
  53661. private _capacity;
  53662. private _activeCount;
  53663. private _currentActiveCount;
  53664. private _accumulatedCount;
  53665. private _renderEffect;
  53666. private _updateEffect;
  53667. private _buffer0;
  53668. private _buffer1;
  53669. private _spriteBuffer;
  53670. private _updateVAO;
  53671. private _renderVAO;
  53672. private _targetIndex;
  53673. private _sourceBuffer;
  53674. private _targetBuffer;
  53675. private _engine;
  53676. private _currentRenderId;
  53677. private _started;
  53678. private _stopped;
  53679. private _timeDelta;
  53680. private _randomTexture;
  53681. private _randomTexture2;
  53682. private _attributesStrideSize;
  53683. private _updateEffectOptions;
  53684. private _randomTextureSize;
  53685. private _actualFrame;
  53686. private readonly _rawTextureWidth;
  53687. /**
  53688. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53689. */
  53690. static readonly IsSupported: boolean;
  53691. /**
  53692. * An event triggered when the system is disposed.
  53693. */
  53694. onDisposeObservable: Observable<GPUParticleSystem>;
  53695. /**
  53696. * Gets the maximum number of particles active at the same time.
  53697. * @returns The max number of active particles.
  53698. */
  53699. getCapacity(): number;
  53700. /**
  53701. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53702. * to override the particles.
  53703. */
  53704. forceDepthWrite: boolean;
  53705. /**
  53706. * Gets or set the number of active particles
  53707. */
  53708. activeParticleCount: number;
  53709. private _preWarmDone;
  53710. /**
  53711. * Is this system ready to be used/rendered
  53712. * @return true if the system is ready
  53713. */
  53714. isReady(): boolean;
  53715. /**
  53716. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53717. * @returns True if it has been started, otherwise false.
  53718. */
  53719. isStarted(): boolean;
  53720. /**
  53721. * Starts the particle system and begins to emit
  53722. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53723. */
  53724. start(delay?: number): void;
  53725. /**
  53726. * Stops the particle system.
  53727. */
  53728. stop(): void;
  53729. /**
  53730. * Remove all active particles
  53731. */
  53732. reset(): void;
  53733. /**
  53734. * Returns the string "GPUParticleSystem"
  53735. * @returns a string containing the class name
  53736. */
  53737. getClassName(): string;
  53738. private _colorGradientsTexture;
  53739. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53740. /**
  53741. * Adds a new color gradient
  53742. * @param gradient defines the gradient to use (between 0 and 1)
  53743. * @param color1 defines the color to affect to the specified gradient
  53744. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53745. * @returns the current particle system
  53746. */
  53747. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53748. /**
  53749. * Remove a specific color gradient
  53750. * @param gradient defines the gradient to remove
  53751. * @returns the current particle system
  53752. */
  53753. removeColorGradient(gradient: number): GPUParticleSystem;
  53754. private _angularSpeedGradientsTexture;
  53755. private _sizeGradientsTexture;
  53756. private _velocityGradientsTexture;
  53757. private _limitVelocityGradientsTexture;
  53758. private _dragGradientsTexture;
  53759. private _addFactorGradient;
  53760. /**
  53761. * Adds a new size gradient
  53762. * @param gradient defines the gradient to use (between 0 and 1)
  53763. * @param factor defines the size factor to affect to the specified gradient
  53764. * @returns the current particle system
  53765. */
  53766. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53767. /**
  53768. * Remove a specific size gradient
  53769. * @param gradient defines the gradient to remove
  53770. * @returns the current particle system
  53771. */
  53772. removeSizeGradient(gradient: number): GPUParticleSystem;
  53773. /**
  53774. * Adds a new angular speed gradient
  53775. * @param gradient defines the gradient to use (between 0 and 1)
  53776. * @param factor defines the angular speed to affect to the specified gradient
  53777. * @returns the current particle system
  53778. */
  53779. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53780. /**
  53781. * Remove a specific angular speed gradient
  53782. * @param gradient defines the gradient to remove
  53783. * @returns the current particle system
  53784. */
  53785. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53786. /**
  53787. * Adds a new velocity gradient
  53788. * @param gradient defines the gradient to use (between 0 and 1)
  53789. * @param factor defines the velocity to affect to the specified gradient
  53790. * @returns the current particle system
  53791. */
  53792. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53793. /**
  53794. * Remove a specific velocity gradient
  53795. * @param gradient defines the gradient to remove
  53796. * @returns the current particle system
  53797. */
  53798. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53799. /**
  53800. * Adds a new limit velocity gradient
  53801. * @param gradient defines the gradient to use (between 0 and 1)
  53802. * @param factor defines the limit velocity value to affect to the specified gradient
  53803. * @returns the current particle system
  53804. */
  53805. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53806. /**
  53807. * Remove a specific limit velocity gradient
  53808. * @param gradient defines the gradient to remove
  53809. * @returns the current particle system
  53810. */
  53811. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53812. /**
  53813. * Adds a new drag gradient
  53814. * @param gradient defines the gradient to use (between 0 and 1)
  53815. * @param factor defines the drag value to affect to the specified gradient
  53816. * @returns the current particle system
  53817. */
  53818. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53819. /**
  53820. * Remove a specific drag gradient
  53821. * @param gradient defines the gradient to remove
  53822. * @returns the current particle system
  53823. */
  53824. removeDragGradient(gradient: number): GPUParticleSystem;
  53825. /**
  53826. * Not supported by GPUParticleSystem
  53827. * @param gradient defines the gradient to use (between 0 and 1)
  53828. * @param factor defines the emit rate value to affect to the specified gradient
  53829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53830. * @returns the current particle system
  53831. */
  53832. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53833. /**
  53834. * Not supported by GPUParticleSystem
  53835. * @param gradient defines the gradient to remove
  53836. * @returns the current particle system
  53837. */
  53838. removeEmitRateGradient(gradient: number): IParticleSystem;
  53839. /**
  53840. * Not supported by GPUParticleSystem
  53841. * @param gradient defines the gradient to use (between 0 and 1)
  53842. * @param factor defines the start size value to affect to the specified gradient
  53843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53844. * @returns the current particle system
  53845. */
  53846. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53847. /**
  53848. * Not supported by GPUParticleSystem
  53849. * @param gradient defines the gradient to remove
  53850. * @returns the current particle system
  53851. */
  53852. removeStartSizeGradient(gradient: number): IParticleSystem;
  53853. /**
  53854. * Not supported by GPUParticleSystem
  53855. * @param gradient defines the gradient to use (between 0 and 1)
  53856. * @param min defines the color remap minimal range
  53857. * @param max defines the color remap maximal range
  53858. * @returns the current particle system
  53859. */
  53860. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53861. /**
  53862. * Not supported by GPUParticleSystem
  53863. * @param gradient defines the gradient to remove
  53864. * @returns the current particle system
  53865. */
  53866. removeColorRemapGradient(): IParticleSystem;
  53867. /**
  53868. * Not supported by GPUParticleSystem
  53869. * @param gradient defines the gradient to use (between 0 and 1)
  53870. * @param min defines the alpha remap minimal range
  53871. * @param max defines the alpha remap maximal range
  53872. * @returns the current particle system
  53873. */
  53874. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53875. /**
  53876. * Not supported by GPUParticleSystem
  53877. * @param gradient defines the gradient to remove
  53878. * @returns the current particle system
  53879. */
  53880. removeAlphaRemapGradient(): IParticleSystem;
  53881. /**
  53882. * Not supported by GPUParticleSystem
  53883. * @param gradient defines the gradient to use (between 0 and 1)
  53884. * @param color defines the color to affect to the specified gradient
  53885. * @returns the current particle system
  53886. */
  53887. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53888. /**
  53889. * Not supported by GPUParticleSystem
  53890. * @param gradient defines the gradient to remove
  53891. * @returns the current particle system
  53892. */
  53893. removeRampGradient(): IParticleSystem;
  53894. /**
  53895. * Not supported by GPUParticleSystem
  53896. * @returns the list of ramp gradients
  53897. */
  53898. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53899. /**
  53900. * Not supported by GPUParticleSystem
  53901. * Gets or sets a boolean indicating that ramp gradients must be used
  53902. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53903. */
  53904. useRampGradients: boolean;
  53905. /**
  53906. * Not supported by GPUParticleSystem
  53907. * @param gradient defines the gradient to use (between 0 and 1)
  53908. * @param factor defines the life time factor to affect to the specified gradient
  53909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53910. * @returns the current particle system
  53911. */
  53912. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53913. /**
  53914. * Not supported by GPUParticleSystem
  53915. * @param gradient defines the gradient to remove
  53916. * @returns the current particle system
  53917. */
  53918. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53919. /**
  53920. * Instantiates a GPU particle system.
  53921. * 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.
  53922. * @param name The name of the particle system
  53923. * @param options The options used to create the system
  53924. * @param scene The scene the particle system belongs to
  53925. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53926. */
  53927. constructor(name: string, options: Partial<{
  53928. capacity: number;
  53929. randomTextureSize: number;
  53930. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53931. protected _reset(): void;
  53932. private _createUpdateVAO;
  53933. private _createRenderVAO;
  53934. private _initialize;
  53935. /** @hidden */
  53936. _recreateUpdateEffect(): void;
  53937. /** @hidden */
  53938. _recreateRenderEffect(): void;
  53939. /**
  53940. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53941. * @param preWarm defines if we are in the pre-warmimg phase
  53942. */
  53943. animate(preWarm?: boolean): void;
  53944. private _createFactorGradientTexture;
  53945. private _createSizeGradientTexture;
  53946. private _createAngularSpeedGradientTexture;
  53947. private _createVelocityGradientTexture;
  53948. private _createLimitVelocityGradientTexture;
  53949. private _createDragGradientTexture;
  53950. private _createColorGradientTexture;
  53951. /**
  53952. * Renders the particle system in its current state
  53953. * @param preWarm defines if the system should only update the particles but not render them
  53954. * @returns the current number of particles
  53955. */
  53956. render(preWarm?: boolean): number;
  53957. /**
  53958. * Rebuilds the particle system
  53959. */
  53960. rebuild(): void;
  53961. private _releaseBuffers;
  53962. private _releaseVAOs;
  53963. /**
  53964. * Disposes the particle system and free the associated resources
  53965. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53966. */
  53967. dispose(disposeTexture?: boolean): void;
  53968. /**
  53969. * Clones the particle system.
  53970. * @param name The name of the cloned object
  53971. * @param newEmitter The new emitter to use
  53972. * @returns the cloned particle system
  53973. */
  53974. clone(name: string, newEmitter: any): GPUParticleSystem;
  53975. /**
  53976. * Serializes the particle system to a JSON object.
  53977. * @returns the JSON object
  53978. */
  53979. serialize(): any;
  53980. /**
  53981. * Parses a JSON object to create a GPU particle system.
  53982. * @param parsedParticleSystem The JSON object to parse
  53983. * @param scene The scene to create the particle system in
  53984. * @param rootUrl The root url to use to load external dependencies like texture
  53985. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53986. * @returns the parsed GPU particle system
  53987. */
  53988. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53989. }
  53990. }
  53991. declare module "babylonjs/Particles/particleSystemSet" {
  53992. import { Nullable } from "babylonjs/types";
  53993. import { Color3 } from "babylonjs/Maths/math";
  53994. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53996. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53997. import { Scene, IDisposable } from "babylonjs/scene";
  53998. /**
  53999. * Represents a set of particle systems working together to create a specific effect
  54000. */
  54001. export class ParticleSystemSet implements IDisposable {
  54002. private _emitterCreationOptions;
  54003. private _emitterNode;
  54004. /**
  54005. * Gets the particle system list
  54006. */
  54007. systems: IParticleSystem[];
  54008. /**
  54009. * Gets the emitter node used with this set
  54010. */
  54011. readonly emitterNode: Nullable<TransformNode>;
  54012. /**
  54013. * Creates a new emitter mesh as a sphere
  54014. * @param options defines the options used to create the sphere
  54015. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54016. * @param scene defines the hosting scene
  54017. */
  54018. setEmitterAsSphere(options: {
  54019. diameter: number;
  54020. segments: number;
  54021. color: Color3;
  54022. }, renderingGroupId: number, scene: Scene): void;
  54023. /**
  54024. * Starts all particle systems of the set
  54025. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54026. */
  54027. start(emitter?: AbstractMesh): void;
  54028. /**
  54029. * Release all associated resources
  54030. */
  54031. dispose(): void;
  54032. /**
  54033. * Serialize the set into a JSON compatible object
  54034. * @returns a JSON compatible representation of the set
  54035. */
  54036. serialize(): any;
  54037. /**
  54038. * Parse a new ParticleSystemSet from a serialized source
  54039. * @param data defines a JSON compatible representation of the set
  54040. * @param scene defines the hosting scene
  54041. * @param gpu defines if we want GPU particles or CPU particles
  54042. * @returns a new ParticleSystemSet
  54043. */
  54044. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54045. }
  54046. }
  54047. declare module "babylonjs/Particles/particleHelper" {
  54048. import { Nullable } from "babylonjs/types";
  54049. import { Scene } from "babylonjs/scene";
  54050. import { Vector3 } from "babylonjs/Maths/math";
  54051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54052. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54053. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  54054. /**
  54055. * This class is made for on one-liner static method to help creating particle system set.
  54056. */
  54057. export class ParticleHelper {
  54058. /**
  54059. * Gets or sets base Assets URL
  54060. */
  54061. static BaseAssetsUrl: string;
  54062. /**
  54063. * Create a default particle system that you can tweak
  54064. * @param emitter defines the emitter to use
  54065. * @param capacity defines the system capacity (default is 500 particles)
  54066. * @param scene defines the hosting scene
  54067. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54068. * @returns the new Particle system
  54069. */
  54070. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54071. /**
  54072. * This is the main static method (one-liner) of this helper to create different particle systems
  54073. * @param type This string represents the type to the particle system to create
  54074. * @param scene The scene where the particle system should live
  54075. * @param gpu If the system will use gpu
  54076. * @returns the ParticleSystemSet created
  54077. */
  54078. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54079. /**
  54080. * Static function used to export a particle system to a ParticleSystemSet variable.
  54081. * Please note that the emitter shape is not exported
  54082. * @param systems defines the particle systems to export
  54083. * @returns the created particle system set
  54084. */
  54085. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54086. }
  54087. }
  54088. declare module "babylonjs/Particles/particleSystemComponent" {
  54089. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54090. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54091. import "babylonjs/Shaders/particles.vertex";
  54092. module "babylonjs/Engines/engine" {
  54093. interface Engine {
  54094. /**
  54095. * Create an effect to use with particle systems.
  54096. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54097. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54098. * @param uniformsNames defines a list of attribute names
  54099. * @param samplers defines an array of string used to represent textures
  54100. * @param defines defines the string containing the defines to use to compile the shaders
  54101. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54102. * @param onCompiled defines a function to call when the effect creation is successful
  54103. * @param onError defines a function to call when the effect creation has failed
  54104. * @returns the new Effect
  54105. */
  54106. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54107. }
  54108. }
  54109. module "babylonjs/Meshes/mesh" {
  54110. interface Mesh {
  54111. /**
  54112. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54113. * @returns an array of IParticleSystem
  54114. */
  54115. getEmittedParticleSystems(): IParticleSystem[];
  54116. /**
  54117. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54118. * @returns an array of IParticleSystem
  54119. */
  54120. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54121. }
  54122. }
  54123. /**
  54124. * @hidden
  54125. */
  54126. export var _IDoNeedToBeInTheBuild: number;
  54127. }
  54128. declare module "babylonjs/Particles/index" {
  54129. export * from "babylonjs/Particles/baseParticleSystem";
  54130. export * from "babylonjs/Particles/EmitterTypes/index";
  54131. export * from "babylonjs/Particles/gpuParticleSystem";
  54132. export * from "babylonjs/Particles/IParticleSystem";
  54133. export * from "babylonjs/Particles/particle";
  54134. export * from "babylonjs/Particles/particleHelper";
  54135. export * from "babylonjs/Particles/particleSystem";
  54136. export * from "babylonjs/Particles/particleSystemComponent";
  54137. export * from "babylonjs/Particles/particleSystemSet";
  54138. export * from "babylonjs/Particles/solidParticle";
  54139. export * from "babylonjs/Particles/solidParticleSystem";
  54140. export * from "babylonjs/Particles/subEmitter";
  54141. }
  54142. declare module "babylonjs/Physics/physicsEngineComponent" {
  54143. import { Nullable } from "babylonjs/types";
  54144. import { Observable, Observer } from "babylonjs/Misc/observable";
  54145. import { Vector3 } from "babylonjs/Maths/math";
  54146. import { Mesh } from "babylonjs/Meshes/mesh";
  54147. import { ISceneComponent } from "babylonjs/sceneComponent";
  54148. import { Scene } from "babylonjs/scene";
  54149. import { Node } from "babylonjs/node";
  54150. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54151. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54152. module "babylonjs/scene" {
  54153. interface Scene {
  54154. /** @hidden (Backing field) */
  54155. _physicsEngine: Nullable<IPhysicsEngine>;
  54156. /**
  54157. * Gets the current physics engine
  54158. * @returns a IPhysicsEngine or null if none attached
  54159. */
  54160. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54161. /**
  54162. * Enables physics to the current scene
  54163. * @param gravity defines the scene's gravity for the physics engine
  54164. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54165. * @return a boolean indicating if the physics engine was initialized
  54166. */
  54167. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54168. /**
  54169. * Disables and disposes the physics engine associated with the scene
  54170. */
  54171. disablePhysicsEngine(): void;
  54172. /**
  54173. * Gets a boolean indicating if there is an active physics engine
  54174. * @returns a boolean indicating if there is an active physics engine
  54175. */
  54176. isPhysicsEnabled(): boolean;
  54177. /**
  54178. * Deletes a physics compound impostor
  54179. * @param compound defines the compound to delete
  54180. */
  54181. deleteCompoundImpostor(compound: any): void;
  54182. /**
  54183. * An event triggered when physic simulation is about to be run
  54184. */
  54185. onBeforePhysicsObservable: Observable<Scene>;
  54186. /**
  54187. * An event triggered when physic simulation has been done
  54188. */
  54189. onAfterPhysicsObservable: Observable<Scene>;
  54190. }
  54191. }
  54192. module "babylonjs/Meshes/abstractMesh" {
  54193. interface AbstractMesh {
  54194. /** @hidden */
  54195. _physicsImpostor: Nullable<PhysicsImpostor>;
  54196. /**
  54197. * Gets or sets impostor used for physic simulation
  54198. * @see http://doc.babylonjs.com/features/physics_engine
  54199. */
  54200. physicsImpostor: Nullable<PhysicsImpostor>;
  54201. /**
  54202. * Gets the current physics impostor
  54203. * @see http://doc.babylonjs.com/features/physics_engine
  54204. * @returns a physics impostor or null
  54205. */
  54206. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54207. /** Apply a physic impulse to the mesh
  54208. * @param force defines the force to apply
  54209. * @param contactPoint defines where to apply the force
  54210. * @returns the current mesh
  54211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54212. */
  54213. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54214. /**
  54215. * Creates a physic joint between two meshes
  54216. * @param otherMesh defines the other mesh to use
  54217. * @param pivot1 defines the pivot to use on this mesh
  54218. * @param pivot2 defines the pivot to use on the other mesh
  54219. * @param options defines additional options (can be plugin dependent)
  54220. * @returns the current mesh
  54221. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54222. */
  54223. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54224. /** @hidden */
  54225. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54226. }
  54227. }
  54228. /**
  54229. * Defines the physics engine scene component responsible to manage a physics engine
  54230. */
  54231. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54232. /**
  54233. * The component name helpful to identify the component in the list of scene components.
  54234. */
  54235. readonly name: string;
  54236. /**
  54237. * The scene the component belongs to.
  54238. */
  54239. scene: Scene;
  54240. /**
  54241. * Creates a new instance of the component for the given scene
  54242. * @param scene Defines the scene to register the component in
  54243. */
  54244. constructor(scene: Scene);
  54245. /**
  54246. * Registers the component in a given scene
  54247. */
  54248. register(): void;
  54249. /**
  54250. * Rebuilds the elements related to this component in case of
  54251. * context lost for instance.
  54252. */
  54253. rebuild(): void;
  54254. /**
  54255. * Disposes the component and the associated ressources
  54256. */
  54257. dispose(): void;
  54258. }
  54259. }
  54260. declare module "babylonjs/Physics/physicsHelper" {
  54261. import { Nullable } from "babylonjs/types";
  54262. import { Vector3 } from "babylonjs/Maths/math";
  54263. import { Mesh } from "babylonjs/Meshes/mesh";
  54264. import { Scene } from "babylonjs/scene";
  54265. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54266. /**
  54267. * A helper for physics simulations
  54268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54269. */
  54270. export class PhysicsHelper {
  54271. private _scene;
  54272. private _physicsEngine;
  54273. /**
  54274. * Initializes the Physics helper
  54275. * @param scene Babylon.js scene
  54276. */
  54277. constructor(scene: Scene);
  54278. /**
  54279. * Applies a radial explosion impulse
  54280. * @param origin the origin of the explosion
  54281. * @param radiusOrEventOptions the radius or the options of radial explosion
  54282. * @param strength the explosion strength
  54283. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54284. * @returns A physics radial explosion event, or null
  54285. */
  54286. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54287. /**
  54288. * Applies a radial explosion force
  54289. * @param origin the origin of the explosion
  54290. * @param radiusOrEventOptions the radius or the options of radial explosion
  54291. * @param strength the explosion strength
  54292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54293. * @returns A physics radial explosion event, or null
  54294. */
  54295. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54296. /**
  54297. * Creates a gravitational field
  54298. * @param origin the origin of the explosion
  54299. * @param radiusOrEventOptions the radius or the options of radial explosion
  54300. * @param strength the explosion strength
  54301. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54302. * @returns A physics gravitational field event, or null
  54303. */
  54304. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54305. /**
  54306. * Creates a physics updraft event
  54307. * @param origin the origin of the updraft
  54308. * @param radiusOrEventOptions the radius or the options of the updraft
  54309. * @param strength the strength of the updraft
  54310. * @param height the height of the updraft
  54311. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54312. * @returns A physics updraft event, or null
  54313. */
  54314. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54315. /**
  54316. * Creates a physics vortex event
  54317. * @param origin the of the vortex
  54318. * @param radiusOrEventOptions the radius or the options of the vortex
  54319. * @param strength the strength of the vortex
  54320. * @param height the height of the vortex
  54321. * @returns a Physics vortex event, or null
  54322. * A physics vortex event or null
  54323. */
  54324. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54325. }
  54326. /**
  54327. * Represents a physics radial explosion event
  54328. */
  54329. class PhysicsRadialExplosionEvent {
  54330. private _scene;
  54331. private _options;
  54332. private _sphere;
  54333. private _dataFetched;
  54334. /**
  54335. * Initializes a radial explosioin event
  54336. * @param _scene BabylonJS scene
  54337. * @param _options The options for the vortex event
  54338. */
  54339. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54340. /**
  54341. * Returns the data related to the radial explosion event (sphere).
  54342. * @returns The radial explosion event data
  54343. */
  54344. getData(): PhysicsRadialExplosionEventData;
  54345. /**
  54346. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54347. * @param impostor A physics imposter
  54348. * @param origin the origin of the explosion
  54349. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54350. */
  54351. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54352. /**
  54353. * Triggers affecterd impostors callbacks
  54354. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54355. */
  54356. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54357. /**
  54358. * Disposes the sphere.
  54359. * @param force Specifies if the sphere should be disposed by force
  54360. */
  54361. dispose(force?: boolean): void;
  54362. /*** Helpers ***/
  54363. private _prepareSphere;
  54364. private _intersectsWithSphere;
  54365. }
  54366. /**
  54367. * Represents a gravitational field event
  54368. */
  54369. class PhysicsGravitationalFieldEvent {
  54370. private _physicsHelper;
  54371. private _scene;
  54372. private _origin;
  54373. private _options;
  54374. private _tickCallback;
  54375. private _sphere;
  54376. private _dataFetched;
  54377. /**
  54378. * Initializes the physics gravitational field event
  54379. * @param _physicsHelper A physics helper
  54380. * @param _scene BabylonJS scene
  54381. * @param _origin The origin position of the gravitational field event
  54382. * @param _options The options for the vortex event
  54383. */
  54384. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54385. /**
  54386. * Returns the data related to the gravitational field event (sphere).
  54387. * @returns A gravitational field event
  54388. */
  54389. getData(): PhysicsGravitationalFieldEventData;
  54390. /**
  54391. * Enables the gravitational field.
  54392. */
  54393. enable(): void;
  54394. /**
  54395. * Disables the gravitational field.
  54396. */
  54397. disable(): void;
  54398. /**
  54399. * Disposes the sphere.
  54400. * @param force The force to dispose from the gravitational field event
  54401. */
  54402. dispose(force?: boolean): void;
  54403. private _tick;
  54404. }
  54405. /**
  54406. * Represents a physics updraft event
  54407. */
  54408. class PhysicsUpdraftEvent {
  54409. private _scene;
  54410. private _origin;
  54411. private _options;
  54412. private _physicsEngine;
  54413. private _originTop;
  54414. private _originDirection;
  54415. private _tickCallback;
  54416. private _cylinder;
  54417. private _cylinderPosition;
  54418. private _dataFetched;
  54419. /**
  54420. * Initializes the physics updraft event
  54421. * @param _scene BabylonJS scene
  54422. * @param _origin The origin position of the updraft
  54423. * @param _options The options for the updraft event
  54424. */
  54425. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54426. /**
  54427. * Returns the data related to the updraft event (cylinder).
  54428. * @returns A physics updraft event
  54429. */
  54430. getData(): PhysicsUpdraftEventData;
  54431. /**
  54432. * Enables the updraft.
  54433. */
  54434. enable(): void;
  54435. /**
  54436. * Disables the updraft.
  54437. */
  54438. disable(): void;
  54439. /**
  54440. * Disposes the cylinder.
  54441. * @param force Specifies if the updraft should be disposed by force
  54442. */
  54443. dispose(force?: boolean): void;
  54444. private getImpostorHitData;
  54445. private _tick;
  54446. /*** Helpers ***/
  54447. private _prepareCylinder;
  54448. private _intersectsWithCylinder;
  54449. }
  54450. /**
  54451. * Represents a physics vortex event
  54452. */
  54453. class PhysicsVortexEvent {
  54454. private _scene;
  54455. private _origin;
  54456. private _options;
  54457. private _physicsEngine;
  54458. private _originTop;
  54459. private _tickCallback;
  54460. private _cylinder;
  54461. private _cylinderPosition;
  54462. private _dataFetched;
  54463. /**
  54464. * Initializes the physics vortex event
  54465. * @param _scene The BabylonJS scene
  54466. * @param _origin The origin position of the vortex
  54467. * @param _options The options for the vortex event
  54468. */
  54469. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54470. /**
  54471. * Returns the data related to the vortex event (cylinder).
  54472. * @returns The physics vortex event data
  54473. */
  54474. getData(): PhysicsVortexEventData;
  54475. /**
  54476. * Enables the vortex.
  54477. */
  54478. enable(): void;
  54479. /**
  54480. * Disables the cortex.
  54481. */
  54482. disable(): void;
  54483. /**
  54484. * Disposes the sphere.
  54485. * @param force
  54486. */
  54487. dispose(force?: boolean): void;
  54488. private getImpostorHitData;
  54489. private _tick;
  54490. /*** Helpers ***/
  54491. private _prepareCylinder;
  54492. private _intersectsWithCylinder;
  54493. }
  54494. /**
  54495. * Options fot the radial explosion event
  54496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54497. */
  54498. export class PhysicsRadialExplosionEventOptions {
  54499. /**
  54500. * The radius of the sphere for the radial explosion.
  54501. */
  54502. radius: number;
  54503. /**
  54504. * The strenth of the explosion.
  54505. */
  54506. strength: number;
  54507. /**
  54508. * The strenght of the force in correspondence to the distance of the affected object
  54509. */
  54510. falloff: PhysicsRadialImpulseFalloff;
  54511. /**
  54512. * Sphere options for the radial explosion.
  54513. */
  54514. sphere: {
  54515. segments: number;
  54516. diameter: number;
  54517. };
  54518. /**
  54519. * Sphere options for the radial explosion.
  54520. */
  54521. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54522. }
  54523. /**
  54524. * Options fot the updraft event
  54525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54526. */
  54527. export class PhysicsUpdraftEventOptions {
  54528. /**
  54529. * The radius of the cylinder for the vortex
  54530. */
  54531. radius: number;
  54532. /**
  54533. * The strenth of the updraft.
  54534. */
  54535. strength: number;
  54536. /**
  54537. * The height of the cylinder for the updraft.
  54538. */
  54539. height: number;
  54540. /**
  54541. * The mode for the the updraft.
  54542. */
  54543. updraftMode: PhysicsUpdraftMode;
  54544. }
  54545. /**
  54546. * Options fot the vortex event
  54547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54548. */
  54549. export class PhysicsVortexEventOptions {
  54550. /**
  54551. * The radius of the cylinder for the vortex
  54552. */
  54553. radius: number;
  54554. /**
  54555. * The strenth of the vortex.
  54556. */
  54557. strength: number;
  54558. /**
  54559. * The height of the cylinder for the vortex.
  54560. */
  54561. height: number;
  54562. /**
  54563. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54564. */
  54565. centripetalForceThreshold: number;
  54566. /**
  54567. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54568. */
  54569. centripetalForceMultiplier: number;
  54570. /**
  54571. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54572. */
  54573. centrifugalForceMultiplier: number;
  54574. /**
  54575. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54576. */
  54577. updraftForceMultiplier: number;
  54578. }
  54579. /**
  54580. * The strenght of the force in correspondence to the distance of the affected object
  54581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54582. */
  54583. export enum PhysicsRadialImpulseFalloff {
  54584. /** Defines that impulse is constant in strength across it's whole radius */
  54585. Constant = 0,
  54586. /** Defines that impulse gets weaker if it's further from the origin */
  54587. Linear = 1
  54588. }
  54589. /**
  54590. * The strength of the force in correspondence to the distance of the affected object
  54591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54592. */
  54593. export enum PhysicsUpdraftMode {
  54594. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54595. Center = 0,
  54596. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54597. Perpendicular = 1
  54598. }
  54599. /**
  54600. * Interface for a physics hit data
  54601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54602. */
  54603. export interface PhysicsHitData {
  54604. /**
  54605. * The force applied at the contact point
  54606. */
  54607. force: Vector3;
  54608. /**
  54609. * The contact point
  54610. */
  54611. contactPoint: Vector3;
  54612. /**
  54613. * The distance from the origin to the contact point
  54614. */
  54615. distanceFromOrigin: number;
  54616. }
  54617. /**
  54618. * Interface for radial explosion event data
  54619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54620. */
  54621. export interface PhysicsRadialExplosionEventData {
  54622. /**
  54623. * A sphere used for the radial explosion event
  54624. */
  54625. sphere: Mesh;
  54626. }
  54627. /**
  54628. * Interface for gravitational field event data
  54629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54630. */
  54631. export interface PhysicsGravitationalFieldEventData {
  54632. /**
  54633. * A sphere mesh used for the gravitational field event
  54634. */
  54635. sphere: Mesh;
  54636. }
  54637. /**
  54638. * Interface for updraft event data
  54639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54640. */
  54641. export interface PhysicsUpdraftEventData {
  54642. /**
  54643. * A cylinder used for the updraft event
  54644. */
  54645. cylinder: Mesh;
  54646. }
  54647. /**
  54648. * Interface for vortex event data
  54649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54650. */
  54651. export interface PhysicsVortexEventData {
  54652. /**
  54653. * A cylinder used for the vortex event
  54654. */
  54655. cylinder: Mesh;
  54656. }
  54657. /**
  54658. * Interface for an affected physics impostor
  54659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54660. */
  54661. export interface PhysicsAffectedImpostorWithData {
  54662. /**
  54663. * The impostor affected by the effect
  54664. */
  54665. impostor: PhysicsImpostor;
  54666. /**
  54667. * The data about the hit/horce from the explosion
  54668. */
  54669. hitData: PhysicsHitData;
  54670. }
  54671. }
  54672. declare module "babylonjs/Physics/Plugins/index" {
  54673. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54674. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54675. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54676. }
  54677. declare module "babylonjs/Physics/index" {
  54678. export * from "babylonjs/Physics/IPhysicsEngine";
  54679. export * from "babylonjs/Physics/physicsEngine";
  54680. export * from "babylonjs/Physics/physicsEngineComponent";
  54681. export * from "babylonjs/Physics/physicsHelper";
  54682. export * from "babylonjs/Physics/physicsImpostor";
  54683. export * from "babylonjs/Physics/physicsJoint";
  54684. export * from "babylonjs/Physics/Plugins/index";
  54685. }
  54686. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54687. /** @hidden */
  54688. export var blackAndWhitePixelShader: {
  54689. name: string;
  54690. shader: string;
  54691. };
  54692. }
  54693. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54695. import { Camera } from "babylonjs/Cameras/camera";
  54696. import { Engine } from "babylonjs/Engines/engine";
  54697. import "babylonjs/Shaders/blackAndWhite.fragment";
  54698. /**
  54699. * Post process used to render in black and white
  54700. */
  54701. export class BlackAndWhitePostProcess extends PostProcess {
  54702. /**
  54703. * Linear about to convert he result to black and white (default: 1)
  54704. */
  54705. degree: number;
  54706. /**
  54707. * Creates a black and white post process
  54708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54709. * @param name The name of the effect.
  54710. * @param options The required width/height ratio to downsize to before computing the render pass.
  54711. * @param camera The camera to apply the render pass to.
  54712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54713. * @param engine The engine which the post process will be applied. (default: current engine)
  54714. * @param reusable If the post process can be reused on the same frame. (default: false)
  54715. */
  54716. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54717. }
  54718. }
  54719. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54720. import { Nullable } from "babylonjs/types";
  54721. import { Camera } from "babylonjs/Cameras/camera";
  54722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54723. import { Engine } from "babylonjs/Engines/engine";
  54724. /**
  54725. * This represents a set of one or more post processes in Babylon.
  54726. * A post process can be used to apply a shader to a texture after it is rendered.
  54727. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54728. */
  54729. export class PostProcessRenderEffect {
  54730. private _postProcesses;
  54731. private _getPostProcesses;
  54732. private _singleInstance;
  54733. private _cameras;
  54734. private _indicesForCamera;
  54735. /**
  54736. * Name of the effect
  54737. * @hidden
  54738. */
  54739. _name: string;
  54740. /**
  54741. * Instantiates a post process render effect.
  54742. * A post process can be used to apply a shader to a texture after it is rendered.
  54743. * @param engine The engine the effect is tied to
  54744. * @param name The name of the effect
  54745. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54746. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54747. */
  54748. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54749. /**
  54750. * Checks if all the post processes in the effect are supported.
  54751. */
  54752. readonly isSupported: boolean;
  54753. /**
  54754. * Updates the current state of the effect
  54755. * @hidden
  54756. */
  54757. _update(): void;
  54758. /**
  54759. * Attaches the effect on cameras
  54760. * @param cameras The camera to attach to.
  54761. * @hidden
  54762. */
  54763. _attachCameras(cameras: Camera): void;
  54764. /**
  54765. * Attaches the effect on cameras
  54766. * @param cameras The camera to attach to.
  54767. * @hidden
  54768. */
  54769. _attachCameras(cameras: Camera[]): void;
  54770. /**
  54771. * Detaches the effect on cameras
  54772. * @param cameras The camera to detatch from.
  54773. * @hidden
  54774. */
  54775. _detachCameras(cameras: Camera): void;
  54776. /**
  54777. * Detatches the effect on cameras
  54778. * @param cameras The camera to detatch from.
  54779. * @hidden
  54780. */
  54781. _detachCameras(cameras: Camera[]): void;
  54782. /**
  54783. * Enables the effect on given cameras
  54784. * @param cameras The camera to enable.
  54785. * @hidden
  54786. */
  54787. _enable(cameras: Camera): void;
  54788. /**
  54789. * Enables the effect on given cameras
  54790. * @param cameras The camera to enable.
  54791. * @hidden
  54792. */
  54793. _enable(cameras: Nullable<Camera[]>): void;
  54794. /**
  54795. * Disables the effect on the given cameras
  54796. * @param cameras The camera to disable.
  54797. * @hidden
  54798. */
  54799. _disable(cameras: Camera): void;
  54800. /**
  54801. * Disables the effect on the given cameras
  54802. * @param cameras The camera to disable.
  54803. * @hidden
  54804. */
  54805. _disable(cameras: Nullable<Camera[]>): void;
  54806. /**
  54807. * Gets a list of the post processes contained in the effect.
  54808. * @param camera The camera to get the post processes on.
  54809. * @returns The list of the post processes in the effect.
  54810. */
  54811. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54812. }
  54813. }
  54814. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54815. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54816. /** @hidden */
  54817. export var extractHighlightsPixelShader: {
  54818. name: string;
  54819. shader: string;
  54820. };
  54821. }
  54822. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54823. import { Nullable } from "babylonjs/types";
  54824. import { Camera } from "babylonjs/Cameras/camera";
  54825. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54826. import { Engine } from "babylonjs/Engines/engine";
  54827. import "babylonjs/Shaders/extractHighlights.fragment";
  54828. /**
  54829. * 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.
  54830. */
  54831. export class ExtractHighlightsPostProcess extends PostProcess {
  54832. /**
  54833. * The luminance threshold, pixels below this value will be set to black.
  54834. */
  54835. threshold: number;
  54836. /** @hidden */
  54837. _exposure: number;
  54838. /**
  54839. * Post process which has the input texture to be used when performing highlight extraction
  54840. * @hidden
  54841. */
  54842. _inputPostProcess: Nullable<PostProcess>;
  54843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54844. }
  54845. }
  54846. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54847. /** @hidden */
  54848. export var bloomMergePixelShader: {
  54849. name: string;
  54850. shader: string;
  54851. };
  54852. }
  54853. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54855. import { Nullable } from "babylonjs/types";
  54856. import { Engine } from "babylonjs/Engines/engine";
  54857. import { Camera } from "babylonjs/Cameras/camera";
  54858. import "babylonjs/Shaders/bloomMerge.fragment";
  54859. /**
  54860. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54861. */
  54862. export class BloomMergePostProcess extends PostProcess {
  54863. /** Weight of the bloom to be added to the original input. */
  54864. weight: number;
  54865. /**
  54866. * Creates a new instance of @see BloomMergePostProcess
  54867. * @param name The name of the effect.
  54868. * @param originalFromInput Post process which's input will be used for the merge.
  54869. * @param blurred Blurred highlights post process which's output will be used.
  54870. * @param weight Weight of the bloom to be added to the original input.
  54871. * @param options The required width/height ratio to downsize to before computing the render pass.
  54872. * @param camera The camera to apply the render pass to.
  54873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54874. * @param engine The engine which the post process will be applied. (default: current engine)
  54875. * @param reusable If the post process can be reused on the same frame. (default: false)
  54876. * @param textureType Type of textures used when performing the post process. (default: 0)
  54877. * @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)
  54878. */
  54879. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54880. /** Weight of the bloom to be added to the original input. */
  54881. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54882. }
  54883. }
  54884. declare module "babylonjs/PostProcesses/bloomEffect" {
  54885. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54887. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54888. import { Camera } from "babylonjs/Cameras/camera";
  54889. import { Scene } from "babylonjs/scene";
  54890. /**
  54891. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54892. */
  54893. export class BloomEffect extends PostProcessRenderEffect {
  54894. private bloomScale;
  54895. /**
  54896. * @hidden Internal
  54897. */
  54898. _effects: Array<PostProcess>;
  54899. /**
  54900. * @hidden Internal
  54901. */
  54902. _downscale: ExtractHighlightsPostProcess;
  54903. private _blurX;
  54904. private _blurY;
  54905. private _merge;
  54906. /**
  54907. * The luminance threshold to find bright areas of the image to bloom.
  54908. */
  54909. threshold: number;
  54910. /**
  54911. * The strength of the bloom.
  54912. */
  54913. weight: number;
  54914. /**
  54915. * Specifies the size of the bloom blur kernel, relative to the final output size
  54916. */
  54917. kernel: number;
  54918. /**
  54919. * Creates a new instance of @see BloomEffect
  54920. * @param scene The scene the effect belongs to.
  54921. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54922. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54923. * @param bloomWeight The the strength of bloom.
  54924. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54925. * @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)
  54926. */
  54927. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54928. /**
  54929. * Disposes each of the internal effects for a given camera.
  54930. * @param camera The camera to dispose the effect on.
  54931. */
  54932. disposeEffects(camera: Camera): void;
  54933. /**
  54934. * @hidden Internal
  54935. */
  54936. _updateEffects(): void;
  54937. /**
  54938. * Internal
  54939. * @returns if all the contained post processes are ready.
  54940. * @hidden
  54941. */
  54942. _isReady(): boolean;
  54943. }
  54944. }
  54945. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54946. /** @hidden */
  54947. export var chromaticAberrationPixelShader: {
  54948. name: string;
  54949. shader: string;
  54950. };
  54951. }
  54952. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54953. import { Vector2 } from "babylonjs/Maths/math";
  54954. import { Nullable } from "babylonjs/types";
  54955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54956. import { Camera } from "babylonjs/Cameras/camera";
  54957. import { Engine } from "babylonjs/Engines/engine";
  54958. import "babylonjs/Shaders/chromaticAberration.fragment";
  54959. /**
  54960. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54961. */
  54962. export class ChromaticAberrationPostProcess extends PostProcess {
  54963. /**
  54964. * The amount of seperation of rgb channels (default: 30)
  54965. */
  54966. aberrationAmount: number;
  54967. /**
  54968. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54969. */
  54970. radialIntensity: number;
  54971. /**
  54972. * 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))
  54973. */
  54974. direction: Vector2;
  54975. /**
  54976. * 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))
  54977. */
  54978. centerPosition: Vector2;
  54979. /**
  54980. * Creates a new instance ChromaticAberrationPostProcess
  54981. * @param name The name of the effect.
  54982. * @param screenWidth The width of the screen to apply the effect on.
  54983. * @param screenHeight The height of the screen to apply the effect on.
  54984. * @param options The required width/height ratio to downsize to before computing the render pass.
  54985. * @param camera The camera to apply the render pass to.
  54986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54987. * @param engine The engine which the post process will be applied. (default: current engine)
  54988. * @param reusable If the post process can be reused on the same frame. (default: false)
  54989. * @param textureType Type of textures used when performing the post process. (default: 0)
  54990. * @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)
  54991. */
  54992. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54993. }
  54994. }
  54995. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54996. /** @hidden */
  54997. export var circleOfConfusionPixelShader: {
  54998. name: string;
  54999. shader: string;
  55000. };
  55001. }
  55002. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  55003. import { Nullable } from "babylonjs/types";
  55004. import { Engine } from "babylonjs/Engines/engine";
  55005. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55007. import { Camera } from "babylonjs/Cameras/camera";
  55008. import "babylonjs/Shaders/circleOfConfusion.fragment";
  55009. /**
  55010. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55011. */
  55012. export class CircleOfConfusionPostProcess extends PostProcess {
  55013. /**
  55014. * 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.
  55015. */
  55016. lensSize: number;
  55017. /**
  55018. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55019. */
  55020. fStop: number;
  55021. /**
  55022. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55023. */
  55024. focusDistance: number;
  55025. /**
  55026. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55027. */
  55028. focalLength: number;
  55029. private _depthTexture;
  55030. /**
  55031. * Creates a new instance CircleOfConfusionPostProcess
  55032. * @param name The name of the effect.
  55033. * @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.
  55034. * @param options The required width/height ratio to downsize to before computing the render pass.
  55035. * @param camera The camera to apply the render pass to.
  55036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55037. * @param engine The engine which the post process will be applied. (default: current engine)
  55038. * @param reusable If the post process can be reused on the same frame. (default: false)
  55039. * @param textureType Type of textures used when performing the post process. (default: 0)
  55040. * @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)
  55041. */
  55042. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55043. /**
  55044. * 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.
  55045. */
  55046. depthTexture: RenderTargetTexture;
  55047. }
  55048. }
  55049. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  55050. /** @hidden */
  55051. export var colorCorrectionPixelShader: {
  55052. name: string;
  55053. shader: string;
  55054. };
  55055. }
  55056. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  55057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55058. import { Engine } from "babylonjs/Engines/engine";
  55059. import { Camera } from "babylonjs/Cameras/camera";
  55060. import "babylonjs/Shaders/colorCorrection.fragment";
  55061. /**
  55062. *
  55063. * This post-process allows the modification of rendered colors by using
  55064. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55065. *
  55066. * The object needs to be provided an url to a texture containing the color
  55067. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55068. * Use an image editing software to tweak the LUT to match your needs.
  55069. *
  55070. * For an example of a color LUT, see here:
  55071. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55072. * For explanations on color grading, see here:
  55073. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55074. *
  55075. */
  55076. export class ColorCorrectionPostProcess extends PostProcess {
  55077. private _colorTableTexture;
  55078. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55079. }
  55080. }
  55081. declare module "babylonjs/Shaders/convolution.fragment" {
  55082. /** @hidden */
  55083. export var convolutionPixelShader: {
  55084. name: string;
  55085. shader: string;
  55086. };
  55087. }
  55088. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  55089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55090. import { Nullable } from "babylonjs/types";
  55091. import { Camera } from "babylonjs/Cameras/camera";
  55092. import { Engine } from "babylonjs/Engines/engine";
  55093. import "babylonjs/Shaders/convolution.fragment";
  55094. /**
  55095. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55096. * input texture to perform effects such as edge detection or sharpening
  55097. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55098. */
  55099. export class ConvolutionPostProcess extends PostProcess {
  55100. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55101. kernel: number[];
  55102. /**
  55103. * Creates a new instance ConvolutionPostProcess
  55104. * @param name The name of the effect.
  55105. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  55106. * @param options The required width/height ratio to downsize to before computing the render pass.
  55107. * @param camera The camera to apply the render pass to.
  55108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55109. * @param engine The engine which the post process will be applied. (default: current engine)
  55110. * @param reusable If the post process can be reused on the same frame. (default: false)
  55111. * @param textureType Type of textures used when performing the post process. (default: 0)
  55112. */
  55113. constructor(name: string,
  55114. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  55115. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55116. /**
  55117. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55118. */
  55119. static EdgeDetect0Kernel: number[];
  55120. /**
  55121. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55122. */
  55123. static EdgeDetect1Kernel: number[];
  55124. /**
  55125. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55126. */
  55127. static EdgeDetect2Kernel: number[];
  55128. /**
  55129. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55130. */
  55131. static SharpenKernel: number[];
  55132. /**
  55133. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55134. */
  55135. static EmbossKernel: number[];
  55136. /**
  55137. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55138. */
  55139. static GaussianKernel: number[];
  55140. }
  55141. }
  55142. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  55143. import { Nullable } from "babylonjs/types";
  55144. import { Vector2 } from "babylonjs/Maths/math";
  55145. import { Camera } from "babylonjs/Cameras/camera";
  55146. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55147. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55148. import { Engine } from "babylonjs/Engines/engine";
  55149. import { Scene } from "babylonjs/scene";
  55150. /**
  55151. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55152. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55153. * based on samples that have a large difference in distance than the center pixel.
  55154. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55155. */
  55156. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55157. direction: Vector2;
  55158. /**
  55159. * Creates a new instance CircleOfConfusionPostProcess
  55160. * @param name The name of the effect.
  55161. * @param scene The scene the effect belongs to.
  55162. * @param direction The direction the blur should be applied.
  55163. * @param kernel The size of the kernel used to blur.
  55164. * @param options The required width/height ratio to downsize to before computing the render pass.
  55165. * @param camera The camera to apply the render pass to.
  55166. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55167. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55169. * @param engine The engine which the post process will be applied. (default: current engine)
  55170. * @param reusable If the post process can be reused on the same frame. (default: false)
  55171. * @param textureType Type of textures used when performing the post process. (default: 0)
  55172. * @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)
  55173. */
  55174. 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);
  55175. }
  55176. }
  55177. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  55178. /** @hidden */
  55179. export var depthOfFieldMergePixelShader: {
  55180. name: string;
  55181. shader: string;
  55182. };
  55183. }
  55184. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  55185. import { Nullable } from "babylonjs/types";
  55186. import { Camera } from "babylonjs/Cameras/camera";
  55187. import { Effect } from "babylonjs/Materials/effect";
  55188. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55189. import { Engine } from "babylonjs/Engines/engine";
  55190. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  55191. /**
  55192. * Options to be set when merging outputs from the default pipeline.
  55193. */
  55194. export class DepthOfFieldMergePostProcessOptions {
  55195. /**
  55196. * The original image to merge on top of
  55197. */
  55198. originalFromInput: PostProcess;
  55199. /**
  55200. * Parameters to perform the merge of the depth of field effect
  55201. */
  55202. depthOfField?: {
  55203. circleOfConfusion: PostProcess;
  55204. blurSteps: Array<PostProcess>;
  55205. };
  55206. /**
  55207. * Parameters to perform the merge of bloom effect
  55208. */
  55209. bloom?: {
  55210. blurred: PostProcess;
  55211. weight: number;
  55212. };
  55213. }
  55214. /**
  55215. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55216. */
  55217. export class DepthOfFieldMergePostProcess extends PostProcess {
  55218. private blurSteps;
  55219. /**
  55220. * Creates a new instance of DepthOfFieldMergePostProcess
  55221. * @param name The name of the effect.
  55222. * @param originalFromInput Post process which's input will be used for the merge.
  55223. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55224. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55225. * @param options The required width/height ratio to downsize to before computing the render pass.
  55226. * @param camera The camera to apply the render pass to.
  55227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55228. * @param engine The engine which the post process will be applied. (default: current engine)
  55229. * @param reusable If the post process can be reused on the same frame. (default: false)
  55230. * @param textureType Type of textures used when performing the post process. (default: 0)
  55231. * @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)
  55232. */
  55233. 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);
  55234. /**
  55235. * Updates the effect with the current post process compile time values and recompiles the shader.
  55236. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55237. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55238. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55239. * @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
  55240. * @param onCompiled Called when the shader has been compiled.
  55241. * @param onError Called if there is an error when compiling a shader.
  55242. */
  55243. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55244. }
  55245. }
  55246. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  55247. import { Nullable } from "babylonjs/types";
  55248. import { Camera } from "babylonjs/Cameras/camera";
  55249. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55250. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55251. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55252. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55253. import { Scene } from "babylonjs/scene";
  55254. /**
  55255. * Specifies the level of max blur that should be applied when using the depth of field effect
  55256. */
  55257. export enum DepthOfFieldEffectBlurLevel {
  55258. /**
  55259. * Subtle blur
  55260. */
  55261. Low = 0,
  55262. /**
  55263. * Medium blur
  55264. */
  55265. Medium = 1,
  55266. /**
  55267. * Large blur
  55268. */
  55269. High = 2
  55270. }
  55271. /**
  55272. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55273. */
  55274. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55275. private _circleOfConfusion;
  55276. /**
  55277. * @hidden Internal, blurs from high to low
  55278. */
  55279. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55280. private _depthOfFieldBlurY;
  55281. private _dofMerge;
  55282. /**
  55283. * @hidden Internal post processes in depth of field effect
  55284. */
  55285. _effects: Array<PostProcess>;
  55286. /**
  55287. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55288. */
  55289. focalLength: number;
  55290. /**
  55291. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55292. */
  55293. fStop: number;
  55294. /**
  55295. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55296. */
  55297. focusDistance: number;
  55298. /**
  55299. * 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.
  55300. */
  55301. lensSize: number;
  55302. /**
  55303. * Creates a new instance DepthOfFieldEffect
  55304. * @param scene The scene the effect belongs to.
  55305. * @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.
  55306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55307. * @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)
  55308. */
  55309. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55310. /**
  55311. * Get the current class name of the current effet
  55312. * @returns "DepthOfFieldEffect"
  55313. */
  55314. getClassName(): string;
  55315. /**
  55316. * 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.
  55317. */
  55318. depthTexture: RenderTargetTexture;
  55319. /**
  55320. * Disposes each of the internal effects for a given camera.
  55321. * @param camera The camera to dispose the effect on.
  55322. */
  55323. disposeEffects(camera: Camera): void;
  55324. /**
  55325. * @hidden Internal
  55326. */
  55327. _updateEffects(): void;
  55328. /**
  55329. * Internal
  55330. * @returns if all the contained post processes are ready.
  55331. * @hidden
  55332. */
  55333. _isReady(): boolean;
  55334. }
  55335. }
  55336. declare module "babylonjs/Shaders/displayPass.fragment" {
  55337. /** @hidden */
  55338. export var displayPassPixelShader: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  55344. import { Nullable } from "babylonjs/types";
  55345. import { Camera } from "babylonjs/Cameras/camera";
  55346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55347. import { Engine } from "babylonjs/Engines/engine";
  55348. import "babylonjs/Shaders/displayPass.fragment";
  55349. /**
  55350. * DisplayPassPostProcess which produces an output the same as it's input
  55351. */
  55352. export class DisplayPassPostProcess extends PostProcess {
  55353. /**
  55354. * Creates the DisplayPassPostProcess
  55355. * @param name The name of the effect.
  55356. * @param options The required width/height ratio to downsize to before computing the render pass.
  55357. * @param camera The camera to apply the render pass to.
  55358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55359. * @param engine The engine which the post process will be applied. (default: current engine)
  55360. * @param reusable If the post process can be reused on the same frame. (default: false)
  55361. */
  55362. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55363. }
  55364. }
  55365. declare module "babylonjs/Shaders/filter.fragment" {
  55366. /** @hidden */
  55367. export var filterPixelShader: {
  55368. name: string;
  55369. shader: string;
  55370. };
  55371. }
  55372. declare module "babylonjs/PostProcesses/filterPostProcess" {
  55373. import { Nullable } from "babylonjs/types";
  55374. import { Matrix } from "babylonjs/Maths/math";
  55375. import { Camera } from "babylonjs/Cameras/camera";
  55376. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55377. import { Engine } from "babylonjs/Engines/engine";
  55378. import "babylonjs/Shaders/filter.fragment";
  55379. /**
  55380. * Applies a kernel filter to the image
  55381. */
  55382. export class FilterPostProcess extends PostProcess {
  55383. /** The matrix to be applied to the image */
  55384. kernelMatrix: Matrix;
  55385. /**
  55386. *
  55387. * @param name The name of the effect.
  55388. * @param kernelMatrix The matrix to be applied to the image
  55389. * @param options The required width/height ratio to downsize to before computing the render pass.
  55390. * @param camera The camera to apply the render pass to.
  55391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55392. * @param engine The engine which the post process will be applied. (default: current engine)
  55393. * @param reusable If the post process can be reused on the same frame. (default: false)
  55394. */
  55395. constructor(name: string,
  55396. /** The matrix to be applied to the image */
  55397. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55398. }
  55399. }
  55400. declare module "babylonjs/Shaders/fxaa.fragment" {
  55401. /** @hidden */
  55402. export var fxaaPixelShader: {
  55403. name: string;
  55404. shader: string;
  55405. };
  55406. }
  55407. declare module "babylonjs/Shaders/fxaa.vertex" {
  55408. /** @hidden */
  55409. export var fxaaVertexShader: {
  55410. name: string;
  55411. shader: string;
  55412. };
  55413. }
  55414. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55415. import { Nullable } from "babylonjs/types";
  55416. import { Camera } from "babylonjs/Cameras/camera";
  55417. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55418. import { Engine } from "babylonjs/Engines/engine";
  55419. import "babylonjs/Shaders/fxaa.fragment";
  55420. import "babylonjs/Shaders/fxaa.vertex";
  55421. /**
  55422. * Fxaa post process
  55423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55424. */
  55425. export class FxaaPostProcess extends PostProcess {
  55426. /** @hidden */
  55427. texelWidth: number;
  55428. /** @hidden */
  55429. texelHeight: number;
  55430. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55431. private _getDefines;
  55432. }
  55433. }
  55434. declare module "babylonjs/Shaders/grain.fragment" {
  55435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55436. /** @hidden */
  55437. export var grainPixelShader: {
  55438. name: string;
  55439. shader: string;
  55440. };
  55441. }
  55442. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55443. import { Nullable } from "babylonjs/types";
  55444. import { Camera } from "babylonjs/Cameras/camera";
  55445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55446. import { Engine } from "babylonjs/Engines/engine";
  55447. import "babylonjs/Shaders/grain.fragment";
  55448. /**
  55449. * The GrainPostProcess adds noise to the image at mid luminance levels
  55450. */
  55451. export class GrainPostProcess extends PostProcess {
  55452. /**
  55453. * The intensity of the grain added (default: 30)
  55454. */
  55455. intensity: number;
  55456. /**
  55457. * If the grain should be randomized on every frame
  55458. */
  55459. animated: boolean;
  55460. /**
  55461. * Creates a new instance of @see GrainPostProcess
  55462. * @param name The name of the effect.
  55463. * @param options The required width/height ratio to downsize to before computing the render pass.
  55464. * @param camera The camera to apply the render pass to.
  55465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55466. * @param engine The engine which the post process will be applied. (default: current engine)
  55467. * @param reusable If the post process can be reused on the same frame. (default: false)
  55468. * @param textureType Type of textures used when performing the post process. (default: 0)
  55469. * @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)
  55470. */
  55471. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55472. }
  55473. }
  55474. declare module "babylonjs/Shaders/highlights.fragment" {
  55475. /** @hidden */
  55476. export var highlightsPixelShader: {
  55477. name: string;
  55478. shader: string;
  55479. };
  55480. }
  55481. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55482. import { Nullable } from "babylonjs/types";
  55483. import { Camera } from "babylonjs/Cameras/camera";
  55484. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55485. import { Engine } from "babylonjs/Engines/engine";
  55486. import "babylonjs/Shaders/highlights.fragment";
  55487. /**
  55488. * Extracts highlights from the image
  55489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55490. */
  55491. export class HighlightsPostProcess extends PostProcess {
  55492. /**
  55493. * Extracts highlights from the image
  55494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55495. * @param name The name of the effect.
  55496. * @param options The required width/height ratio to downsize to before computing the render pass.
  55497. * @param camera The camera to apply the render pass to.
  55498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55499. * @param engine The engine which the post process will be applied. (default: current engine)
  55500. * @param reusable If the post process can be reused on the same frame. (default: false)
  55501. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55502. */
  55503. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55504. }
  55505. }
  55506. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55507. /** @hidden */
  55508. export var mrtFragmentDeclaration: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module "babylonjs/Shaders/geometry.fragment" {
  55514. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55515. /** @hidden */
  55516. export var geometryPixelShader: {
  55517. name: string;
  55518. shader: string;
  55519. };
  55520. }
  55521. declare module "babylonjs/Shaders/geometry.vertex" {
  55522. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55523. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55524. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55525. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55526. /** @hidden */
  55527. export var geometryVertexShader: {
  55528. name: string;
  55529. shader: string;
  55530. };
  55531. }
  55532. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55533. import { Matrix } from "babylonjs/Maths/math";
  55534. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55535. import { Mesh } from "babylonjs/Meshes/mesh";
  55536. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55537. import { Effect } from "babylonjs/Materials/effect";
  55538. import { Scene } from "babylonjs/scene";
  55539. import "babylonjs/Shaders/geometry.fragment";
  55540. import "babylonjs/Shaders/geometry.vertex";
  55541. /**
  55542. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55543. */
  55544. export class GeometryBufferRenderer {
  55545. /**
  55546. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55547. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55548. */
  55549. static readonly POSITION_TEXTURE_TYPE: number;
  55550. /**
  55551. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55552. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55553. */
  55554. static readonly VELOCITY_TEXTURE_TYPE: number;
  55555. /**
  55556. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55557. * in order to compute objects velocities when enableVelocity is set to "true"
  55558. * @hidden
  55559. */
  55560. _previousTransformationMatrices: {
  55561. [index: number]: Matrix;
  55562. };
  55563. private _scene;
  55564. private _multiRenderTarget;
  55565. private _ratio;
  55566. private _enablePosition;
  55567. private _enableVelocity;
  55568. private _positionIndex;
  55569. private _velocityIndex;
  55570. protected _effect: Effect;
  55571. protected _cachedDefines: string;
  55572. /**
  55573. * Set the render list (meshes to be rendered) used in the G buffer.
  55574. */
  55575. renderList: Mesh[];
  55576. /**
  55577. * Gets wether or not G buffer are supported by the running hardware.
  55578. * This requires draw buffer supports
  55579. */
  55580. readonly isSupported: boolean;
  55581. /**
  55582. * Returns the index of the given texture type in the G-Buffer textures array
  55583. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55584. * @returns the index of the given texture type in the G-Buffer textures array
  55585. */
  55586. getTextureIndex(textureType: number): number;
  55587. /**
  55588. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55589. */
  55590. /**
  55591. * Sets whether or not objects positions are enabled for the G buffer.
  55592. */
  55593. enablePosition: boolean;
  55594. /**
  55595. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55596. */
  55597. /**
  55598. * Sets wether or not objects velocities are enabled for the G buffer.
  55599. */
  55600. enableVelocity: boolean;
  55601. /**
  55602. * Gets the scene associated with the buffer.
  55603. */
  55604. readonly scene: Scene;
  55605. /**
  55606. * Gets the ratio used by the buffer during its creation.
  55607. * How big is the buffer related to the main canvas.
  55608. */
  55609. readonly ratio: number;
  55610. /** @hidden */
  55611. static _SceneComponentInitialization: (scene: Scene) => void;
  55612. /**
  55613. * Creates a new G Buffer for the scene
  55614. * @param scene The scene the buffer belongs to
  55615. * @param ratio How big is the buffer related to the main canvas.
  55616. */
  55617. constructor(scene: Scene, ratio?: number);
  55618. /**
  55619. * Checks wether everything is ready to render a submesh to the G buffer.
  55620. * @param subMesh the submesh to check readiness for
  55621. * @param useInstances is the mesh drawn using instance or not
  55622. * @returns true if ready otherwise false
  55623. */
  55624. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55625. /**
  55626. * Gets the current underlying G Buffer.
  55627. * @returns the buffer
  55628. */
  55629. getGBuffer(): MultiRenderTarget;
  55630. /**
  55631. * Gets the number of samples used to render the buffer (anti aliasing).
  55632. */
  55633. /**
  55634. * Sets the number of samples used to render the buffer (anti aliasing).
  55635. */
  55636. samples: number;
  55637. /**
  55638. * Disposes the renderer and frees up associated resources.
  55639. */
  55640. dispose(): void;
  55641. protected _createRenderTargets(): void;
  55642. }
  55643. }
  55644. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55645. import { Nullable } from "babylonjs/types";
  55646. import { Scene } from "babylonjs/scene";
  55647. import { ISceneComponent } from "babylonjs/sceneComponent";
  55648. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55649. module "babylonjs/scene" {
  55650. interface Scene {
  55651. /** @hidden (Backing field) */
  55652. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55653. /**
  55654. * Gets or Sets the current geometry buffer associated to the scene.
  55655. */
  55656. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55657. /**
  55658. * Enables a GeometryBufferRender and associates it with the scene
  55659. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55660. * @returns the GeometryBufferRenderer
  55661. */
  55662. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55663. /**
  55664. * Disables the GeometryBufferRender associated with the scene
  55665. */
  55666. disableGeometryBufferRenderer(): void;
  55667. }
  55668. }
  55669. /**
  55670. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55671. * in several rendering techniques.
  55672. */
  55673. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55674. /**
  55675. * The component name helpful to identify the component in the list of scene components.
  55676. */
  55677. readonly name: string;
  55678. /**
  55679. * The scene the component belongs to.
  55680. */
  55681. scene: Scene;
  55682. /**
  55683. * Creates a new instance of the component for the given scene
  55684. * @param scene Defines the scene to register the component in
  55685. */
  55686. constructor(scene: Scene);
  55687. /**
  55688. * Registers the component in a given scene
  55689. */
  55690. register(): void;
  55691. /**
  55692. * Rebuilds the elements related to this component in case of
  55693. * context lost for instance.
  55694. */
  55695. rebuild(): void;
  55696. /**
  55697. * Disposes the component and the associated ressources
  55698. */
  55699. dispose(): void;
  55700. private _gatherRenderTargets;
  55701. }
  55702. }
  55703. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55704. /** @hidden */
  55705. export var motionBlurPixelShader: {
  55706. name: string;
  55707. shader: string;
  55708. };
  55709. }
  55710. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55711. import { Nullable } from "babylonjs/types";
  55712. import { Camera } from "babylonjs/Cameras/camera";
  55713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55714. import { Scene } from "babylonjs/scene";
  55715. import "babylonjs/Animations/animatable";
  55716. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55717. import "babylonjs/Shaders/motionBlur.fragment";
  55718. import { Engine } from "babylonjs/Engines/engine";
  55719. /**
  55720. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55721. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55722. * As an example, all you have to do is to create the post-process:
  55723. * var mb = new BABYLON.MotionBlurPostProcess(
  55724. * 'mb', // The name of the effect.
  55725. * scene, // The scene containing the objects to blur according to their velocity.
  55726. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55727. * camera // The camera to apply the render pass to.
  55728. * );
  55729. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55730. */
  55731. export class MotionBlurPostProcess extends PostProcess {
  55732. /**
  55733. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55734. */
  55735. motionStrength: number;
  55736. /**
  55737. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55738. */
  55739. /**
  55740. * Sets the number of iterations to be used for motion blur quality
  55741. */
  55742. motionBlurSamples: number;
  55743. private _motionBlurSamples;
  55744. private _geometryBufferRenderer;
  55745. /**
  55746. * Creates a new instance MotionBlurPostProcess
  55747. * @param name The name of the effect.
  55748. * @param scene The scene containing the objects to blur according to their velocity.
  55749. * @param options The required width/height ratio to downsize to before computing the render pass.
  55750. * @param camera The camera to apply the render pass to.
  55751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55752. * @param engine The engine which the post process will be applied. (default: current engine)
  55753. * @param reusable If the post process can be reused on the same frame. (default: false)
  55754. * @param textureType Type of textures used when performing the post process. (default: 0)
  55755. * @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)
  55756. */
  55757. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55758. /**
  55759. * Disposes the post process.
  55760. * @param camera The camera to dispose the post process on.
  55761. */
  55762. dispose(camera?: Camera): void;
  55763. }
  55764. }
  55765. declare module "babylonjs/Shaders/refraction.fragment" {
  55766. /** @hidden */
  55767. export var refractionPixelShader: {
  55768. name: string;
  55769. shader: string;
  55770. };
  55771. }
  55772. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55773. import { Color3 } from "babylonjs/Maths/math";
  55774. import { Camera } from "babylonjs/Cameras/camera";
  55775. import { Texture } from "babylonjs/Materials/Textures/texture";
  55776. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55777. import { Engine } from "babylonjs/Engines/engine";
  55778. import "babylonjs/Shaders/refraction.fragment";
  55779. /**
  55780. * Post process which applies a refractin texture
  55781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55782. */
  55783. export class RefractionPostProcess extends PostProcess {
  55784. /** the base color of the refraction (used to taint the rendering) */
  55785. color: Color3;
  55786. /** simulated refraction depth */
  55787. depth: number;
  55788. /** the coefficient of the base color (0 to remove base color tainting) */
  55789. colorLevel: number;
  55790. private _refTexture;
  55791. private _ownRefractionTexture;
  55792. /**
  55793. * Gets or sets the refraction texture
  55794. * Please note that you are responsible for disposing the texture if you set it manually
  55795. */
  55796. refractionTexture: Texture;
  55797. /**
  55798. * Initializes the RefractionPostProcess
  55799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55800. * @param name The name of the effect.
  55801. * @param refractionTextureUrl Url of the refraction texture to use
  55802. * @param color the base color of the refraction (used to taint the rendering)
  55803. * @param depth simulated refraction depth
  55804. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55805. * @param camera The camera to apply the render pass to.
  55806. * @param options The required width/height ratio to downsize to before computing the render pass.
  55807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55808. * @param engine The engine which the post process will be applied. (default: current engine)
  55809. * @param reusable If the post process can be reused on the same frame. (default: false)
  55810. */
  55811. constructor(name: string, refractionTextureUrl: string,
  55812. /** the base color of the refraction (used to taint the rendering) */
  55813. color: Color3,
  55814. /** simulated refraction depth */
  55815. depth: number,
  55816. /** the coefficient of the base color (0 to remove base color tainting) */
  55817. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55818. /**
  55819. * Disposes of the post process
  55820. * @param camera Camera to dispose post process on
  55821. */
  55822. dispose(camera: Camera): void;
  55823. }
  55824. }
  55825. declare module "babylonjs/Shaders/sharpen.fragment" {
  55826. /** @hidden */
  55827. export var sharpenPixelShader: {
  55828. name: string;
  55829. shader: string;
  55830. };
  55831. }
  55832. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55833. import { Nullable } from "babylonjs/types";
  55834. import { Camera } from "babylonjs/Cameras/camera";
  55835. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55836. import "babylonjs/Shaders/sharpen.fragment";
  55837. import { Engine } from "babylonjs/Engines/engine";
  55838. /**
  55839. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55840. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55841. */
  55842. export class SharpenPostProcess extends PostProcess {
  55843. /**
  55844. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55845. */
  55846. colorAmount: number;
  55847. /**
  55848. * How much sharpness should be applied (default: 0.3)
  55849. */
  55850. edgeAmount: number;
  55851. /**
  55852. * Creates a new instance ConvolutionPostProcess
  55853. * @param name The name of the effect.
  55854. * @param options The required width/height ratio to downsize to before computing the render pass.
  55855. * @param camera The camera to apply the render pass to.
  55856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55857. * @param engine The engine which the post process will be applied. (default: current engine)
  55858. * @param reusable If the post process can be reused on the same frame. (default: false)
  55859. * @param textureType Type of textures used when performing the post process. (default: 0)
  55860. * @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)
  55861. */
  55862. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55863. }
  55864. }
  55865. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55866. import { Nullable } from "babylonjs/types";
  55867. import { Camera } from "babylonjs/Cameras/camera";
  55868. import { Engine } from "babylonjs/Engines/engine";
  55869. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55870. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55871. /**
  55872. * PostProcessRenderPipeline
  55873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55874. */
  55875. export class PostProcessRenderPipeline {
  55876. private engine;
  55877. private _renderEffects;
  55878. private _renderEffectsForIsolatedPass;
  55879. /**
  55880. * List of inspectable custom properties (used by the Inspector)
  55881. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55882. */
  55883. inspectableCustomProperties: IInspectable[];
  55884. /**
  55885. * @hidden
  55886. */
  55887. protected _cameras: Camera[];
  55888. /** @hidden */
  55889. _name: string;
  55890. /**
  55891. * Gets pipeline name
  55892. */
  55893. readonly name: string;
  55894. /**
  55895. * Initializes a PostProcessRenderPipeline
  55896. * @param engine engine to add the pipeline to
  55897. * @param name name of the pipeline
  55898. */
  55899. constructor(engine: Engine, name: string);
  55900. /**
  55901. * Gets the class name
  55902. * @returns "PostProcessRenderPipeline"
  55903. */
  55904. getClassName(): string;
  55905. /**
  55906. * If all the render effects in the pipeline are supported
  55907. */
  55908. readonly isSupported: boolean;
  55909. /**
  55910. * Adds an effect to the pipeline
  55911. * @param renderEffect the effect to add
  55912. */
  55913. addEffect(renderEffect: PostProcessRenderEffect): void;
  55914. /** @hidden */
  55915. _rebuild(): void;
  55916. /** @hidden */
  55917. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55918. /** @hidden */
  55919. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55920. /** @hidden */
  55921. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55922. /** @hidden */
  55923. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55924. /** @hidden */
  55925. _attachCameras(cameras: Camera, unique: boolean): void;
  55926. /** @hidden */
  55927. _attachCameras(cameras: Camera[], unique: boolean): void;
  55928. /** @hidden */
  55929. _detachCameras(cameras: Camera): void;
  55930. /** @hidden */
  55931. _detachCameras(cameras: Nullable<Camera[]>): void;
  55932. /** @hidden */
  55933. _update(): void;
  55934. /** @hidden */
  55935. _reset(): void;
  55936. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55937. /**
  55938. * Disposes of the pipeline
  55939. */
  55940. dispose(): void;
  55941. }
  55942. }
  55943. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55944. import { Camera } from "babylonjs/Cameras/camera";
  55945. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55946. /**
  55947. * PostProcessRenderPipelineManager class
  55948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55949. */
  55950. export class PostProcessRenderPipelineManager {
  55951. private _renderPipelines;
  55952. /**
  55953. * Initializes a PostProcessRenderPipelineManager
  55954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55955. */
  55956. constructor();
  55957. /**
  55958. * Gets the list of supported render pipelines
  55959. */
  55960. readonly supportedPipelines: PostProcessRenderPipeline[];
  55961. /**
  55962. * Adds a pipeline to the manager
  55963. * @param renderPipeline The pipeline to add
  55964. */
  55965. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55966. /**
  55967. * Attaches a camera to the pipeline
  55968. * @param renderPipelineName The name of the pipeline to attach to
  55969. * @param cameras the camera to attach
  55970. * @param unique if the camera can be attached multiple times to the pipeline
  55971. */
  55972. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55973. /**
  55974. * Detaches a camera from the pipeline
  55975. * @param renderPipelineName The name of the pipeline to detach from
  55976. * @param cameras the camera to detach
  55977. */
  55978. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55979. /**
  55980. * Enables an effect by name on a pipeline
  55981. * @param renderPipelineName the name of the pipeline to enable the effect in
  55982. * @param renderEffectName the name of the effect to enable
  55983. * @param cameras the cameras that the effect should be enabled on
  55984. */
  55985. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55986. /**
  55987. * Disables an effect by name on a pipeline
  55988. * @param renderPipelineName the name of the pipeline to disable the effect in
  55989. * @param renderEffectName the name of the effect to disable
  55990. * @param cameras the cameras that the effect should be disabled on
  55991. */
  55992. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55993. /**
  55994. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55995. */
  55996. update(): void;
  55997. /** @hidden */
  55998. _rebuild(): void;
  55999. /**
  56000. * Disposes of the manager and pipelines
  56001. */
  56002. dispose(): void;
  56003. }
  56004. }
  56005. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  56006. import { ISceneComponent } from "babylonjs/sceneComponent";
  56007. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56008. import { Scene } from "babylonjs/scene";
  56009. module "babylonjs/scene" {
  56010. interface Scene {
  56011. /** @hidden (Backing field) */
  56012. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56013. /**
  56014. * Gets the postprocess render pipeline manager
  56015. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56016. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56017. */
  56018. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56019. }
  56020. }
  56021. /**
  56022. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56023. */
  56024. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56025. /**
  56026. * The component name helpfull to identify the component in the list of scene components.
  56027. */
  56028. readonly name: string;
  56029. /**
  56030. * The scene the component belongs to.
  56031. */
  56032. scene: Scene;
  56033. /**
  56034. * Creates a new instance of the component for the given scene
  56035. * @param scene Defines the scene to register the component in
  56036. */
  56037. constructor(scene: Scene);
  56038. /**
  56039. * Registers the component in a given scene
  56040. */
  56041. register(): void;
  56042. /**
  56043. * Rebuilds the elements related to this component in case of
  56044. * context lost for instance.
  56045. */
  56046. rebuild(): void;
  56047. /**
  56048. * Disposes the component and the associated ressources
  56049. */
  56050. dispose(): void;
  56051. private _gatherRenderTargets;
  56052. }
  56053. }
  56054. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  56055. import { IAnimatable } from "babylonjs/Misc/tools";
  56056. import { Camera } from "babylonjs/Cameras/camera";
  56057. import { IDisposable } from "babylonjs/scene";
  56058. import { Scene } from "babylonjs/scene";
  56059. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  56060. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56061. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56062. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  56063. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56064. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56065. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  56066. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56067. import { Animation } from "babylonjs/Animations/animation";
  56068. /**
  56069. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56070. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56071. */
  56072. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56073. private _scene;
  56074. private _camerasToBeAttached;
  56075. /**
  56076. * ID of the sharpen post process,
  56077. */
  56078. private readonly SharpenPostProcessId;
  56079. /**
  56080. * @ignore
  56081. * ID of the image processing post process;
  56082. */
  56083. readonly ImageProcessingPostProcessId: string;
  56084. /**
  56085. * @ignore
  56086. * ID of the Fast Approximate Anti-Aliasing post process;
  56087. */
  56088. readonly FxaaPostProcessId: string;
  56089. /**
  56090. * ID of the chromatic aberration post process,
  56091. */
  56092. private readonly ChromaticAberrationPostProcessId;
  56093. /**
  56094. * ID of the grain post process
  56095. */
  56096. private readonly GrainPostProcessId;
  56097. /**
  56098. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56099. */
  56100. sharpen: SharpenPostProcess;
  56101. private _sharpenEffect;
  56102. private bloom;
  56103. /**
  56104. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56105. */
  56106. depthOfField: DepthOfFieldEffect;
  56107. /**
  56108. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56109. */
  56110. fxaa: FxaaPostProcess;
  56111. /**
  56112. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56113. */
  56114. imageProcessing: ImageProcessingPostProcess;
  56115. /**
  56116. * Chromatic aberration post process which will shift rgb colors in the image
  56117. */
  56118. chromaticAberration: ChromaticAberrationPostProcess;
  56119. private _chromaticAberrationEffect;
  56120. /**
  56121. * Grain post process which add noise to the image
  56122. */
  56123. grain: GrainPostProcess;
  56124. private _grainEffect;
  56125. /**
  56126. * Glow post process which adds a glow to emissive areas of the image
  56127. */
  56128. private _glowLayer;
  56129. /**
  56130. * Animations which can be used to tweak settings over a period of time
  56131. */
  56132. animations: Animation[];
  56133. private _imageProcessingConfigurationObserver;
  56134. private _sharpenEnabled;
  56135. private _bloomEnabled;
  56136. private _depthOfFieldEnabled;
  56137. private _depthOfFieldBlurLevel;
  56138. private _fxaaEnabled;
  56139. private _imageProcessingEnabled;
  56140. private _defaultPipelineTextureType;
  56141. private _bloomScale;
  56142. private _chromaticAberrationEnabled;
  56143. private _grainEnabled;
  56144. private _buildAllowed;
  56145. /**
  56146. * Gets active scene
  56147. */
  56148. readonly scene: Scene;
  56149. /**
  56150. * Enable or disable the sharpen process from the pipeline
  56151. */
  56152. sharpenEnabled: boolean;
  56153. private _resizeObserver;
  56154. private _hardwareScaleLevel;
  56155. private _bloomKernel;
  56156. /**
  56157. * Specifies the size of the bloom blur kernel, relative to the final output size
  56158. */
  56159. bloomKernel: number;
  56160. /**
  56161. * Specifies the weight of the bloom in the final rendering
  56162. */
  56163. private _bloomWeight;
  56164. /**
  56165. * Specifies the luma threshold for the area that will be blurred by the bloom
  56166. */
  56167. private _bloomThreshold;
  56168. private _hdr;
  56169. /**
  56170. * The strength of the bloom.
  56171. */
  56172. bloomWeight: number;
  56173. /**
  56174. * The strength of the bloom.
  56175. */
  56176. bloomThreshold: number;
  56177. /**
  56178. * The scale of the bloom, lower value will provide better performance.
  56179. */
  56180. bloomScale: number;
  56181. /**
  56182. * Enable or disable the bloom from the pipeline
  56183. */
  56184. bloomEnabled: boolean;
  56185. private _rebuildBloom;
  56186. /**
  56187. * If the depth of field is enabled.
  56188. */
  56189. depthOfFieldEnabled: boolean;
  56190. /**
  56191. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56192. */
  56193. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56194. /**
  56195. * If the anti aliasing is enabled.
  56196. */
  56197. fxaaEnabled: boolean;
  56198. private _samples;
  56199. /**
  56200. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56201. */
  56202. samples: number;
  56203. /**
  56204. * If image processing is enabled.
  56205. */
  56206. imageProcessingEnabled: boolean;
  56207. /**
  56208. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56209. */
  56210. glowLayerEnabled: boolean;
  56211. /**
  56212. * Enable or disable the chromaticAberration process from the pipeline
  56213. */
  56214. chromaticAberrationEnabled: boolean;
  56215. /**
  56216. * Enable or disable the grain process from the pipeline
  56217. */
  56218. grainEnabled: boolean;
  56219. /**
  56220. * @constructor
  56221. * @param name - The rendering pipeline name (default: "")
  56222. * @param hdr - If high dynamic range textures should be used (default: true)
  56223. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56224. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56225. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56226. */
  56227. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56228. /**
  56229. * Get the class name
  56230. * @returns "DefaultRenderingPipeline"
  56231. */
  56232. getClassName(): string;
  56233. /**
  56234. * Force the compilation of the entire pipeline.
  56235. */
  56236. prepare(): void;
  56237. private _hasCleared;
  56238. private _prevPostProcess;
  56239. private _prevPrevPostProcess;
  56240. private _setAutoClearAndTextureSharing;
  56241. private _depthOfFieldSceneObserver;
  56242. private _buildPipeline;
  56243. private _disposePostProcesses;
  56244. /**
  56245. * Adds a camera to the pipeline
  56246. * @param camera the camera to be added
  56247. */
  56248. addCamera(camera: Camera): void;
  56249. /**
  56250. * Removes a camera from the pipeline
  56251. * @param camera the camera to remove
  56252. */
  56253. removeCamera(camera: Camera): void;
  56254. /**
  56255. * Dispose of the pipeline and stop all post processes
  56256. */
  56257. dispose(): void;
  56258. /**
  56259. * Serialize the rendering pipeline (Used when exporting)
  56260. * @returns the serialized object
  56261. */
  56262. serialize(): any;
  56263. /**
  56264. * Parse the serialized pipeline
  56265. * @param source Source pipeline.
  56266. * @param scene The scene to load the pipeline to.
  56267. * @param rootUrl The URL of the serialized pipeline.
  56268. * @returns An instantiated pipeline from the serialized object.
  56269. */
  56270. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56271. }
  56272. }
  56273. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  56274. /** @hidden */
  56275. export var lensHighlightsPixelShader: {
  56276. name: string;
  56277. shader: string;
  56278. };
  56279. }
  56280. declare module "babylonjs/Shaders/depthOfField.fragment" {
  56281. /** @hidden */
  56282. export var depthOfFieldPixelShader: {
  56283. name: string;
  56284. shader: string;
  56285. };
  56286. }
  56287. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  56288. import { Camera } from "babylonjs/Cameras/camera";
  56289. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56290. import { Scene } from "babylonjs/scene";
  56291. import "babylonjs/Shaders/chromaticAberration.fragment";
  56292. import "babylonjs/Shaders/lensHighlights.fragment";
  56293. import "babylonjs/Shaders/depthOfField.fragment";
  56294. /**
  56295. * BABYLON.JS Chromatic Aberration GLSL Shader
  56296. * Author: Olivier Guyot
  56297. * Separates very slightly R, G and B colors on the edges of the screen
  56298. * Inspired by Francois Tarlier & Martins Upitis
  56299. */
  56300. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56301. /**
  56302. * @ignore
  56303. * The chromatic aberration PostProcess id in the pipeline
  56304. */
  56305. LensChromaticAberrationEffect: string;
  56306. /**
  56307. * @ignore
  56308. * The highlights enhancing PostProcess id in the pipeline
  56309. */
  56310. HighlightsEnhancingEffect: string;
  56311. /**
  56312. * @ignore
  56313. * The depth-of-field PostProcess id in the pipeline
  56314. */
  56315. LensDepthOfFieldEffect: string;
  56316. private _scene;
  56317. private _depthTexture;
  56318. private _grainTexture;
  56319. private _chromaticAberrationPostProcess;
  56320. private _highlightsPostProcess;
  56321. private _depthOfFieldPostProcess;
  56322. private _edgeBlur;
  56323. private _grainAmount;
  56324. private _chromaticAberration;
  56325. private _distortion;
  56326. private _highlightsGain;
  56327. private _highlightsThreshold;
  56328. private _dofDistance;
  56329. private _dofAperture;
  56330. private _dofDarken;
  56331. private _dofPentagon;
  56332. private _blurNoise;
  56333. /**
  56334. * @constructor
  56335. *
  56336. * Effect parameters are as follow:
  56337. * {
  56338. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56339. * edge_blur: number; // from 0 to x (1 for realism)
  56340. * distortion: number; // from 0 to x (1 for realism)
  56341. * grain_amount: number; // from 0 to 1
  56342. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56343. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56344. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56345. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56346. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56347. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56348. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56349. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56350. * }
  56351. * Note: if an effect parameter is unset, effect is disabled
  56352. *
  56353. * @param name The rendering pipeline name
  56354. * @param parameters - An object containing all parameters (see above)
  56355. * @param scene The scene linked to this pipeline
  56356. * @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)
  56357. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56358. */
  56359. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56360. /**
  56361. * Get the class name
  56362. * @returns "LensRenderingPipeline"
  56363. */
  56364. getClassName(): string;
  56365. /**
  56366. * Gets associated scene
  56367. */
  56368. readonly scene: Scene;
  56369. /**
  56370. * Gets or sets the edge blur
  56371. */
  56372. edgeBlur: number;
  56373. /**
  56374. * Gets or sets the grain amount
  56375. */
  56376. grainAmount: number;
  56377. /**
  56378. * Gets or sets the chromatic aberration amount
  56379. */
  56380. chromaticAberration: number;
  56381. /**
  56382. * Gets or sets the depth of field aperture
  56383. */
  56384. dofAperture: number;
  56385. /**
  56386. * Gets or sets the edge distortion
  56387. */
  56388. edgeDistortion: number;
  56389. /**
  56390. * Gets or sets the depth of field distortion
  56391. */
  56392. dofDistortion: number;
  56393. /**
  56394. * Gets or sets the darken out of focus amount
  56395. */
  56396. darkenOutOfFocus: number;
  56397. /**
  56398. * Gets or sets a boolean indicating if blur noise is enabled
  56399. */
  56400. blurNoise: boolean;
  56401. /**
  56402. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56403. */
  56404. pentagonBokeh: boolean;
  56405. /**
  56406. * Gets or sets the highlight grain amount
  56407. */
  56408. highlightsGain: number;
  56409. /**
  56410. * Gets or sets the highlight threshold
  56411. */
  56412. highlightsThreshold: number;
  56413. /**
  56414. * Sets the amount of blur at the edges
  56415. * @param amount blur amount
  56416. */
  56417. setEdgeBlur(amount: number): void;
  56418. /**
  56419. * Sets edge blur to 0
  56420. */
  56421. disableEdgeBlur(): void;
  56422. /**
  56423. * Sets the amout of grain
  56424. * @param amount Amount of grain
  56425. */
  56426. setGrainAmount(amount: number): void;
  56427. /**
  56428. * Set grain amount to 0
  56429. */
  56430. disableGrain(): void;
  56431. /**
  56432. * Sets the chromatic aberration amount
  56433. * @param amount amount of chromatic aberration
  56434. */
  56435. setChromaticAberration(amount: number): void;
  56436. /**
  56437. * Sets chromatic aberration amount to 0
  56438. */
  56439. disableChromaticAberration(): void;
  56440. /**
  56441. * Sets the EdgeDistortion amount
  56442. * @param amount amount of EdgeDistortion
  56443. */
  56444. setEdgeDistortion(amount: number): void;
  56445. /**
  56446. * Sets edge distortion to 0
  56447. */
  56448. disableEdgeDistortion(): void;
  56449. /**
  56450. * Sets the FocusDistance amount
  56451. * @param amount amount of FocusDistance
  56452. */
  56453. setFocusDistance(amount: number): void;
  56454. /**
  56455. * Disables depth of field
  56456. */
  56457. disableDepthOfField(): void;
  56458. /**
  56459. * Sets the Aperture amount
  56460. * @param amount amount of Aperture
  56461. */
  56462. setAperture(amount: number): void;
  56463. /**
  56464. * Sets the DarkenOutOfFocus amount
  56465. * @param amount amount of DarkenOutOfFocus
  56466. */
  56467. setDarkenOutOfFocus(amount: number): void;
  56468. private _pentagonBokehIsEnabled;
  56469. /**
  56470. * Creates a pentagon bokeh effect
  56471. */
  56472. enablePentagonBokeh(): void;
  56473. /**
  56474. * Disables the pentagon bokeh effect
  56475. */
  56476. disablePentagonBokeh(): void;
  56477. /**
  56478. * Enables noise blur
  56479. */
  56480. enableNoiseBlur(): void;
  56481. /**
  56482. * Disables noise blur
  56483. */
  56484. disableNoiseBlur(): void;
  56485. /**
  56486. * Sets the HighlightsGain amount
  56487. * @param amount amount of HighlightsGain
  56488. */
  56489. setHighlightsGain(amount: number): void;
  56490. /**
  56491. * Sets the HighlightsThreshold amount
  56492. * @param amount amount of HighlightsThreshold
  56493. */
  56494. setHighlightsThreshold(amount: number): void;
  56495. /**
  56496. * Disables highlights
  56497. */
  56498. disableHighlights(): void;
  56499. /**
  56500. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56501. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56502. */
  56503. dispose(disableDepthRender?: boolean): void;
  56504. private _createChromaticAberrationPostProcess;
  56505. private _createHighlightsPostProcess;
  56506. private _createDepthOfFieldPostProcess;
  56507. private _createGrainTexture;
  56508. }
  56509. }
  56510. declare module "babylonjs/Shaders/ssao2.fragment" {
  56511. /** @hidden */
  56512. export var ssao2PixelShader: {
  56513. name: string;
  56514. shader: string;
  56515. };
  56516. }
  56517. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56518. /** @hidden */
  56519. export var ssaoCombinePixelShader: {
  56520. name: string;
  56521. shader: string;
  56522. };
  56523. }
  56524. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56525. import { Camera } from "babylonjs/Cameras/camera";
  56526. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56527. import { Scene } from "babylonjs/scene";
  56528. import "babylonjs/Shaders/ssao2.fragment";
  56529. import "babylonjs/Shaders/ssaoCombine.fragment";
  56530. /**
  56531. * Render pipeline to produce ssao effect
  56532. */
  56533. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56534. /**
  56535. * @ignore
  56536. * The PassPostProcess id in the pipeline that contains the original scene color
  56537. */
  56538. SSAOOriginalSceneColorEffect: string;
  56539. /**
  56540. * @ignore
  56541. * The SSAO PostProcess id in the pipeline
  56542. */
  56543. SSAORenderEffect: string;
  56544. /**
  56545. * @ignore
  56546. * The horizontal blur PostProcess id in the pipeline
  56547. */
  56548. SSAOBlurHRenderEffect: string;
  56549. /**
  56550. * @ignore
  56551. * The vertical blur PostProcess id in the pipeline
  56552. */
  56553. SSAOBlurVRenderEffect: string;
  56554. /**
  56555. * @ignore
  56556. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56557. */
  56558. SSAOCombineRenderEffect: string;
  56559. /**
  56560. * The output strength of the SSAO post-process. Default value is 1.0.
  56561. */
  56562. totalStrength: number;
  56563. /**
  56564. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56565. */
  56566. maxZ: number;
  56567. /**
  56568. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56569. */
  56570. minZAspect: number;
  56571. private _samples;
  56572. /**
  56573. * Number of samples used for the SSAO calculations. Default value is 8
  56574. */
  56575. samples: number;
  56576. private _textureSamples;
  56577. /**
  56578. * Number of samples to use for antialiasing
  56579. */
  56580. textureSamples: number;
  56581. /**
  56582. * Ratio object used for SSAO ratio and blur ratio
  56583. */
  56584. private _ratio;
  56585. /**
  56586. * Dynamically generated sphere sampler.
  56587. */
  56588. private _sampleSphere;
  56589. /**
  56590. * Blur filter offsets
  56591. */
  56592. private _samplerOffsets;
  56593. private _expensiveBlur;
  56594. /**
  56595. * If bilateral blur should be used
  56596. */
  56597. expensiveBlur: boolean;
  56598. /**
  56599. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56600. */
  56601. radius: number;
  56602. /**
  56603. * The base color of the SSAO post-process
  56604. * The final result is "base + ssao" between [0, 1]
  56605. */
  56606. base: number;
  56607. /**
  56608. * Support test.
  56609. */
  56610. static readonly IsSupported: boolean;
  56611. private _scene;
  56612. private _depthTexture;
  56613. private _normalTexture;
  56614. private _randomTexture;
  56615. private _originalColorPostProcess;
  56616. private _ssaoPostProcess;
  56617. private _blurHPostProcess;
  56618. private _blurVPostProcess;
  56619. private _ssaoCombinePostProcess;
  56620. private _firstUpdate;
  56621. /**
  56622. * Gets active scene
  56623. */
  56624. readonly scene: Scene;
  56625. /**
  56626. * @constructor
  56627. * @param name The rendering pipeline name
  56628. * @param scene The scene linked to this pipeline
  56629. * @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 }
  56630. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56631. */
  56632. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56633. /**
  56634. * Get the class name
  56635. * @returns "SSAO2RenderingPipeline"
  56636. */
  56637. getClassName(): string;
  56638. /**
  56639. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56640. */
  56641. dispose(disableGeometryBufferRenderer?: boolean): void;
  56642. private _createBlurPostProcess;
  56643. /** @hidden */
  56644. _rebuild(): void;
  56645. private _bits;
  56646. private _radicalInverse_VdC;
  56647. private _hammersley;
  56648. private _hemisphereSample_uniform;
  56649. private _generateHemisphere;
  56650. private _createSSAOPostProcess;
  56651. private _createSSAOCombinePostProcess;
  56652. private _createRandomTexture;
  56653. /**
  56654. * Serialize the rendering pipeline (Used when exporting)
  56655. * @returns the serialized object
  56656. */
  56657. serialize(): any;
  56658. /**
  56659. * Parse the serialized pipeline
  56660. * @param source Source pipeline.
  56661. * @param scene The scene to load the pipeline to.
  56662. * @param rootUrl The URL of the serialized pipeline.
  56663. * @returns An instantiated pipeline from the serialized object.
  56664. */
  56665. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56666. }
  56667. }
  56668. declare module "babylonjs/Shaders/ssao.fragment" {
  56669. /** @hidden */
  56670. export var ssaoPixelShader: {
  56671. name: string;
  56672. shader: string;
  56673. };
  56674. }
  56675. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56676. import { Camera } from "babylonjs/Cameras/camera";
  56677. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56678. import { Scene } from "babylonjs/scene";
  56679. import "babylonjs/Shaders/ssao.fragment";
  56680. import "babylonjs/Shaders/ssaoCombine.fragment";
  56681. /**
  56682. * Render pipeline to produce ssao effect
  56683. */
  56684. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56685. /**
  56686. * @ignore
  56687. * The PassPostProcess id in the pipeline that contains the original scene color
  56688. */
  56689. SSAOOriginalSceneColorEffect: string;
  56690. /**
  56691. * @ignore
  56692. * The SSAO PostProcess id in the pipeline
  56693. */
  56694. SSAORenderEffect: string;
  56695. /**
  56696. * @ignore
  56697. * The horizontal blur PostProcess id in the pipeline
  56698. */
  56699. SSAOBlurHRenderEffect: string;
  56700. /**
  56701. * @ignore
  56702. * The vertical blur PostProcess id in the pipeline
  56703. */
  56704. SSAOBlurVRenderEffect: string;
  56705. /**
  56706. * @ignore
  56707. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56708. */
  56709. SSAOCombineRenderEffect: string;
  56710. /**
  56711. * The output strength of the SSAO post-process. Default value is 1.0.
  56712. */
  56713. totalStrength: number;
  56714. /**
  56715. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56716. */
  56717. radius: number;
  56718. /**
  56719. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56720. * Must not be equal to fallOff and superior to fallOff.
  56721. * Default value is 0.0075
  56722. */
  56723. area: number;
  56724. /**
  56725. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56726. * Must not be equal to area and inferior to area.
  56727. * Default value is 0.000001
  56728. */
  56729. fallOff: number;
  56730. /**
  56731. * The base color of the SSAO post-process
  56732. * The final result is "base + ssao" between [0, 1]
  56733. */
  56734. base: number;
  56735. private _scene;
  56736. private _depthTexture;
  56737. private _randomTexture;
  56738. private _originalColorPostProcess;
  56739. private _ssaoPostProcess;
  56740. private _blurHPostProcess;
  56741. private _blurVPostProcess;
  56742. private _ssaoCombinePostProcess;
  56743. private _firstUpdate;
  56744. /**
  56745. * Gets active scene
  56746. */
  56747. readonly scene: Scene;
  56748. /**
  56749. * @constructor
  56750. * @param name - The rendering pipeline name
  56751. * @param scene - The scene linked to this pipeline
  56752. * @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 }
  56753. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56754. */
  56755. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56756. /**
  56757. * Get the class name
  56758. * @returns "SSAORenderingPipeline"
  56759. */
  56760. getClassName(): string;
  56761. /**
  56762. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56763. */
  56764. dispose(disableDepthRender?: boolean): void;
  56765. private _createBlurPostProcess;
  56766. /** @hidden */
  56767. _rebuild(): void;
  56768. private _createSSAOPostProcess;
  56769. private _createSSAOCombinePostProcess;
  56770. private _createRandomTexture;
  56771. }
  56772. }
  56773. declare module "babylonjs/Shaders/standard.fragment" {
  56774. /** @hidden */
  56775. export var standardPixelShader: {
  56776. name: string;
  56777. shader: string;
  56778. };
  56779. }
  56780. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56781. import { Nullable } from "babylonjs/types";
  56782. import { IAnimatable } from "babylonjs/Misc/tools";
  56783. import { Camera } from "babylonjs/Cameras/camera";
  56784. import { Texture } from "babylonjs/Materials/Textures/texture";
  56785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56786. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56787. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56788. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56789. import { IDisposable } from "babylonjs/scene";
  56790. import { SpotLight } from "babylonjs/Lights/spotLight";
  56791. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56792. import { Scene } from "babylonjs/scene";
  56793. import { Animation } from "babylonjs/Animations/animation";
  56794. import "babylonjs/Shaders/standard.fragment";
  56795. /**
  56796. * Standard rendering pipeline
  56797. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56798. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56799. */
  56800. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56801. /**
  56802. * Public members
  56803. */
  56804. /**
  56805. * Post-process which contains the original scene color before the pipeline applies all the effects
  56806. */
  56807. originalPostProcess: Nullable<PostProcess>;
  56808. /**
  56809. * Post-process used to down scale an image x4
  56810. */
  56811. downSampleX4PostProcess: Nullable<PostProcess>;
  56812. /**
  56813. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56814. */
  56815. brightPassPostProcess: Nullable<PostProcess>;
  56816. /**
  56817. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56818. */
  56819. blurHPostProcesses: PostProcess[];
  56820. /**
  56821. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56822. */
  56823. blurVPostProcesses: PostProcess[];
  56824. /**
  56825. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56826. */
  56827. textureAdderPostProcess: Nullable<PostProcess>;
  56828. /**
  56829. * Post-process used to create volumetric lighting effect
  56830. */
  56831. volumetricLightPostProcess: Nullable<PostProcess>;
  56832. /**
  56833. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56834. */
  56835. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56836. /**
  56837. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56838. */
  56839. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56840. /**
  56841. * Post-process used to merge the volumetric light effect and the real scene color
  56842. */
  56843. volumetricLightMergePostProces: Nullable<PostProcess>;
  56844. /**
  56845. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56846. */
  56847. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56848. /**
  56849. * Base post-process used to calculate the average luminance of the final image for HDR
  56850. */
  56851. luminancePostProcess: Nullable<PostProcess>;
  56852. /**
  56853. * Post-processes used to create down sample post-processes in order to get
  56854. * the average luminance of the final image for HDR
  56855. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56856. */
  56857. luminanceDownSamplePostProcesses: PostProcess[];
  56858. /**
  56859. * Post-process used to create a HDR effect (light adaptation)
  56860. */
  56861. hdrPostProcess: Nullable<PostProcess>;
  56862. /**
  56863. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56864. */
  56865. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56866. /**
  56867. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56868. */
  56869. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56870. /**
  56871. * Post-process used to merge the final HDR post-process and the real scene color
  56872. */
  56873. hdrFinalPostProcess: Nullable<PostProcess>;
  56874. /**
  56875. * Post-process used to create a lens flare effect
  56876. */
  56877. lensFlarePostProcess: Nullable<PostProcess>;
  56878. /**
  56879. * Post-process that merges the result of the lens flare post-process and the real scene color
  56880. */
  56881. lensFlareComposePostProcess: Nullable<PostProcess>;
  56882. /**
  56883. * Post-process used to create a motion blur effect
  56884. */
  56885. motionBlurPostProcess: Nullable<PostProcess>;
  56886. /**
  56887. * Post-process used to create a depth of field effect
  56888. */
  56889. depthOfFieldPostProcess: Nullable<PostProcess>;
  56890. /**
  56891. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56892. */
  56893. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56894. /**
  56895. * Represents the brightness threshold in order to configure the illuminated surfaces
  56896. */
  56897. brightThreshold: number;
  56898. /**
  56899. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56900. */
  56901. blurWidth: number;
  56902. /**
  56903. * Sets if the blur for highlighted surfaces must be only horizontal
  56904. */
  56905. horizontalBlur: boolean;
  56906. /**
  56907. * Gets the overall exposure used by the pipeline
  56908. */
  56909. /**
  56910. * Sets the overall exposure used by the pipeline
  56911. */
  56912. exposure: number;
  56913. /**
  56914. * Texture used typically to simulate "dirty" on camera lens
  56915. */
  56916. lensTexture: Nullable<Texture>;
  56917. /**
  56918. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56919. */
  56920. volumetricLightCoefficient: number;
  56921. /**
  56922. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56923. */
  56924. volumetricLightPower: number;
  56925. /**
  56926. * Used the set the blur intensity to smooth the volumetric lights
  56927. */
  56928. volumetricLightBlurScale: number;
  56929. /**
  56930. * Light (spot or directional) used to generate the volumetric lights rays
  56931. * The source light must have a shadow generate so the pipeline can get its
  56932. * depth map
  56933. */
  56934. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56935. /**
  56936. * For eye adaptation, represents the minimum luminance the eye can see
  56937. */
  56938. hdrMinimumLuminance: number;
  56939. /**
  56940. * For eye adaptation, represents the decrease luminance speed
  56941. */
  56942. hdrDecreaseRate: number;
  56943. /**
  56944. * For eye adaptation, represents the increase luminance speed
  56945. */
  56946. hdrIncreaseRate: number;
  56947. /**
  56948. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56949. */
  56950. /**
  56951. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56952. */
  56953. hdrAutoExposure: boolean;
  56954. /**
  56955. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56956. */
  56957. lensColorTexture: Nullable<Texture>;
  56958. /**
  56959. * The overall strengh for the lens flare effect
  56960. */
  56961. lensFlareStrength: number;
  56962. /**
  56963. * Dispersion coefficient for lens flare ghosts
  56964. */
  56965. lensFlareGhostDispersal: number;
  56966. /**
  56967. * Main lens flare halo width
  56968. */
  56969. lensFlareHaloWidth: number;
  56970. /**
  56971. * Based on the lens distortion effect, defines how much the lens flare result
  56972. * is distorted
  56973. */
  56974. lensFlareDistortionStrength: number;
  56975. /**
  56976. * Lens star texture must be used to simulate rays on the flares and is available
  56977. * in the documentation
  56978. */
  56979. lensStarTexture: Nullable<Texture>;
  56980. /**
  56981. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56982. * flare effect by taking account of the dirt texture
  56983. */
  56984. lensFlareDirtTexture: Nullable<Texture>;
  56985. /**
  56986. * Represents the focal length for the depth of field effect
  56987. */
  56988. depthOfFieldDistance: number;
  56989. /**
  56990. * Represents the blur intensity for the blurred part of the depth of field effect
  56991. */
  56992. depthOfFieldBlurWidth: number;
  56993. /**
  56994. * For motion blur, defines how much the image is blurred by the movement
  56995. */
  56996. motionStrength: number;
  56997. /**
  56998. * List of animations for the pipeline (IAnimatable implementation)
  56999. */
  57000. animations: Animation[];
  57001. /**
  57002. * Private members
  57003. */
  57004. private _scene;
  57005. private _currentDepthOfFieldSource;
  57006. private _basePostProcess;
  57007. private _fixedExposure;
  57008. private _currentExposure;
  57009. private _hdrAutoExposure;
  57010. private _hdrCurrentLuminance;
  57011. private _floatTextureType;
  57012. private _ratio;
  57013. private _bloomEnabled;
  57014. private _depthOfFieldEnabled;
  57015. private _vlsEnabled;
  57016. private _lensFlareEnabled;
  57017. private _hdrEnabled;
  57018. private _motionBlurEnabled;
  57019. private _fxaaEnabled;
  57020. private _motionBlurSamples;
  57021. private _volumetricLightStepsCount;
  57022. private _samples;
  57023. /**
  57024. * @ignore
  57025. * Specifies if the bloom pipeline is enabled
  57026. */
  57027. BloomEnabled: boolean;
  57028. /**
  57029. * @ignore
  57030. * Specifies if the depth of field pipeline is enabed
  57031. */
  57032. DepthOfFieldEnabled: boolean;
  57033. /**
  57034. * @ignore
  57035. * Specifies if the lens flare pipeline is enabed
  57036. */
  57037. LensFlareEnabled: boolean;
  57038. /**
  57039. * @ignore
  57040. * Specifies if the HDR pipeline is enabled
  57041. */
  57042. HDREnabled: boolean;
  57043. /**
  57044. * @ignore
  57045. * Specifies if the volumetric lights scattering effect is enabled
  57046. */
  57047. VLSEnabled: boolean;
  57048. /**
  57049. * @ignore
  57050. * Specifies if the motion blur effect is enabled
  57051. */
  57052. MotionBlurEnabled: boolean;
  57053. /**
  57054. * Specifies if anti-aliasing is enabled
  57055. */
  57056. fxaaEnabled: boolean;
  57057. /**
  57058. * Specifies the number of steps used to calculate the volumetric lights
  57059. * Typically in interval [50, 200]
  57060. */
  57061. volumetricLightStepsCount: number;
  57062. /**
  57063. * Specifies the number of samples used for the motion blur effect
  57064. * Typically in interval [16, 64]
  57065. */
  57066. motionBlurSamples: number;
  57067. /**
  57068. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57069. */
  57070. samples: number;
  57071. /**
  57072. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57073. * @constructor
  57074. * @param name The rendering pipeline name
  57075. * @param scene The scene linked to this pipeline
  57076. * @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)
  57077. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57078. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57079. */
  57080. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57081. private _buildPipeline;
  57082. private _createDownSampleX4PostProcess;
  57083. private _createBrightPassPostProcess;
  57084. private _createBlurPostProcesses;
  57085. private _createTextureAdderPostProcess;
  57086. private _createVolumetricLightPostProcess;
  57087. private _createLuminancePostProcesses;
  57088. private _createHdrPostProcess;
  57089. private _createLensFlarePostProcess;
  57090. private _createDepthOfFieldPostProcess;
  57091. private _createMotionBlurPostProcess;
  57092. private _getDepthTexture;
  57093. private _disposePostProcesses;
  57094. /**
  57095. * Dispose of the pipeline and stop all post processes
  57096. */
  57097. dispose(): void;
  57098. /**
  57099. * Serialize the rendering pipeline (Used when exporting)
  57100. * @returns the serialized object
  57101. */
  57102. serialize(): any;
  57103. /**
  57104. * Parse the serialized pipeline
  57105. * @param source Source pipeline.
  57106. * @param scene The scene to load the pipeline to.
  57107. * @param rootUrl The URL of the serialized pipeline.
  57108. * @returns An instantiated pipeline from the serialized object.
  57109. */
  57110. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57111. /**
  57112. * Luminance steps
  57113. */
  57114. static LuminanceSteps: number;
  57115. }
  57116. }
  57117. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  57118. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  57119. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  57120. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  57121. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  57122. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  57123. }
  57124. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  57125. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  57126. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57127. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  57128. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  57129. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  57130. }
  57131. declare module "babylonjs/Shaders/tonemap.fragment" {
  57132. /** @hidden */
  57133. export var tonemapPixelShader: {
  57134. name: string;
  57135. shader: string;
  57136. };
  57137. }
  57138. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  57139. import { Camera } from "babylonjs/Cameras/camera";
  57140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57141. import "babylonjs/Shaders/tonemap.fragment";
  57142. import { Engine } from "babylonjs/Engines/engine";
  57143. /** Defines operator used for tonemapping */
  57144. export enum TonemappingOperator {
  57145. /** Hable */
  57146. Hable = 0,
  57147. /** Reinhard */
  57148. Reinhard = 1,
  57149. /** HejiDawson */
  57150. HejiDawson = 2,
  57151. /** Photographic */
  57152. Photographic = 3
  57153. }
  57154. /**
  57155. * Defines a post process to apply tone mapping
  57156. */
  57157. export class TonemapPostProcess extends PostProcess {
  57158. private _operator;
  57159. /** Defines the required exposure adjustement */
  57160. exposureAdjustment: number;
  57161. /**
  57162. * Creates a new TonemapPostProcess
  57163. * @param name defines the name of the postprocess
  57164. * @param _operator defines the operator to use
  57165. * @param exposureAdjustment defines the required exposure adjustement
  57166. * @param camera defines the camera to use (can be null)
  57167. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57168. * @param engine defines the hosting engine (can be ignore if camera is set)
  57169. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57170. */
  57171. constructor(name: string, _operator: TonemappingOperator,
  57172. /** Defines the required exposure adjustement */
  57173. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57174. }
  57175. }
  57176. declare module "babylonjs/Shaders/depth.vertex" {
  57177. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57178. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57179. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57180. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57181. /** @hidden */
  57182. export var depthVertexShader: {
  57183. name: string;
  57184. shader: string;
  57185. };
  57186. }
  57187. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  57188. /** @hidden */
  57189. export var volumetricLightScatteringPixelShader: {
  57190. name: string;
  57191. shader: string;
  57192. };
  57193. }
  57194. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  57195. /** @hidden */
  57196. export var volumetricLightScatteringPassPixelShader: {
  57197. name: string;
  57198. shader: string;
  57199. };
  57200. }
  57201. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  57202. import { Vector3 } from "babylonjs/Maths/math";
  57203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57204. import { Mesh } from "babylonjs/Meshes/mesh";
  57205. import { Camera } from "babylonjs/Cameras/camera";
  57206. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57208. import { Scene } from "babylonjs/scene";
  57209. import "babylonjs/Meshes/Builders/planeBuilder";
  57210. import "babylonjs/Shaders/depth.vertex";
  57211. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  57212. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  57213. import { Engine } from "babylonjs/Engines/engine";
  57214. /**
  57215. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57216. */
  57217. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57218. private _volumetricLightScatteringPass;
  57219. private _volumetricLightScatteringRTT;
  57220. private _viewPort;
  57221. private _screenCoordinates;
  57222. private _cachedDefines;
  57223. /**
  57224. * If not undefined, the mesh position is computed from the attached node position
  57225. */
  57226. attachedNode: {
  57227. position: Vector3;
  57228. };
  57229. /**
  57230. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57231. */
  57232. customMeshPosition: Vector3;
  57233. /**
  57234. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57235. */
  57236. useCustomMeshPosition: boolean;
  57237. /**
  57238. * If the post-process should inverse the light scattering direction
  57239. */
  57240. invert: boolean;
  57241. /**
  57242. * The internal mesh used by the post-process
  57243. */
  57244. mesh: Mesh;
  57245. /**
  57246. * @hidden
  57247. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57248. */
  57249. useDiffuseColor: boolean;
  57250. /**
  57251. * Array containing the excluded meshes not rendered in the internal pass
  57252. */
  57253. excludedMeshes: AbstractMesh[];
  57254. /**
  57255. * Controls the overall intensity of the post-process
  57256. */
  57257. exposure: number;
  57258. /**
  57259. * Dissipates each sample's contribution in range [0, 1]
  57260. */
  57261. decay: number;
  57262. /**
  57263. * Controls the overall intensity of each sample
  57264. */
  57265. weight: number;
  57266. /**
  57267. * Controls the density of each sample
  57268. */
  57269. density: number;
  57270. /**
  57271. * @constructor
  57272. * @param name The post-process name
  57273. * @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)
  57274. * @param camera The camera that the post-process will be attached to
  57275. * @param mesh The mesh used to create the light scattering
  57276. * @param samples The post-process quality, default 100
  57277. * @param samplingModeThe post-process filtering mode
  57278. * @param engine The babylon engine
  57279. * @param reusable If the post-process is reusable
  57280. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57281. */
  57282. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57283. /**
  57284. * Returns the string "VolumetricLightScatteringPostProcess"
  57285. * @returns "VolumetricLightScatteringPostProcess"
  57286. */
  57287. getClassName(): string;
  57288. private _isReady;
  57289. /**
  57290. * Sets the new light position for light scattering effect
  57291. * @param position The new custom light position
  57292. */
  57293. setCustomMeshPosition(position: Vector3): void;
  57294. /**
  57295. * Returns the light position for light scattering effect
  57296. * @return Vector3 The custom light position
  57297. */
  57298. getCustomMeshPosition(): Vector3;
  57299. /**
  57300. * Disposes the internal assets and detaches the post-process from the camera
  57301. */
  57302. dispose(camera: Camera): void;
  57303. /**
  57304. * Returns the render target texture used by the post-process
  57305. * @return the render target texture used by the post-process
  57306. */
  57307. getPass(): RenderTargetTexture;
  57308. private _meshExcluded;
  57309. private _createPass;
  57310. private _updateMeshScreenCoordinates;
  57311. /**
  57312. * Creates a default mesh for the Volumeric Light Scattering post-process
  57313. * @param name The mesh name
  57314. * @param scene The scene where to create the mesh
  57315. * @return the default mesh
  57316. */
  57317. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57318. }
  57319. }
  57320. declare module "babylonjs/PostProcesses/index" {
  57321. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  57322. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  57323. export * from "babylonjs/PostProcesses/bloomEffect";
  57324. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  57325. export * from "babylonjs/PostProcesses/blurPostProcess";
  57326. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  57327. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  57328. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  57329. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  57330. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57331. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  57332. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  57333. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  57334. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57335. export * from "babylonjs/PostProcesses/filterPostProcess";
  57336. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  57337. export * from "babylonjs/PostProcesses/grainPostProcess";
  57338. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  57339. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  57340. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  57341. export * from "babylonjs/PostProcesses/passPostProcess";
  57342. export * from "babylonjs/PostProcesses/postProcess";
  57343. export * from "babylonjs/PostProcesses/postProcessManager";
  57344. export * from "babylonjs/PostProcesses/refractionPostProcess";
  57345. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  57346. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  57347. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  57348. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  57349. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  57350. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  57351. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  57352. }
  57353. declare module "babylonjs/Probes/index" {
  57354. export * from "babylonjs/Probes/reflectionProbe";
  57355. }
  57356. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  57357. import { Scene } from "babylonjs/scene";
  57358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57359. import { Color3 } from "babylonjs/Maths/math";
  57360. import { SmartArray } from "babylonjs/Misc/smartArray";
  57361. import { ISceneComponent } from "babylonjs/sceneComponent";
  57362. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  57363. import "babylonjs/Meshes/Builders/boxBuilder";
  57364. import "babylonjs/Shaders/color.fragment";
  57365. import "babylonjs/Shaders/color.vertex";
  57366. module "babylonjs/scene" {
  57367. interface Scene {
  57368. /** @hidden (Backing field) */
  57369. _boundingBoxRenderer: BoundingBoxRenderer;
  57370. /** @hidden (Backing field) */
  57371. _forceShowBoundingBoxes: boolean;
  57372. /**
  57373. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57374. */
  57375. forceShowBoundingBoxes: boolean;
  57376. /**
  57377. * Gets the bounding box renderer associated with the scene
  57378. * @returns a BoundingBoxRenderer
  57379. */
  57380. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57381. }
  57382. }
  57383. module "babylonjs/Meshes/abstractMesh" {
  57384. interface AbstractMesh {
  57385. /** @hidden (Backing field) */
  57386. _showBoundingBox: boolean;
  57387. /**
  57388. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57389. */
  57390. showBoundingBox: boolean;
  57391. }
  57392. }
  57393. /**
  57394. * Component responsible of rendering the bounding box of the meshes in a scene.
  57395. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57396. */
  57397. export class BoundingBoxRenderer implements ISceneComponent {
  57398. /**
  57399. * The component name helpfull to identify the component in the list of scene components.
  57400. */
  57401. readonly name: string;
  57402. /**
  57403. * The scene the component belongs to.
  57404. */
  57405. scene: Scene;
  57406. /**
  57407. * Color of the bounding box lines placed in front of an object
  57408. */
  57409. frontColor: Color3;
  57410. /**
  57411. * Color of the bounding box lines placed behind an object
  57412. */
  57413. backColor: Color3;
  57414. /**
  57415. * Defines if the renderer should show the back lines or not
  57416. */
  57417. showBackLines: boolean;
  57418. /**
  57419. * @hidden
  57420. */
  57421. renderList: SmartArray<BoundingBox>;
  57422. private _colorShader;
  57423. private _vertexBuffers;
  57424. private _indexBuffer;
  57425. /**
  57426. * Instantiates a new bounding box renderer in a scene.
  57427. * @param scene the scene the renderer renders in
  57428. */
  57429. constructor(scene: Scene);
  57430. /**
  57431. * Registers the component in a given scene
  57432. */
  57433. register(): void;
  57434. private _evaluateSubMesh;
  57435. private _activeMesh;
  57436. private _prepareRessources;
  57437. private _createIndexBuffer;
  57438. /**
  57439. * Rebuilds the elements related to this component in case of
  57440. * context lost for instance.
  57441. */
  57442. rebuild(): void;
  57443. /**
  57444. * @hidden
  57445. */
  57446. reset(): void;
  57447. /**
  57448. * Render the bounding boxes of a specific rendering group
  57449. * @param renderingGroupId defines the rendering group to render
  57450. */
  57451. render(renderingGroupId: number): void;
  57452. /**
  57453. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57454. * @param mesh Define the mesh to render the occlusion bounding box for
  57455. */
  57456. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57457. /**
  57458. * Dispose and release the resources attached to this renderer.
  57459. */
  57460. dispose(): void;
  57461. }
  57462. }
  57463. declare module "babylonjs/Shaders/depth.fragment" {
  57464. /** @hidden */
  57465. export var depthPixelShader: {
  57466. name: string;
  57467. shader: string;
  57468. };
  57469. }
  57470. declare module "babylonjs/Rendering/depthRenderer" {
  57471. import { Nullable } from "babylonjs/types";
  57472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57473. import { Scene } from "babylonjs/scene";
  57474. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57475. import { Camera } from "babylonjs/Cameras/camera";
  57476. import "babylonjs/Shaders/depth.fragment";
  57477. import "babylonjs/Shaders/depth.vertex";
  57478. /**
  57479. * This represents a depth renderer in Babylon.
  57480. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57481. */
  57482. export class DepthRenderer {
  57483. private _scene;
  57484. private _depthMap;
  57485. private _effect;
  57486. private _cachedDefines;
  57487. private _camera;
  57488. /**
  57489. * Specifiess that the depth renderer will only be used within
  57490. * the camera it is created for.
  57491. * This can help forcing its rendering during the camera processing.
  57492. */
  57493. useOnlyInActiveCamera: boolean;
  57494. /** @hidden */
  57495. static _SceneComponentInitialization: (scene: Scene) => void;
  57496. /**
  57497. * Instantiates a depth renderer
  57498. * @param scene The scene the renderer belongs to
  57499. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57500. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57501. */
  57502. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57503. /**
  57504. * Creates the depth rendering effect and checks if the effect is ready.
  57505. * @param subMesh The submesh to be used to render the depth map of
  57506. * @param useInstances If multiple world instances should be used
  57507. * @returns if the depth renderer is ready to render the depth map
  57508. */
  57509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57510. /**
  57511. * Gets the texture which the depth map will be written to.
  57512. * @returns The depth map texture
  57513. */
  57514. getDepthMap(): RenderTargetTexture;
  57515. /**
  57516. * Disposes of the depth renderer.
  57517. */
  57518. dispose(): void;
  57519. }
  57520. }
  57521. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57522. import { Nullable } from "babylonjs/types";
  57523. import { Scene } from "babylonjs/scene";
  57524. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57525. import { Camera } from "babylonjs/Cameras/camera";
  57526. import { ISceneComponent } from "babylonjs/sceneComponent";
  57527. module "babylonjs/scene" {
  57528. interface Scene {
  57529. /** @hidden (Backing field) */
  57530. _depthRenderer: {
  57531. [id: string]: DepthRenderer;
  57532. };
  57533. /**
  57534. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57535. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57536. * @returns the created depth renderer
  57537. */
  57538. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57539. /**
  57540. * Disables a depth renderer for a given camera
  57541. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57542. */
  57543. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57544. }
  57545. }
  57546. /**
  57547. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57548. * in several rendering techniques.
  57549. */
  57550. export class DepthRendererSceneComponent implements ISceneComponent {
  57551. /**
  57552. * The component name helpfull to identify the component in the list of scene components.
  57553. */
  57554. readonly name: string;
  57555. /**
  57556. * The scene the component belongs to.
  57557. */
  57558. scene: Scene;
  57559. /**
  57560. * Creates a new instance of the component for the given scene
  57561. * @param scene Defines the scene to register the component in
  57562. */
  57563. constructor(scene: Scene);
  57564. /**
  57565. * Registers the component in a given scene
  57566. */
  57567. register(): void;
  57568. /**
  57569. * Rebuilds the elements related to this component in case of
  57570. * context lost for instance.
  57571. */
  57572. rebuild(): void;
  57573. /**
  57574. * Disposes the component and the associated ressources
  57575. */
  57576. dispose(): void;
  57577. private _gatherRenderTargets;
  57578. private _gatherActiveCameraRenderTargets;
  57579. }
  57580. }
  57581. declare module "babylonjs/Shaders/outline.fragment" {
  57582. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57583. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57584. /** @hidden */
  57585. export var outlinePixelShader: {
  57586. name: string;
  57587. shader: string;
  57588. };
  57589. }
  57590. declare module "babylonjs/Shaders/outline.vertex" {
  57591. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57592. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57593. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57594. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57595. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57596. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57597. /** @hidden */
  57598. export var outlineVertexShader: {
  57599. name: string;
  57600. shader: string;
  57601. };
  57602. }
  57603. declare module "babylonjs/Rendering/outlineRenderer" {
  57604. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57605. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57606. import { Scene } from "babylonjs/scene";
  57607. import { ISceneComponent } from "babylonjs/sceneComponent";
  57608. import "babylonjs/Shaders/outline.fragment";
  57609. import "babylonjs/Shaders/outline.vertex";
  57610. module "babylonjs/scene" {
  57611. interface Scene {
  57612. /** @hidden */
  57613. _outlineRenderer: OutlineRenderer;
  57614. /**
  57615. * Gets the outline renderer associated with the scene
  57616. * @returns a OutlineRenderer
  57617. */
  57618. getOutlineRenderer(): OutlineRenderer;
  57619. }
  57620. }
  57621. module "babylonjs/Meshes/abstractMesh" {
  57622. interface AbstractMesh {
  57623. /** @hidden (Backing field) */
  57624. _renderOutline: boolean;
  57625. /**
  57626. * Gets or sets a boolean indicating if the outline must be rendered as well
  57627. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57628. */
  57629. renderOutline: boolean;
  57630. /** @hidden (Backing field) */
  57631. _renderOverlay: boolean;
  57632. /**
  57633. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57634. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57635. */
  57636. renderOverlay: boolean;
  57637. }
  57638. }
  57639. /**
  57640. * This class is responsible to draw bothe outline/overlay of meshes.
  57641. * It should not be used directly but through the available method on mesh.
  57642. */
  57643. export class OutlineRenderer implements ISceneComponent {
  57644. /**
  57645. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57646. */
  57647. private static _StencilReference;
  57648. /**
  57649. * The name of the component. Each component must have a unique name.
  57650. */
  57651. name: string;
  57652. /**
  57653. * The scene the component belongs to.
  57654. */
  57655. scene: Scene;
  57656. /**
  57657. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57658. */
  57659. zOffset: number;
  57660. private _engine;
  57661. private _effect;
  57662. private _cachedDefines;
  57663. private _savedDepthWrite;
  57664. /**
  57665. * Instantiates a new outline renderer. (There could be only one per scene).
  57666. * @param scene Defines the scene it belongs to
  57667. */
  57668. constructor(scene: Scene);
  57669. /**
  57670. * Register the component to one instance of a scene.
  57671. */
  57672. register(): void;
  57673. /**
  57674. * Rebuilds the elements related to this component in case of
  57675. * context lost for instance.
  57676. */
  57677. rebuild(): void;
  57678. /**
  57679. * Disposes the component and the associated ressources.
  57680. */
  57681. dispose(): void;
  57682. /**
  57683. * Renders the outline in the canvas.
  57684. * @param subMesh Defines the sumesh to render
  57685. * @param batch Defines the batch of meshes in case of instances
  57686. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57687. */
  57688. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57689. /**
  57690. * Returns whether or not the outline renderer is ready for a given submesh.
  57691. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57692. * @param subMesh Defines the submesh to check readyness for
  57693. * @param useInstances Defines wheter wee are trying to render instances or not
  57694. * @returns true if ready otherwise false
  57695. */
  57696. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57697. private _beforeRenderingMesh;
  57698. private _afterRenderingMesh;
  57699. }
  57700. }
  57701. declare module "babylonjs/Rendering/index" {
  57702. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57703. export * from "babylonjs/Rendering/depthRenderer";
  57704. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57705. export * from "babylonjs/Rendering/edgesRenderer";
  57706. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57707. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57708. export * from "babylonjs/Rendering/outlineRenderer";
  57709. export * from "babylonjs/Rendering/renderingGroup";
  57710. export * from "babylonjs/Rendering/renderingManager";
  57711. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57712. }
  57713. declare module "babylonjs/Sprites/index" {
  57714. export * from "babylonjs/Sprites/sprite";
  57715. export * from "babylonjs/Sprites/spriteManager";
  57716. export * from "babylonjs/Sprites/spriteSceneComponent";
  57717. }
  57718. declare module "babylonjs/Misc/assetsManager" {
  57719. import { Scene } from "babylonjs/scene";
  57720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57721. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57722. import { Skeleton } from "babylonjs/Bones/skeleton";
  57723. import { Observable } from "babylonjs/Misc/observable";
  57724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57725. import { Texture } from "babylonjs/Materials/Textures/texture";
  57726. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57727. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57728. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57729. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57730. /**
  57731. * Defines the list of states available for a task inside a AssetsManager
  57732. */
  57733. export enum AssetTaskState {
  57734. /**
  57735. * Initialization
  57736. */
  57737. INIT = 0,
  57738. /**
  57739. * Running
  57740. */
  57741. RUNNING = 1,
  57742. /**
  57743. * Done
  57744. */
  57745. DONE = 2,
  57746. /**
  57747. * Error
  57748. */
  57749. ERROR = 3
  57750. }
  57751. /**
  57752. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57753. */
  57754. export abstract class AbstractAssetTask {
  57755. /**
  57756. * Task name
  57757. */ name: string;
  57758. /**
  57759. * Callback called when the task is successful
  57760. */
  57761. onSuccess: (task: any) => void;
  57762. /**
  57763. * Callback called when the task is not successful
  57764. */
  57765. onError: (task: any, message?: string, exception?: any) => void;
  57766. /**
  57767. * Creates a new AssetsManager
  57768. * @param name defines the name of the task
  57769. */
  57770. constructor(
  57771. /**
  57772. * Task name
  57773. */ name: string);
  57774. private _isCompleted;
  57775. private _taskState;
  57776. private _errorObject;
  57777. /**
  57778. * Get if the task is completed
  57779. */
  57780. readonly isCompleted: boolean;
  57781. /**
  57782. * Gets the current state of the task
  57783. */
  57784. readonly taskState: AssetTaskState;
  57785. /**
  57786. * Gets the current error object (if task is in error)
  57787. */
  57788. readonly errorObject: {
  57789. message?: string;
  57790. exception?: any;
  57791. };
  57792. /**
  57793. * Internal only
  57794. * @hidden
  57795. */
  57796. _setErrorObject(message?: string, exception?: any): void;
  57797. /**
  57798. * Execute the current task
  57799. * @param scene defines the scene where you want your assets to be loaded
  57800. * @param onSuccess is a callback called when the task is successfully executed
  57801. * @param onError is a callback called if an error occurs
  57802. */
  57803. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57804. /**
  57805. * Execute the current task
  57806. * @param scene defines the scene where you want your assets to be loaded
  57807. * @param onSuccess is a callback called when the task is successfully executed
  57808. * @param onError is a callback called if an error occurs
  57809. */
  57810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57811. /**
  57812. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57813. * This can be used with failed tasks that have the reason for failure fixed.
  57814. */
  57815. reset(): void;
  57816. private onErrorCallback;
  57817. private onDoneCallback;
  57818. }
  57819. /**
  57820. * Define the interface used by progress events raised during assets loading
  57821. */
  57822. export interface IAssetsProgressEvent {
  57823. /**
  57824. * Defines the number of remaining tasks to process
  57825. */
  57826. remainingCount: number;
  57827. /**
  57828. * Defines the total number of tasks
  57829. */
  57830. totalCount: number;
  57831. /**
  57832. * Defines the task that was just processed
  57833. */
  57834. task: AbstractAssetTask;
  57835. }
  57836. /**
  57837. * Class used to share progress information about assets loading
  57838. */
  57839. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57840. /**
  57841. * Defines the number of remaining tasks to process
  57842. */
  57843. remainingCount: number;
  57844. /**
  57845. * Defines the total number of tasks
  57846. */
  57847. totalCount: number;
  57848. /**
  57849. * Defines the task that was just processed
  57850. */
  57851. task: AbstractAssetTask;
  57852. /**
  57853. * Creates a AssetsProgressEvent
  57854. * @param remainingCount defines the number of remaining tasks to process
  57855. * @param totalCount defines the total number of tasks
  57856. * @param task defines the task that was just processed
  57857. */
  57858. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57859. }
  57860. /**
  57861. * Define a task used by AssetsManager to load meshes
  57862. */
  57863. export class MeshAssetTask extends AbstractAssetTask {
  57864. /**
  57865. * Defines the name of the task
  57866. */
  57867. name: string;
  57868. /**
  57869. * Defines the list of mesh's names you want to load
  57870. */
  57871. meshesNames: any;
  57872. /**
  57873. * Defines the root url to use as a base to load your meshes and associated resources
  57874. */
  57875. rootUrl: string;
  57876. /**
  57877. * Defines the filename of the scene to load from
  57878. */
  57879. sceneFilename: string;
  57880. /**
  57881. * Gets the list of loaded meshes
  57882. */
  57883. loadedMeshes: Array<AbstractMesh>;
  57884. /**
  57885. * Gets the list of loaded particle systems
  57886. */
  57887. loadedParticleSystems: Array<IParticleSystem>;
  57888. /**
  57889. * Gets the list of loaded skeletons
  57890. */
  57891. loadedSkeletons: Array<Skeleton>;
  57892. /**
  57893. * Gets the list of loaded animation groups
  57894. */
  57895. loadedAnimationGroups: Array<AnimationGroup>;
  57896. /**
  57897. * Callback called when the task is successful
  57898. */
  57899. onSuccess: (task: MeshAssetTask) => void;
  57900. /**
  57901. * Callback called when the task is successful
  57902. */
  57903. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57904. /**
  57905. * Creates a new MeshAssetTask
  57906. * @param name defines the name of the task
  57907. * @param meshesNames defines the list of mesh's names you want to load
  57908. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57909. * @param sceneFilename defines the filename of the scene to load from
  57910. */
  57911. constructor(
  57912. /**
  57913. * Defines the name of the task
  57914. */
  57915. name: string,
  57916. /**
  57917. * Defines the list of mesh's names you want to load
  57918. */
  57919. meshesNames: any,
  57920. /**
  57921. * Defines the root url to use as a base to load your meshes and associated resources
  57922. */
  57923. rootUrl: string,
  57924. /**
  57925. * Defines the filename of the scene to load from
  57926. */
  57927. sceneFilename: string);
  57928. /**
  57929. * Execute the current task
  57930. * @param scene defines the scene where you want your assets to be loaded
  57931. * @param onSuccess is a callback called when the task is successfully executed
  57932. * @param onError is a callback called if an error occurs
  57933. */
  57934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57935. }
  57936. /**
  57937. * Define a task used by AssetsManager to load text content
  57938. */
  57939. export class TextFileAssetTask extends AbstractAssetTask {
  57940. /**
  57941. * Defines the name of the task
  57942. */
  57943. name: string;
  57944. /**
  57945. * Defines the location of the file to load
  57946. */
  57947. url: string;
  57948. /**
  57949. * Gets the loaded text string
  57950. */
  57951. text: string;
  57952. /**
  57953. * Callback called when the task is successful
  57954. */
  57955. onSuccess: (task: TextFileAssetTask) => void;
  57956. /**
  57957. * Callback called when the task is successful
  57958. */
  57959. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57960. /**
  57961. * Creates a new TextFileAssetTask object
  57962. * @param name defines the name of the task
  57963. * @param url defines the location of the file to load
  57964. */
  57965. constructor(
  57966. /**
  57967. * Defines the name of the task
  57968. */
  57969. name: string,
  57970. /**
  57971. * Defines the location of the file to load
  57972. */
  57973. url: string);
  57974. /**
  57975. * Execute the current task
  57976. * @param scene defines the scene where you want your assets to be loaded
  57977. * @param onSuccess is a callback called when the task is successfully executed
  57978. * @param onError is a callback called if an error occurs
  57979. */
  57980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57981. }
  57982. /**
  57983. * Define a task used by AssetsManager to load binary data
  57984. */
  57985. export class BinaryFileAssetTask extends AbstractAssetTask {
  57986. /**
  57987. * Defines the name of the task
  57988. */
  57989. name: string;
  57990. /**
  57991. * Defines the location of the file to load
  57992. */
  57993. url: string;
  57994. /**
  57995. * Gets the lodaded data (as an array buffer)
  57996. */
  57997. data: ArrayBuffer;
  57998. /**
  57999. * Callback called when the task is successful
  58000. */
  58001. onSuccess: (task: BinaryFileAssetTask) => void;
  58002. /**
  58003. * Callback called when the task is successful
  58004. */
  58005. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58006. /**
  58007. * Creates a new BinaryFileAssetTask object
  58008. * @param name defines the name of the new task
  58009. * @param url defines the location of the file to load
  58010. */
  58011. constructor(
  58012. /**
  58013. * Defines the name of the task
  58014. */
  58015. name: string,
  58016. /**
  58017. * Defines the location of the file to load
  58018. */
  58019. url: string);
  58020. /**
  58021. * Execute the current task
  58022. * @param scene defines the scene where you want your assets to be loaded
  58023. * @param onSuccess is a callback called when the task is successfully executed
  58024. * @param onError is a callback called if an error occurs
  58025. */
  58026. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58027. }
  58028. /**
  58029. * Define a task used by AssetsManager to load images
  58030. */
  58031. export class ImageAssetTask extends AbstractAssetTask {
  58032. /**
  58033. * Defines the name of the task
  58034. */
  58035. name: string;
  58036. /**
  58037. * Defines the location of the image to load
  58038. */
  58039. url: string;
  58040. /**
  58041. * Gets the loaded images
  58042. */
  58043. image: HTMLImageElement;
  58044. /**
  58045. * Callback called when the task is successful
  58046. */
  58047. onSuccess: (task: ImageAssetTask) => void;
  58048. /**
  58049. * Callback called when the task is successful
  58050. */
  58051. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58052. /**
  58053. * Creates a new ImageAssetTask
  58054. * @param name defines the name of the task
  58055. * @param url defines the location of the image to load
  58056. */
  58057. constructor(
  58058. /**
  58059. * Defines the name of the task
  58060. */
  58061. name: string,
  58062. /**
  58063. * Defines the location of the image to load
  58064. */
  58065. url: string);
  58066. /**
  58067. * Execute the current task
  58068. * @param scene defines the scene where you want your assets to be loaded
  58069. * @param onSuccess is a callback called when the task is successfully executed
  58070. * @param onError is a callback called if an error occurs
  58071. */
  58072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58073. }
  58074. /**
  58075. * Defines the interface used by texture loading tasks
  58076. */
  58077. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58078. /**
  58079. * Gets the loaded texture
  58080. */
  58081. texture: TEX;
  58082. }
  58083. /**
  58084. * Define a task used by AssetsManager to load 2D textures
  58085. */
  58086. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58087. /**
  58088. * Defines the name of the task
  58089. */
  58090. name: string;
  58091. /**
  58092. * Defines the location of the file to load
  58093. */
  58094. url: string;
  58095. /**
  58096. * Defines if mipmap should not be generated (default is false)
  58097. */
  58098. noMipmap?: boolean | undefined;
  58099. /**
  58100. * Defines if texture must be inverted on Y axis (default is false)
  58101. */
  58102. invertY?: boolean | undefined;
  58103. /**
  58104. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58105. */
  58106. samplingMode: number;
  58107. /**
  58108. * Gets the loaded texture
  58109. */
  58110. texture: Texture;
  58111. /**
  58112. * Callback called when the task is successful
  58113. */
  58114. onSuccess: (task: TextureAssetTask) => void;
  58115. /**
  58116. * Callback called when the task is successful
  58117. */
  58118. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58119. /**
  58120. * Creates a new TextureAssetTask object
  58121. * @param name defines the name of the task
  58122. * @param url defines the location of the file to load
  58123. * @param noMipmap defines if mipmap should not be generated (default is false)
  58124. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58125. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58126. */
  58127. constructor(
  58128. /**
  58129. * Defines the name of the task
  58130. */
  58131. name: string,
  58132. /**
  58133. * Defines the location of the file to load
  58134. */
  58135. url: string,
  58136. /**
  58137. * Defines if mipmap should not be generated (default is false)
  58138. */
  58139. noMipmap?: boolean | undefined,
  58140. /**
  58141. * Defines if texture must be inverted on Y axis (default is false)
  58142. */
  58143. invertY?: boolean | undefined,
  58144. /**
  58145. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58146. */
  58147. samplingMode?: number);
  58148. /**
  58149. * Execute the current task
  58150. * @param scene defines the scene where you want your assets to be loaded
  58151. * @param onSuccess is a callback called when the task is successfully executed
  58152. * @param onError is a callback called if an error occurs
  58153. */
  58154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58155. }
  58156. /**
  58157. * Define a task used by AssetsManager to load cube textures
  58158. */
  58159. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58160. /**
  58161. * Defines the name of the task
  58162. */
  58163. name: string;
  58164. /**
  58165. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58166. */
  58167. url: string;
  58168. /**
  58169. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58170. */
  58171. extensions?: string[] | undefined;
  58172. /**
  58173. * Defines if mipmaps should not be generated (default is false)
  58174. */
  58175. noMipmap?: boolean | undefined;
  58176. /**
  58177. * Defines the explicit list of files (undefined by default)
  58178. */
  58179. files?: string[] | undefined;
  58180. /**
  58181. * Gets the loaded texture
  58182. */
  58183. texture: CubeTexture;
  58184. /**
  58185. * Callback called when the task is successful
  58186. */
  58187. onSuccess: (task: CubeTextureAssetTask) => void;
  58188. /**
  58189. * Callback called when the task is successful
  58190. */
  58191. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58192. /**
  58193. * Creates a new CubeTextureAssetTask
  58194. * @param name defines the name of the task
  58195. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58196. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58197. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58198. * @param files defines the explicit list of files (undefined by default)
  58199. */
  58200. constructor(
  58201. /**
  58202. * Defines the name of the task
  58203. */
  58204. name: string,
  58205. /**
  58206. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58207. */
  58208. url: string,
  58209. /**
  58210. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58211. */
  58212. extensions?: string[] | undefined,
  58213. /**
  58214. * Defines if mipmaps should not be generated (default is false)
  58215. */
  58216. noMipmap?: boolean | undefined,
  58217. /**
  58218. * Defines the explicit list of files (undefined by default)
  58219. */
  58220. files?: string[] | undefined);
  58221. /**
  58222. * Execute the current task
  58223. * @param scene defines the scene where you want your assets to be loaded
  58224. * @param onSuccess is a callback called when the task is successfully executed
  58225. * @param onError is a callback called if an error occurs
  58226. */
  58227. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58228. }
  58229. /**
  58230. * Define a task used by AssetsManager to load HDR cube textures
  58231. */
  58232. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58233. /**
  58234. * Defines the name of the task
  58235. */
  58236. name: string;
  58237. /**
  58238. * Defines the location of the file to load
  58239. */
  58240. url: string;
  58241. /**
  58242. * Defines the desired size (the more it increases the longer the generation will be)
  58243. */
  58244. size: number;
  58245. /**
  58246. * Defines if mipmaps should not be generated (default is false)
  58247. */
  58248. noMipmap: boolean;
  58249. /**
  58250. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58251. */
  58252. generateHarmonics: boolean;
  58253. /**
  58254. * 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)
  58255. */
  58256. gammaSpace: boolean;
  58257. /**
  58258. * Internal Use Only
  58259. */
  58260. reserved: boolean;
  58261. /**
  58262. * Gets the loaded texture
  58263. */
  58264. texture: HDRCubeTexture;
  58265. /**
  58266. * Callback called when the task is successful
  58267. */
  58268. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58269. /**
  58270. * Callback called when the task is successful
  58271. */
  58272. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58273. /**
  58274. * Creates a new HDRCubeTextureAssetTask object
  58275. * @param name defines the name of the task
  58276. * @param url defines the location of the file to load
  58277. * @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.
  58278. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58279. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58280. * @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)
  58281. * @param reserved Internal use only
  58282. */
  58283. constructor(
  58284. /**
  58285. * Defines the name of the task
  58286. */
  58287. name: string,
  58288. /**
  58289. * Defines the location of the file to load
  58290. */
  58291. url: string,
  58292. /**
  58293. * Defines the desired size (the more it increases the longer the generation will be)
  58294. */
  58295. size: number,
  58296. /**
  58297. * Defines if mipmaps should not be generated (default is false)
  58298. */
  58299. noMipmap?: boolean,
  58300. /**
  58301. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58302. */
  58303. generateHarmonics?: boolean,
  58304. /**
  58305. * 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)
  58306. */
  58307. gammaSpace?: boolean,
  58308. /**
  58309. * Internal Use Only
  58310. */
  58311. reserved?: boolean);
  58312. /**
  58313. * Execute the current task
  58314. * @param scene defines the scene where you want your assets to be loaded
  58315. * @param onSuccess is a callback called when the task is successfully executed
  58316. * @param onError is a callback called if an error occurs
  58317. */
  58318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58319. }
  58320. /**
  58321. * Define a task used by AssetsManager to load Equirectangular cube textures
  58322. */
  58323. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58324. /**
  58325. * Defines the name of the task
  58326. */
  58327. name: string;
  58328. /**
  58329. * Defines the location of the file to load
  58330. */
  58331. url: string;
  58332. /**
  58333. * Defines the desired size (the more it increases the longer the generation will be)
  58334. */
  58335. size: number;
  58336. /**
  58337. * Defines if mipmaps should not be generated (default is false)
  58338. */
  58339. noMipmap: boolean;
  58340. /**
  58341. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58342. * but the standard material would require them in Gamma space) (default is true)
  58343. */
  58344. gammaSpace: boolean;
  58345. /**
  58346. * Gets the loaded texture
  58347. */
  58348. texture: EquiRectangularCubeTexture;
  58349. /**
  58350. * Callback called when the task is successful
  58351. */
  58352. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58353. /**
  58354. * Callback called when the task is successful
  58355. */
  58356. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58357. /**
  58358. * Creates a new EquiRectangularCubeTextureAssetTask object
  58359. * @param name defines the name of the task
  58360. * @param url defines the location of the file to load
  58361. * @param size defines the desired size (the more it increases the longer the generation will be)
  58362. * If the size is omitted this implies you are using a preprocessed cubemap.
  58363. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58364. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58365. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58366. * (default is true)
  58367. */
  58368. constructor(
  58369. /**
  58370. * Defines the name of the task
  58371. */
  58372. name: string,
  58373. /**
  58374. * Defines the location of the file to load
  58375. */
  58376. url: string,
  58377. /**
  58378. * Defines the desired size (the more it increases the longer the generation will be)
  58379. */
  58380. size: number,
  58381. /**
  58382. * Defines if mipmaps should not be generated (default is false)
  58383. */
  58384. noMipmap?: boolean,
  58385. /**
  58386. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58387. * but the standard material would require them in Gamma space) (default is true)
  58388. */
  58389. gammaSpace?: boolean);
  58390. /**
  58391. * Execute the current task
  58392. * @param scene defines the scene where you want your assets to be loaded
  58393. * @param onSuccess is a callback called when the task is successfully executed
  58394. * @param onError is a callback called if an error occurs
  58395. */
  58396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58397. }
  58398. /**
  58399. * This class can be used to easily import assets into a scene
  58400. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58401. */
  58402. export class AssetsManager {
  58403. private _scene;
  58404. private _isLoading;
  58405. protected _tasks: AbstractAssetTask[];
  58406. protected _waitingTasksCount: number;
  58407. protected _totalTasksCount: number;
  58408. /**
  58409. * Callback called when all tasks are processed
  58410. */
  58411. onFinish: (tasks: AbstractAssetTask[]) => void;
  58412. /**
  58413. * Callback called when a task is successful
  58414. */
  58415. onTaskSuccess: (task: AbstractAssetTask) => void;
  58416. /**
  58417. * Callback called when a task had an error
  58418. */
  58419. onTaskError: (task: AbstractAssetTask) => void;
  58420. /**
  58421. * Callback called when a task is done (whatever the result is)
  58422. */
  58423. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58424. /**
  58425. * Observable called when all tasks are processed
  58426. */
  58427. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58428. /**
  58429. * Observable called when a task had an error
  58430. */
  58431. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58432. /**
  58433. * Observable called when all tasks were executed
  58434. */
  58435. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58436. /**
  58437. * Observable called when a task is done (whatever the result is)
  58438. */
  58439. onProgressObservable: Observable<IAssetsProgressEvent>;
  58440. /**
  58441. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58442. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58443. */
  58444. useDefaultLoadingScreen: boolean;
  58445. /**
  58446. * Creates a new AssetsManager
  58447. * @param scene defines the scene to work on
  58448. */
  58449. constructor(scene: Scene);
  58450. /**
  58451. * Add a MeshAssetTask to the list of active tasks
  58452. * @param taskName defines the name of the new task
  58453. * @param meshesNames defines the name of meshes to load
  58454. * @param rootUrl defines the root url to use to locate files
  58455. * @param sceneFilename defines the filename of the scene file
  58456. * @returns a new MeshAssetTask object
  58457. */
  58458. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58459. /**
  58460. * Add a TextFileAssetTask to the list of active tasks
  58461. * @param taskName defines the name of the new task
  58462. * @param url defines the url of the file to load
  58463. * @returns a new TextFileAssetTask object
  58464. */
  58465. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58466. /**
  58467. * Add a BinaryFileAssetTask to the list of active tasks
  58468. * @param taskName defines the name of the new task
  58469. * @param url defines the url of the file to load
  58470. * @returns a new BinaryFileAssetTask object
  58471. */
  58472. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58473. /**
  58474. * Add a ImageAssetTask to the list of active tasks
  58475. * @param taskName defines the name of the new task
  58476. * @param url defines the url of the file to load
  58477. * @returns a new ImageAssetTask object
  58478. */
  58479. addImageTask(taskName: string, url: string): ImageAssetTask;
  58480. /**
  58481. * Add a TextureAssetTask to the list of active tasks
  58482. * @param taskName defines the name of the new task
  58483. * @param url defines the url of the file to load
  58484. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58485. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58486. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58487. * @returns a new TextureAssetTask object
  58488. */
  58489. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58490. /**
  58491. * Add a CubeTextureAssetTask to the list of active tasks
  58492. * @param taskName defines the name of the new task
  58493. * @param url defines the url of the file to load
  58494. * @param extensions defines the extension to use to load the cube map (can be null)
  58495. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58496. * @param files defines the list of files to load (can be null)
  58497. * @returns a new CubeTextureAssetTask object
  58498. */
  58499. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58500. /**
  58501. *
  58502. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58503. * @param taskName defines the name of the new task
  58504. * @param url defines the url of the file to load
  58505. * @param size defines the size you want for the cubemap (can be null)
  58506. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58507. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58508. * @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)
  58509. * @param reserved Internal use only
  58510. * @returns a new HDRCubeTextureAssetTask object
  58511. */
  58512. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58513. /**
  58514. *
  58515. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58516. * @param taskName defines the name of the new task
  58517. * @param url defines the url of the file to load
  58518. * @param size defines the size you want for the cubemap (can be null)
  58519. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58520. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58521. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58522. * @returns a new EquiRectangularCubeTextureAssetTask object
  58523. */
  58524. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58525. /**
  58526. * Remove a task from the assets manager.
  58527. * @param task the task to remove
  58528. */
  58529. removeTask(task: AbstractAssetTask): void;
  58530. private _decreaseWaitingTasksCount;
  58531. private _runTask;
  58532. /**
  58533. * Reset the AssetsManager and remove all tasks
  58534. * @return the current instance of the AssetsManager
  58535. */
  58536. reset(): AssetsManager;
  58537. /**
  58538. * Start the loading process
  58539. * @return the current instance of the AssetsManager
  58540. */
  58541. load(): AssetsManager;
  58542. /**
  58543. * Start the loading process as an async operation
  58544. * @return a promise returning the list of failed tasks
  58545. */
  58546. loadAsync(): Promise<void>;
  58547. }
  58548. }
  58549. declare module "babylonjs/Misc/deferred" {
  58550. /**
  58551. * Wrapper class for promise with external resolve and reject.
  58552. */
  58553. export class Deferred<T> {
  58554. /**
  58555. * The promise associated with this deferred object.
  58556. */
  58557. readonly promise: Promise<T>;
  58558. private _resolve;
  58559. private _reject;
  58560. /**
  58561. * The resolve method of the promise associated with this deferred object.
  58562. */
  58563. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58564. /**
  58565. * The reject method of the promise associated with this deferred object.
  58566. */
  58567. readonly reject: (reason?: any) => void;
  58568. /**
  58569. * Constructor for this deferred object.
  58570. */
  58571. constructor();
  58572. }
  58573. }
  58574. declare module "babylonjs/Misc/meshExploder" {
  58575. import { Mesh } from "babylonjs/Meshes/mesh";
  58576. /**
  58577. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58578. */
  58579. export class MeshExploder {
  58580. private _centerMesh;
  58581. private _meshes;
  58582. private _meshesOrigins;
  58583. private _toCenterVectors;
  58584. private _scaledDirection;
  58585. private _newPosition;
  58586. private _centerPosition;
  58587. /**
  58588. * Explodes meshes from a center mesh.
  58589. * @param meshes The meshes to explode.
  58590. * @param centerMesh The mesh to be center of explosion.
  58591. */
  58592. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58593. private _setCenterMesh;
  58594. /**
  58595. * Get class name
  58596. * @returns "MeshExploder"
  58597. */
  58598. getClassName(): string;
  58599. /**
  58600. * "Exploded meshes"
  58601. * @returns Array of meshes with the centerMesh at index 0.
  58602. */
  58603. getMeshes(): Array<Mesh>;
  58604. /**
  58605. * Explodes meshes giving a specific direction
  58606. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58607. */
  58608. explode(direction?: number): void;
  58609. }
  58610. }
  58611. declare module "babylonjs/Misc/filesInput" {
  58612. import { Engine } from "babylonjs/Engines/engine";
  58613. import { Scene } from "babylonjs/scene";
  58614. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58615. /**
  58616. * Class used to help managing file picking and drag'n'drop
  58617. */
  58618. export class FilesInput {
  58619. /**
  58620. * List of files ready to be loaded
  58621. */
  58622. static readonly FilesToLoad: {
  58623. [key: string]: File;
  58624. };
  58625. /**
  58626. * Callback called when a file is processed
  58627. */
  58628. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58629. private _engine;
  58630. private _currentScene;
  58631. private _sceneLoadedCallback;
  58632. private _progressCallback;
  58633. private _additionalRenderLoopLogicCallback;
  58634. private _textureLoadingCallback;
  58635. private _startingProcessingFilesCallback;
  58636. private _onReloadCallback;
  58637. private _errorCallback;
  58638. private _elementToMonitor;
  58639. private _sceneFileToLoad;
  58640. private _filesToLoad;
  58641. /**
  58642. * Creates a new FilesInput
  58643. * @param engine defines the rendering engine
  58644. * @param scene defines the hosting scene
  58645. * @param sceneLoadedCallback callback called when scene is loaded
  58646. * @param progressCallback callback called to track progress
  58647. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58648. * @param textureLoadingCallback callback called when a texture is loading
  58649. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58650. * @param onReloadCallback callback called when a reload is requested
  58651. * @param errorCallback callback call if an error occurs
  58652. */
  58653. 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);
  58654. private _dragEnterHandler;
  58655. private _dragOverHandler;
  58656. private _dropHandler;
  58657. /**
  58658. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58659. * @param elementToMonitor defines the DOM element to track
  58660. */
  58661. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58662. /**
  58663. * Release all associated resources
  58664. */
  58665. dispose(): void;
  58666. private renderFunction;
  58667. private drag;
  58668. private drop;
  58669. private _traverseFolder;
  58670. private _processFiles;
  58671. /**
  58672. * Load files from a drop event
  58673. * @param event defines the drop event to use as source
  58674. */
  58675. loadFiles(event: any): void;
  58676. private _processReload;
  58677. /**
  58678. * Reload the current scene from the loaded files
  58679. */
  58680. reload(): void;
  58681. }
  58682. }
  58683. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58684. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58685. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58686. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58687. }
  58688. declare module "babylonjs/Misc/sceneOptimizer" {
  58689. import { Scene, IDisposable } from "babylonjs/scene";
  58690. import { Observable } from "babylonjs/Misc/observable";
  58691. /**
  58692. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58693. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58694. */
  58695. export class SceneOptimization {
  58696. /**
  58697. * Defines the priority of this optimization (0 by default which means first in the list)
  58698. */
  58699. priority: number;
  58700. /**
  58701. * Gets a string describing the action executed by the current optimization
  58702. * @returns description string
  58703. */
  58704. getDescription(): string;
  58705. /**
  58706. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58707. * @param scene defines the current scene where to apply this optimization
  58708. * @param optimizer defines the current optimizer
  58709. * @returns true if everything that can be done was applied
  58710. */
  58711. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58712. /**
  58713. * Creates the SceneOptimization object
  58714. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58715. * @param desc defines the description associated with the optimization
  58716. */
  58717. constructor(
  58718. /**
  58719. * Defines the priority of this optimization (0 by default which means first in the list)
  58720. */
  58721. priority?: number);
  58722. }
  58723. /**
  58724. * Defines an optimization used to reduce the size of render target textures
  58725. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58726. */
  58727. export class TextureOptimization extends SceneOptimization {
  58728. /**
  58729. * Defines the priority of this optimization (0 by default which means first in the list)
  58730. */
  58731. priority: number;
  58732. /**
  58733. * 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
  58734. */
  58735. maximumSize: number;
  58736. /**
  58737. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58738. */
  58739. step: number;
  58740. /**
  58741. * Gets a string describing the action executed by the current optimization
  58742. * @returns description string
  58743. */
  58744. getDescription(): string;
  58745. /**
  58746. * Creates the TextureOptimization object
  58747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58748. * @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
  58749. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58750. */
  58751. constructor(
  58752. /**
  58753. * Defines the priority of this optimization (0 by default which means first in the list)
  58754. */
  58755. priority?: number,
  58756. /**
  58757. * 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
  58758. */
  58759. maximumSize?: number,
  58760. /**
  58761. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58762. */
  58763. step?: number);
  58764. /**
  58765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58766. * @param scene defines the current scene where to apply this optimization
  58767. * @param optimizer defines the current optimizer
  58768. * @returns true if everything that can be done was applied
  58769. */
  58770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58771. }
  58772. /**
  58773. * Defines an optimization used to increase or decrease the rendering resolution
  58774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58775. */
  58776. export class HardwareScalingOptimization extends SceneOptimization {
  58777. /**
  58778. * Defines the priority of this optimization (0 by default which means first in the list)
  58779. */
  58780. priority: number;
  58781. /**
  58782. * Defines the maximum scale to use (2 by default)
  58783. */
  58784. maximumScale: number;
  58785. /**
  58786. * Defines the step to use between two passes (0.5 by default)
  58787. */
  58788. step: number;
  58789. private _currentScale;
  58790. private _directionOffset;
  58791. /**
  58792. * Gets a string describing the action executed by the current optimization
  58793. * @return description string
  58794. */
  58795. getDescription(): string;
  58796. /**
  58797. * Creates the HardwareScalingOptimization object
  58798. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58799. * @param maximumScale defines the maximum scale to use (2 by default)
  58800. * @param step defines the step to use between two passes (0.5 by default)
  58801. */
  58802. constructor(
  58803. /**
  58804. * Defines the priority of this optimization (0 by default which means first in the list)
  58805. */
  58806. priority?: number,
  58807. /**
  58808. * Defines the maximum scale to use (2 by default)
  58809. */
  58810. maximumScale?: number,
  58811. /**
  58812. * Defines the step to use between two passes (0.5 by default)
  58813. */
  58814. step?: number);
  58815. /**
  58816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58817. * @param scene defines the current scene where to apply this optimization
  58818. * @param optimizer defines the current optimizer
  58819. * @returns true if everything that can be done was applied
  58820. */
  58821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58822. }
  58823. /**
  58824. * Defines an optimization used to remove shadows
  58825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58826. */
  58827. export class ShadowsOptimization extends SceneOptimization {
  58828. /**
  58829. * Gets a string describing the action executed by the current optimization
  58830. * @return description string
  58831. */
  58832. getDescription(): string;
  58833. /**
  58834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58835. * @param scene defines the current scene where to apply this optimization
  58836. * @param optimizer defines the current optimizer
  58837. * @returns true if everything that can be done was applied
  58838. */
  58839. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58840. }
  58841. /**
  58842. * Defines an optimization used to turn post-processes off
  58843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58844. */
  58845. export class PostProcessesOptimization extends SceneOptimization {
  58846. /**
  58847. * Gets a string describing the action executed by the current optimization
  58848. * @return description string
  58849. */
  58850. getDescription(): string;
  58851. /**
  58852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58853. * @param scene defines the current scene where to apply this optimization
  58854. * @param optimizer defines the current optimizer
  58855. * @returns true if everything that can be done was applied
  58856. */
  58857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58858. }
  58859. /**
  58860. * Defines an optimization used to turn lens flares off
  58861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58862. */
  58863. export class LensFlaresOptimization extends SceneOptimization {
  58864. /**
  58865. * Gets a string describing the action executed by the current optimization
  58866. * @return description string
  58867. */
  58868. getDescription(): string;
  58869. /**
  58870. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58871. * @param scene defines the current scene where to apply this optimization
  58872. * @param optimizer defines the current optimizer
  58873. * @returns true if everything that can be done was applied
  58874. */
  58875. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58876. }
  58877. /**
  58878. * Defines an optimization based on user defined callback.
  58879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58880. */
  58881. export class CustomOptimization extends SceneOptimization {
  58882. /**
  58883. * Callback called to apply the custom optimization.
  58884. */
  58885. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58886. /**
  58887. * Callback called to get custom description
  58888. */
  58889. onGetDescription: () => string;
  58890. /**
  58891. * Gets a string describing the action executed by the current optimization
  58892. * @returns description string
  58893. */
  58894. getDescription(): string;
  58895. /**
  58896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58897. * @param scene defines the current scene where to apply this optimization
  58898. * @param optimizer defines the current optimizer
  58899. * @returns true if everything that can be done was applied
  58900. */
  58901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58902. }
  58903. /**
  58904. * Defines an optimization used to turn particles off
  58905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58906. */
  58907. export class ParticlesOptimization extends SceneOptimization {
  58908. /**
  58909. * Gets a string describing the action executed by the current optimization
  58910. * @return description string
  58911. */
  58912. getDescription(): string;
  58913. /**
  58914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58915. * @param scene defines the current scene where to apply this optimization
  58916. * @param optimizer defines the current optimizer
  58917. * @returns true if everything that can be done was applied
  58918. */
  58919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58920. }
  58921. /**
  58922. * Defines an optimization used to turn render targets off
  58923. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58924. */
  58925. export class RenderTargetsOptimization extends SceneOptimization {
  58926. /**
  58927. * Gets a string describing the action executed by the current optimization
  58928. * @return description string
  58929. */
  58930. getDescription(): string;
  58931. /**
  58932. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58933. * @param scene defines the current scene where to apply this optimization
  58934. * @param optimizer defines the current optimizer
  58935. * @returns true if everything that can be done was applied
  58936. */
  58937. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58938. }
  58939. /**
  58940. * Defines an optimization used to merge meshes with compatible materials
  58941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58942. */
  58943. export class MergeMeshesOptimization extends SceneOptimization {
  58944. private static _UpdateSelectionTree;
  58945. /**
  58946. * Gets or sets a boolean which defines if optimization octree has to be updated
  58947. */
  58948. /**
  58949. * Gets or sets a boolean which defines if optimization octree has to be updated
  58950. */
  58951. static UpdateSelectionTree: boolean;
  58952. /**
  58953. * Gets a string describing the action executed by the current optimization
  58954. * @return description string
  58955. */
  58956. getDescription(): string;
  58957. private _canBeMerged;
  58958. /**
  58959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58960. * @param scene defines the current scene where to apply this optimization
  58961. * @param optimizer defines the current optimizer
  58962. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58963. * @returns true if everything that can be done was applied
  58964. */
  58965. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58966. }
  58967. /**
  58968. * Defines a list of options used by SceneOptimizer
  58969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58970. */
  58971. export class SceneOptimizerOptions {
  58972. /**
  58973. * Defines the target frame rate to reach (60 by default)
  58974. */
  58975. targetFrameRate: number;
  58976. /**
  58977. * Defines the interval between two checkes (2000ms by default)
  58978. */
  58979. trackerDuration: number;
  58980. /**
  58981. * Gets the list of optimizations to apply
  58982. */
  58983. optimizations: SceneOptimization[];
  58984. /**
  58985. * Creates a new list of options used by SceneOptimizer
  58986. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58987. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58988. */
  58989. constructor(
  58990. /**
  58991. * Defines the target frame rate to reach (60 by default)
  58992. */
  58993. targetFrameRate?: number,
  58994. /**
  58995. * Defines the interval between two checkes (2000ms by default)
  58996. */
  58997. trackerDuration?: number);
  58998. /**
  58999. * Add a new optimization
  59000. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59001. * @returns the current SceneOptimizerOptions
  59002. */
  59003. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59004. /**
  59005. * Add a new custom optimization
  59006. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59007. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59008. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59009. * @returns the current SceneOptimizerOptions
  59010. */
  59011. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59012. /**
  59013. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59014. * @param targetFrameRate defines the target frame rate (60 by default)
  59015. * @returns a SceneOptimizerOptions object
  59016. */
  59017. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59018. /**
  59019. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59020. * @param targetFrameRate defines the target frame rate (60 by default)
  59021. * @returns a SceneOptimizerOptions object
  59022. */
  59023. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59024. /**
  59025. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59026. * @param targetFrameRate defines the target frame rate (60 by default)
  59027. * @returns a SceneOptimizerOptions object
  59028. */
  59029. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59030. }
  59031. /**
  59032. * Class used to run optimizations in order to reach a target frame rate
  59033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59034. */
  59035. export class SceneOptimizer implements IDisposable {
  59036. private _isRunning;
  59037. private _options;
  59038. private _scene;
  59039. private _currentPriorityLevel;
  59040. private _targetFrameRate;
  59041. private _trackerDuration;
  59042. private _currentFrameRate;
  59043. private _sceneDisposeObserver;
  59044. private _improvementMode;
  59045. /**
  59046. * Defines an observable called when the optimizer reaches the target frame rate
  59047. */
  59048. onSuccessObservable: Observable<SceneOptimizer>;
  59049. /**
  59050. * Defines an observable called when the optimizer enables an optimization
  59051. */
  59052. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59053. /**
  59054. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59055. */
  59056. onFailureObservable: Observable<SceneOptimizer>;
  59057. /**
  59058. * Gets a boolean indicating if the optimizer is in improvement mode
  59059. */
  59060. readonly isInImprovementMode: boolean;
  59061. /**
  59062. * Gets the current priority level (0 at start)
  59063. */
  59064. readonly currentPriorityLevel: number;
  59065. /**
  59066. * Gets the current frame rate checked by the SceneOptimizer
  59067. */
  59068. readonly currentFrameRate: number;
  59069. /**
  59070. * Gets or sets the current target frame rate (60 by default)
  59071. */
  59072. /**
  59073. * Gets or sets the current target frame rate (60 by default)
  59074. */
  59075. targetFrameRate: number;
  59076. /**
  59077. * Gets or sets the current interval between two checks (every 2000ms by default)
  59078. */
  59079. /**
  59080. * Gets or sets the current interval between two checks (every 2000ms by default)
  59081. */
  59082. trackerDuration: number;
  59083. /**
  59084. * Gets the list of active optimizations
  59085. */
  59086. readonly optimizations: SceneOptimization[];
  59087. /**
  59088. * Creates a new SceneOptimizer
  59089. * @param scene defines the scene to work on
  59090. * @param options defines the options to use with the SceneOptimizer
  59091. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59092. * @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)
  59093. */
  59094. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59095. /**
  59096. * Stops the current optimizer
  59097. */
  59098. stop(): void;
  59099. /**
  59100. * Reset the optimizer to initial step (current priority level = 0)
  59101. */
  59102. reset(): void;
  59103. /**
  59104. * Start the optimizer. By default it will try to reach a specific framerate
  59105. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59106. */
  59107. start(): void;
  59108. private _checkCurrentState;
  59109. /**
  59110. * Release all resources
  59111. */
  59112. dispose(): void;
  59113. /**
  59114. * Helper function to create a SceneOptimizer with one single line of code
  59115. * @param scene defines the scene to work on
  59116. * @param options defines the options to use with the SceneOptimizer
  59117. * @param onSuccess defines a callback to call on success
  59118. * @param onFailure defines a callback to call on failure
  59119. * @returns the new SceneOptimizer object
  59120. */
  59121. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59122. }
  59123. }
  59124. declare module "babylonjs/Misc/sceneSerializer" {
  59125. import { Scene } from "babylonjs/scene";
  59126. /**
  59127. * Class used to serialize a scene into a string
  59128. */
  59129. export class SceneSerializer {
  59130. /**
  59131. * Clear cache used by a previous serialization
  59132. */
  59133. static ClearCache(): void;
  59134. /**
  59135. * Serialize a scene into a JSON compatible object
  59136. * @param scene defines the scene to serialize
  59137. * @returns a JSON compatible object
  59138. */
  59139. static Serialize(scene: Scene): any;
  59140. /**
  59141. * Serialize a mesh into a JSON compatible object
  59142. * @param toSerialize defines the mesh to serialize
  59143. * @param withParents defines if parents must be serialized as well
  59144. * @param withChildren defines if children must be serialized as well
  59145. * @returns a JSON compatible object
  59146. */
  59147. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59148. }
  59149. }
  59150. declare module "babylonjs/Misc/textureTools" {
  59151. import { Texture } from "babylonjs/Materials/Textures/texture";
  59152. /**
  59153. * Class used to host texture specific utilities
  59154. */
  59155. export class TextureTools {
  59156. /**
  59157. * Uses the GPU to create a copy texture rescaled at a given size
  59158. * @param texture Texture to copy from
  59159. * @param width defines the desired width
  59160. * @param height defines the desired height
  59161. * @param useBilinearMode defines if bilinear mode has to be used
  59162. * @return the generated texture
  59163. */
  59164. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59165. }
  59166. }
  59167. declare module "babylonjs/Misc/videoRecorder" {
  59168. import { Nullable } from "babylonjs/types";
  59169. import { Engine } from "babylonjs/Engines/engine";
  59170. /**
  59171. * This represents the different options avilable for the video capture.
  59172. */
  59173. export interface VideoRecorderOptions {
  59174. /** Defines the mime type of the video */
  59175. mimeType: string;
  59176. /** Defines the video the video should be recorded at */
  59177. fps: number;
  59178. /** Defines the chunk size for the recording data */
  59179. recordChunckSize: number;
  59180. /** The audio tracks to attach to the record */
  59181. audioTracks?: MediaStreamTrack[];
  59182. }
  59183. /**
  59184. * This can helps recording videos from BabylonJS.
  59185. * This is based on the available WebRTC functionalities of the browser.
  59186. *
  59187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59188. */
  59189. export class VideoRecorder {
  59190. private static readonly _defaultOptions;
  59191. /**
  59192. * Returns wehther or not the VideoRecorder is available in your browser.
  59193. * @param engine Defines the Babylon Engine to check the support for
  59194. * @returns true if supported otherwise false
  59195. */
  59196. static IsSupported(engine: Engine): boolean;
  59197. private readonly _options;
  59198. private _canvas;
  59199. private _mediaRecorder;
  59200. private _recordedChunks;
  59201. private _fileName;
  59202. private _resolve;
  59203. private _reject;
  59204. /**
  59205. * True wether a recording is already in progress.
  59206. */
  59207. readonly isRecording: boolean;
  59208. /**
  59209. * Create a new VideoCapture object which can help converting what you see in Babylon to
  59210. * a video file.
  59211. * @param engine Defines the BabylonJS Engine you wish to record
  59212. * @param options Defines options that can be used to customized the capture
  59213. */
  59214. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59215. /**
  59216. * Stops the current recording before the default capture timeout passed in the startRecording
  59217. * functions.
  59218. */
  59219. stopRecording(): void;
  59220. /**
  59221. * Starts recording the canvas for a max duration specified in parameters.
  59222. * @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.
  59223. * @param maxDuration Defines the maximum recording time in seconds.
  59224. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59225. * @return a promise callback at the end of the recording with the video data in Blob.
  59226. */
  59227. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59228. /**
  59229. * Releases internal resources used during the recording.
  59230. */
  59231. dispose(): void;
  59232. private _handleDataAvailable;
  59233. private _handleError;
  59234. private _handleStop;
  59235. }
  59236. }
  59237. declare module "babylonjs/Misc/screenshotTools" {
  59238. import { Camera } from "babylonjs/Cameras/camera";
  59239. import { Engine } from "babylonjs/Engines/engine";
  59240. /**
  59241. * Class containing a set of static utilities functions for screenshots
  59242. */
  59243. export class ScreenshotTools {
  59244. /**
  59245. * Captures a screenshot of the current rendering
  59246. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59247. * @param engine defines the rendering engine
  59248. * @param camera defines the source camera
  59249. * @param size This parameter can be set to a single number or to an object with the
  59250. * following (optional) properties: precision, width, height. If a single number is passed,
  59251. * it will be used for both width and height. If an object is passed, the screenshot size
  59252. * will be derived from the parameters. The precision property is a multiplier allowing
  59253. * rendering at a higher or lower resolution
  59254. * @param successCallback defines the callback receives a single parameter which contains the
  59255. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59256. * src parameter of an <img> to display it
  59257. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59258. * Check your browser for supported MIME types
  59259. */
  59260. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59261. /**
  59262. * Generates an image screenshot from the specified camera.
  59263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59264. * @param engine The engine to use for rendering
  59265. * @param camera The camera to use for rendering
  59266. * @param size This parameter can be set to a single number or to an object with the
  59267. * following (optional) properties: precision, width, height. If a single number is passed,
  59268. * it will be used for both width and height. If an object is passed, the screenshot size
  59269. * will be derived from the parameters. The precision property is a multiplier allowing
  59270. * rendering at a higher or lower resolution
  59271. * @param successCallback The callback receives a single parameter which contains the
  59272. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59273. * src parameter of an <img> to display it
  59274. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59275. * Check your browser for supported MIME types
  59276. * @param samples Texture samples (default: 1)
  59277. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59278. * @param fileName A name for for the downloaded file.
  59279. */
  59280. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59281. }
  59282. }
  59283. declare module "babylonjs/Misc/index" {
  59284. export * from "babylonjs/Misc/andOrNotEvaluator";
  59285. export * from "babylonjs/Misc/assetsManager";
  59286. export * from "babylonjs/Misc/dds";
  59287. export * from "babylonjs/Misc/decorators";
  59288. export * from "babylonjs/Misc/deferred";
  59289. export * from "babylonjs/Misc/environmentTextureTools";
  59290. export * from "babylonjs/Misc/meshExploder";
  59291. export * from "babylonjs/Misc/filesInput";
  59292. export * from "babylonjs/Misc/HighDynamicRange/index";
  59293. export * from "babylonjs/Misc/khronosTextureContainer";
  59294. export * from "babylonjs/Misc/observable";
  59295. export * from "babylonjs/Misc/performanceMonitor";
  59296. export * from "babylonjs/Misc/promise";
  59297. export * from "babylonjs/Misc/sceneOptimizer";
  59298. export * from "babylonjs/Misc/sceneSerializer";
  59299. export * from "babylonjs/Misc/smartArray";
  59300. export * from "babylonjs/Misc/stringDictionary";
  59301. export * from "babylonjs/Misc/tags";
  59302. export * from "babylonjs/Misc/textureTools";
  59303. export * from "babylonjs/Misc/tga";
  59304. export * from "babylonjs/Misc/tools";
  59305. export * from "babylonjs/Misc/videoRecorder";
  59306. export * from "babylonjs/Misc/virtualJoystick";
  59307. export * from "babylonjs/Misc/workerPool";
  59308. export * from "babylonjs/Misc/logger";
  59309. export * from "babylonjs/Misc/typeStore";
  59310. export * from "babylonjs/Misc/filesInputStore";
  59311. export * from "babylonjs/Misc/deepCopier";
  59312. export * from "babylonjs/Misc/pivotTools";
  59313. export * from "babylonjs/Misc/precisionDate";
  59314. export * from "babylonjs/Misc/screenshotTools";
  59315. export * from "babylonjs/Misc/typeStore";
  59316. export * from "babylonjs/Misc/webRequest";
  59317. export * from "babylonjs/Misc/iInspectable";
  59318. }
  59319. declare module "babylonjs/index" {
  59320. export * from "babylonjs/abstractScene";
  59321. export * from "babylonjs/Actions/index";
  59322. export * from "babylonjs/Animations/index";
  59323. export * from "babylonjs/assetContainer";
  59324. export * from "babylonjs/Audio/index";
  59325. export * from "babylonjs/Behaviors/index";
  59326. export * from "babylonjs/Bones/index";
  59327. export * from "babylonjs/Cameras/index";
  59328. export * from "babylonjs/Collisions/index";
  59329. export * from "babylonjs/Culling/index";
  59330. export * from "babylonjs/Debug/index";
  59331. export * from "babylonjs/Engines/index";
  59332. export * from "babylonjs/Events/index";
  59333. export * from "babylonjs/Gamepads/index";
  59334. export * from "babylonjs/Gizmos/index";
  59335. export * from "babylonjs/Helpers/index";
  59336. export * from "babylonjs/Instrumentation/index";
  59337. export * from "babylonjs/Layers/index";
  59338. export * from "babylonjs/LensFlares/index";
  59339. export * from "babylonjs/Lights/index";
  59340. export * from "babylonjs/Loading/index";
  59341. export * from "babylonjs/Materials/index";
  59342. export * from "babylonjs/Maths/index";
  59343. export * from "babylonjs/Meshes/index";
  59344. export * from "babylonjs/Morph/index";
  59345. export * from "babylonjs/node";
  59346. export * from "babylonjs/Offline/index";
  59347. export * from "babylonjs/Particles/index";
  59348. export * from "babylonjs/Physics/index";
  59349. export * from "babylonjs/PostProcesses/index";
  59350. export * from "babylonjs/Probes/index";
  59351. export * from "babylonjs/Rendering/index";
  59352. export * from "babylonjs/scene";
  59353. export * from "babylonjs/sceneComponent";
  59354. export * from "babylonjs/Sprites/index";
  59355. export * from "babylonjs/States/index";
  59356. export * from "babylonjs/Misc/index";
  59357. export * from "babylonjs/types";
  59358. }
  59359. declare module "babylonjs/Animations/pathCursor" {
  59360. import { Path2, Vector3 } from "babylonjs/Maths/math";
  59361. /**
  59362. * A cursor which tracks a point on a path
  59363. */
  59364. export class PathCursor {
  59365. private path;
  59366. /**
  59367. * Stores path cursor callbacks for when an onchange event is triggered
  59368. */
  59369. private _onchange;
  59370. /**
  59371. * The value of the path cursor
  59372. */
  59373. value: number;
  59374. /**
  59375. * The animation array of the path cursor
  59376. */
  59377. animations: Animation[];
  59378. /**
  59379. * Initializes the path cursor
  59380. * @param path The path to track
  59381. */
  59382. constructor(path: Path2);
  59383. /**
  59384. * Gets the cursor point on the path
  59385. * @returns A point on the path cursor at the cursor location
  59386. */
  59387. getPoint(): Vector3;
  59388. /**
  59389. * Moves the cursor ahead by the step amount
  59390. * @param step The amount to move the cursor forward
  59391. * @returns This path cursor
  59392. */
  59393. moveAhead(step?: number): PathCursor;
  59394. /**
  59395. * Moves the cursor behind by the step amount
  59396. * @param step The amount to move the cursor back
  59397. * @returns This path cursor
  59398. */
  59399. moveBack(step?: number): PathCursor;
  59400. /**
  59401. * Moves the cursor by the step amount
  59402. * If the step amount is greater than one, an exception is thrown
  59403. * @param step The amount to move the cursor
  59404. * @returns This path cursor
  59405. */
  59406. move(step: number): PathCursor;
  59407. /**
  59408. * Ensures that the value is limited between zero and one
  59409. * @returns This path cursor
  59410. */
  59411. private ensureLimits;
  59412. /**
  59413. * Runs onchange callbacks on change (used by the animation engine)
  59414. * @returns This path cursor
  59415. */
  59416. private raiseOnChange;
  59417. /**
  59418. * Executes a function on change
  59419. * @param f A path cursor onchange callback
  59420. * @returns This path cursor
  59421. */
  59422. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59423. }
  59424. }
  59425. declare module "babylonjs/Legacy/legacy" {
  59426. import * as Babylon from "babylonjs/index";
  59427. export * from "babylonjs/index";
  59428. }
  59429. declare module "babylonjs/Shaders/blur.fragment" {
  59430. /** @hidden */
  59431. export var blurPixelShader: {
  59432. name: string;
  59433. shader: string;
  59434. };
  59435. }
  59436. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59437. /** @hidden */
  59438. export var bones300Declaration: {
  59439. name: string;
  59440. shader: string;
  59441. };
  59442. }
  59443. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59444. /** @hidden */
  59445. export var instances300Declaration: {
  59446. name: string;
  59447. shader: string;
  59448. };
  59449. }
  59450. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59451. /** @hidden */
  59452. export var pointCloudVertexDeclaration: {
  59453. name: string;
  59454. shader: string;
  59455. };
  59456. }
  59457. // Mixins
  59458. interface Window {
  59459. mozIndexedDB: IDBFactory;
  59460. webkitIndexedDB: IDBFactory;
  59461. msIndexedDB: IDBFactory;
  59462. webkitURL: typeof URL;
  59463. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59464. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59465. WebGLRenderingContext: WebGLRenderingContext;
  59466. MSGesture: MSGesture;
  59467. CANNON: any;
  59468. AudioContext: AudioContext;
  59469. webkitAudioContext: AudioContext;
  59470. PointerEvent: any;
  59471. Math: Math;
  59472. Uint8Array: Uint8ArrayConstructor;
  59473. Float32Array: Float32ArrayConstructor;
  59474. mozURL: typeof URL;
  59475. msURL: typeof URL;
  59476. VRFrameData: any; // WebVR, from specs 1.1
  59477. DracoDecoderModule: any;
  59478. setImmediate(handler: (...args: any[]) => void): number;
  59479. }
  59480. interface HTMLCanvasElement {
  59481. requestPointerLock(): void;
  59482. msRequestPointerLock?(): void;
  59483. mozRequestPointerLock?(): void;
  59484. webkitRequestPointerLock?(): void;
  59485. /** Track wether a record is in progress */
  59486. isRecording: boolean;
  59487. /** Capture Stream method defined by some browsers */
  59488. captureStream(fps?: number): MediaStream;
  59489. }
  59490. interface CanvasRenderingContext2D {
  59491. msImageSmoothingEnabled: boolean;
  59492. }
  59493. interface MouseEvent {
  59494. mozMovementX: number;
  59495. mozMovementY: number;
  59496. webkitMovementX: number;
  59497. webkitMovementY: number;
  59498. msMovementX: number;
  59499. msMovementY: number;
  59500. }
  59501. interface Navigator {
  59502. mozGetVRDevices: (any: any) => any;
  59503. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59504. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59505. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59506. webkitGetGamepads(): Gamepad[];
  59507. msGetGamepads(): Gamepad[];
  59508. webkitGamepads(): Gamepad[];
  59509. }
  59510. interface HTMLVideoElement {
  59511. mozSrcObject: any;
  59512. }
  59513. interface Math {
  59514. fround(x: number): number;
  59515. imul(a: number, b: number): number;
  59516. }
  59517. interface WebGLRenderingContext {
  59518. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59519. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59520. vertexAttribDivisor(index: number, divisor: number): void;
  59521. createVertexArray(): any;
  59522. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59523. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59524. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59525. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59526. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59527. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59528. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59529. // Queries
  59530. createQuery(): WebGLQuery;
  59531. deleteQuery(query: WebGLQuery): void;
  59532. beginQuery(target: number, query: WebGLQuery): void;
  59533. endQuery(target: number): void;
  59534. getQueryParameter(query: WebGLQuery, pname: number): any;
  59535. getQuery(target: number, pname: number): any;
  59536. MAX_SAMPLES: number;
  59537. RGBA8: number;
  59538. READ_FRAMEBUFFER: number;
  59539. DRAW_FRAMEBUFFER: number;
  59540. UNIFORM_BUFFER: number;
  59541. HALF_FLOAT_OES: number;
  59542. RGBA16F: number;
  59543. RGBA32F: number;
  59544. R32F: number;
  59545. RG32F: number;
  59546. RGB32F: number;
  59547. R16F: number;
  59548. RG16F: number;
  59549. RGB16F: number;
  59550. RED: number;
  59551. RG: number;
  59552. R8: number;
  59553. RG8: number;
  59554. UNSIGNED_INT_24_8: number;
  59555. DEPTH24_STENCIL8: number;
  59556. /* Multiple Render Targets */
  59557. drawBuffers(buffers: number[]): void;
  59558. readBuffer(src: number): void;
  59559. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59560. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59561. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59562. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59563. // Occlusion Query
  59564. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59565. ANY_SAMPLES_PASSED: number;
  59566. QUERY_RESULT_AVAILABLE: number;
  59567. QUERY_RESULT: number;
  59568. }
  59569. interface WebGLProgram {
  59570. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59571. }
  59572. interface EXT_disjoint_timer_query {
  59573. QUERY_COUNTER_BITS_EXT: number;
  59574. TIME_ELAPSED_EXT: number;
  59575. TIMESTAMP_EXT: number;
  59576. GPU_DISJOINT_EXT: number;
  59577. QUERY_RESULT_EXT: number;
  59578. QUERY_RESULT_AVAILABLE_EXT: number;
  59579. queryCounterEXT(query: WebGLQuery, target: number): void;
  59580. createQueryEXT(): WebGLQuery;
  59581. beginQueryEXT(target: number, query: WebGLQuery): void;
  59582. endQueryEXT(target: number): void;
  59583. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59584. deleteQueryEXT(query: WebGLQuery): void;
  59585. }
  59586. interface WebGLUniformLocation {
  59587. _currentState: any;
  59588. }
  59589. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59590. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59591. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59592. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59593. interface WebGLRenderingContext {
  59594. readonly RASTERIZER_DISCARD: number;
  59595. readonly DEPTH_COMPONENT24: number;
  59596. readonly TEXTURE_3D: number;
  59597. readonly TEXTURE_2D_ARRAY: number;
  59598. readonly TEXTURE_COMPARE_FUNC: number;
  59599. readonly TEXTURE_COMPARE_MODE: number;
  59600. readonly COMPARE_REF_TO_TEXTURE: number;
  59601. readonly TEXTURE_WRAP_R: number;
  59602. readonly HALF_FLOAT: number;
  59603. readonly RGB8: number;
  59604. readonly RED_INTEGER: number;
  59605. readonly RG_INTEGER: number;
  59606. readonly RGB_INTEGER: number;
  59607. readonly RGBA_INTEGER: number;
  59608. readonly R8_SNORM: number;
  59609. readonly RG8_SNORM: number;
  59610. readonly RGB8_SNORM: number;
  59611. readonly RGBA8_SNORM: number;
  59612. readonly R8I: number;
  59613. readonly RG8I: number;
  59614. readonly RGB8I: number;
  59615. readonly RGBA8I: number;
  59616. readonly R8UI: number;
  59617. readonly RG8UI: number;
  59618. readonly RGB8UI: number;
  59619. readonly RGBA8UI: number;
  59620. readonly R16I: number;
  59621. readonly RG16I: number;
  59622. readonly RGB16I: number;
  59623. readonly RGBA16I: number;
  59624. readonly R16UI: number;
  59625. readonly RG16UI: number;
  59626. readonly RGB16UI: number;
  59627. readonly RGBA16UI: number;
  59628. readonly R32I: number;
  59629. readonly RG32I: number;
  59630. readonly RGB32I: number;
  59631. readonly RGBA32I: number;
  59632. readonly R32UI: number;
  59633. readonly RG32UI: number;
  59634. readonly RGB32UI: number;
  59635. readonly RGBA32UI: number;
  59636. readonly RGB10_A2UI: number;
  59637. readonly R11F_G11F_B10F: number;
  59638. readonly RGB9_E5: number;
  59639. readonly RGB10_A2: number;
  59640. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59641. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59642. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59643. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59644. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59645. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59646. 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;
  59647. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59648. readonly TRANSFORM_FEEDBACK: number;
  59649. readonly INTERLEAVED_ATTRIBS: number;
  59650. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59651. createTransformFeedback(): WebGLTransformFeedback;
  59652. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59653. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59654. beginTransformFeedback(primitiveMode: number): void;
  59655. endTransformFeedback(): void;
  59656. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59657. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59658. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59659. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59660. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59661. }
  59662. interface ImageBitmap {
  59663. readonly width: number;
  59664. readonly height: number;
  59665. close(): void;
  59666. }
  59667. interface WebGLQuery extends WebGLObject {
  59668. }
  59669. declare var WebGLQuery: {
  59670. prototype: WebGLQuery;
  59671. new(): WebGLQuery;
  59672. };
  59673. interface WebGLSampler extends WebGLObject {
  59674. }
  59675. declare var WebGLSampler: {
  59676. prototype: WebGLSampler;
  59677. new(): WebGLSampler;
  59678. };
  59679. interface WebGLSync extends WebGLObject {
  59680. }
  59681. declare var WebGLSync: {
  59682. prototype: WebGLSync;
  59683. new(): WebGLSync;
  59684. };
  59685. interface WebGLTransformFeedback extends WebGLObject {
  59686. }
  59687. declare var WebGLTransformFeedback: {
  59688. prototype: WebGLTransformFeedback;
  59689. new(): WebGLTransformFeedback;
  59690. };
  59691. interface WebGLVertexArrayObject extends WebGLObject {
  59692. }
  59693. declare var WebGLVertexArrayObject: {
  59694. prototype: WebGLVertexArrayObject;
  59695. new(): WebGLVertexArrayObject;
  59696. };
  59697. // Type definitions for WebVR API
  59698. // Project: https://w3c.github.io/webvr/
  59699. // Definitions by: six a <https://github.com/lostfictions>
  59700. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59701. interface VRDisplay extends EventTarget {
  59702. /**
  59703. * Dictionary of capabilities describing the VRDisplay.
  59704. */
  59705. readonly capabilities: VRDisplayCapabilities;
  59706. /**
  59707. * z-depth defining the far plane of the eye view frustum
  59708. * enables mapping of values in the render target depth
  59709. * attachment to scene coordinates. Initially set to 10000.0.
  59710. */
  59711. depthFar: number;
  59712. /**
  59713. * z-depth defining the near plane of the eye view frustum
  59714. * enables mapping of values in the render target depth
  59715. * attachment to scene coordinates. Initially set to 0.01.
  59716. */
  59717. depthNear: number;
  59718. /**
  59719. * An identifier for this distinct VRDisplay. Used as an
  59720. * association point in the Gamepad API.
  59721. */
  59722. readonly displayId: number;
  59723. /**
  59724. * A display name, a user-readable name identifying it.
  59725. */
  59726. readonly displayName: string;
  59727. readonly isConnected: boolean;
  59728. readonly isPresenting: boolean;
  59729. /**
  59730. * If this VRDisplay supports room-scale experiences, the optional
  59731. * stage attribute contains details on the room-scale parameters.
  59732. */
  59733. readonly stageParameters: VRStageParameters | null;
  59734. /**
  59735. * Passing the value returned by `requestAnimationFrame` to
  59736. * `cancelAnimationFrame` will unregister the callback.
  59737. * @param handle Define the hanle of the request to cancel
  59738. */
  59739. cancelAnimationFrame(handle: number): void;
  59740. /**
  59741. * Stops presenting to the VRDisplay.
  59742. * @returns a promise to know when it stopped
  59743. */
  59744. exitPresent(): Promise<void>;
  59745. /**
  59746. * Return the current VREyeParameters for the given eye.
  59747. * @param whichEye Define the eye we want the parameter for
  59748. * @returns the eye parameters
  59749. */
  59750. getEyeParameters(whichEye: string): VREyeParameters;
  59751. /**
  59752. * Populates the passed VRFrameData with the information required to render
  59753. * the current frame.
  59754. * @param frameData Define the data structure to populate
  59755. * @returns true if ok otherwise false
  59756. */
  59757. getFrameData(frameData: VRFrameData): boolean;
  59758. /**
  59759. * Get the layers currently being presented.
  59760. * @returns the list of VR layers
  59761. */
  59762. getLayers(): VRLayer[];
  59763. /**
  59764. * Return a VRPose containing the future predicted pose of the VRDisplay
  59765. * when the current frame will be presented. The value returned will not
  59766. * change until JavaScript has returned control to the browser.
  59767. *
  59768. * The VRPose will contain the position, orientation, velocity,
  59769. * and acceleration of each of these properties.
  59770. * @returns the pose object
  59771. */
  59772. getPose(): VRPose;
  59773. /**
  59774. * Return the current instantaneous pose of the VRDisplay, with no
  59775. * prediction applied.
  59776. * @returns the current instantaneous pose
  59777. */
  59778. getImmediatePose(): VRPose;
  59779. /**
  59780. * The callback passed to `requestAnimationFrame` will be called
  59781. * any time a new frame should be rendered. When the VRDisplay is
  59782. * presenting the callback will be called at the native refresh
  59783. * rate of the HMD. When not presenting this function acts
  59784. * identically to how window.requestAnimationFrame acts. Content should
  59785. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59786. * asynchronously from other displays and at differing refresh rates.
  59787. * @param callback Define the eaction to run next frame
  59788. * @returns the request handle it
  59789. */
  59790. requestAnimationFrame(callback: FrameRequestCallback): number;
  59791. /**
  59792. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59793. * Repeat calls while already presenting will update the VRLayers being displayed.
  59794. * @param layers Define the list of layer to present
  59795. * @returns a promise to know when the request has been fulfilled
  59796. */
  59797. requestPresent(layers: VRLayer[]): Promise<void>;
  59798. /**
  59799. * Reset the pose for this display, treating its current position and
  59800. * orientation as the "origin/zero" values. VRPose.position,
  59801. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59802. * updated when calling resetPose(). This should be called in only
  59803. * sitting-space experiences.
  59804. */
  59805. resetPose(): void;
  59806. /**
  59807. * The VRLayer provided to the VRDisplay will be captured and presented
  59808. * in the HMD. Calling this function has the same effect on the source
  59809. * canvas as any other operation that uses its source image, and canvases
  59810. * created without preserveDrawingBuffer set to true will be cleared.
  59811. * @param pose Define the pose to submit
  59812. */
  59813. submitFrame(pose?: VRPose): void;
  59814. }
  59815. declare var VRDisplay: {
  59816. prototype: VRDisplay;
  59817. new(): VRDisplay;
  59818. };
  59819. interface VRLayer {
  59820. leftBounds?: number[] | Float32Array | null;
  59821. rightBounds?: number[] | Float32Array | null;
  59822. source?: HTMLCanvasElement | null;
  59823. }
  59824. interface VRDisplayCapabilities {
  59825. readonly canPresent: boolean;
  59826. readonly hasExternalDisplay: boolean;
  59827. readonly hasOrientation: boolean;
  59828. readonly hasPosition: boolean;
  59829. readonly maxLayers: number;
  59830. }
  59831. interface VREyeParameters {
  59832. /** @deprecated */
  59833. readonly fieldOfView: VRFieldOfView;
  59834. readonly offset: Float32Array;
  59835. readonly renderHeight: number;
  59836. readonly renderWidth: number;
  59837. }
  59838. interface VRFieldOfView {
  59839. readonly downDegrees: number;
  59840. readonly leftDegrees: number;
  59841. readonly rightDegrees: number;
  59842. readonly upDegrees: number;
  59843. }
  59844. interface VRFrameData {
  59845. readonly leftProjectionMatrix: Float32Array;
  59846. readonly leftViewMatrix: Float32Array;
  59847. readonly pose: VRPose;
  59848. readonly rightProjectionMatrix: Float32Array;
  59849. readonly rightViewMatrix: Float32Array;
  59850. readonly timestamp: number;
  59851. }
  59852. interface VRPose {
  59853. readonly angularAcceleration: Float32Array | null;
  59854. readonly angularVelocity: Float32Array | null;
  59855. readonly linearAcceleration: Float32Array | null;
  59856. readonly linearVelocity: Float32Array | null;
  59857. readonly orientation: Float32Array | null;
  59858. readonly position: Float32Array | null;
  59859. readonly timestamp: number;
  59860. }
  59861. interface VRStageParameters {
  59862. sittingToStandingTransform?: Float32Array;
  59863. sizeX?: number;
  59864. sizeY?: number;
  59865. }
  59866. interface Navigator {
  59867. getVRDisplays(): Promise<VRDisplay[]>;
  59868. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59869. }
  59870. interface Window {
  59871. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59872. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59873. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59874. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59875. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59876. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59877. }
  59878. interface Gamepad {
  59879. readonly displayId: number;
  59880. }
  59881. interface XRDevice {
  59882. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59883. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59884. }
  59885. interface XRSession {
  59886. getInputSources(): Array<any>;
  59887. baseLayer: XRWebGLLayer;
  59888. requestFrameOfReference(type: string): Promise<void>;
  59889. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59890. end(): Promise<void>;
  59891. requestAnimationFrame: Function;
  59892. addEventListener: Function;
  59893. }
  59894. interface XRSessionCreationOptions {
  59895. outputContext?: WebGLRenderingContext | null;
  59896. immersive?: boolean;
  59897. environmentIntegration?: boolean;
  59898. }
  59899. interface XRLayer {
  59900. getViewport: Function;
  59901. framebufferWidth: number;
  59902. framebufferHeight: number;
  59903. }
  59904. interface XRView {
  59905. projectionMatrix: Float32Array;
  59906. }
  59907. interface XRFrame {
  59908. getDevicePose: Function;
  59909. getInputPose: Function;
  59910. views: Array<XRView>;
  59911. baseLayer: XRLayer;
  59912. }
  59913. interface XRFrameOfReference {
  59914. }
  59915. interface XRWebGLLayer extends XRLayer {
  59916. framebuffer: WebGLFramebuffer;
  59917. }
  59918. declare var XRWebGLLayer: {
  59919. prototype: XRWebGLLayer;
  59920. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59921. };
  59922. declare module "babylonjs" {
  59923. export * from "babylonjs/Legacy/legacy";
  59924. }
  59925. declare module BABYLON {
  59926. /** Alias type for value that can be null */
  59927. export type Nullable<T> = T | null;
  59928. /**
  59929. * Alias type for number that are floats
  59930. * @ignorenaming
  59931. */
  59932. export type float = number;
  59933. /**
  59934. * Alias type for number that are doubles.
  59935. * @ignorenaming
  59936. */
  59937. export type double = number;
  59938. /**
  59939. * Alias type for number that are integer
  59940. * @ignorenaming
  59941. */
  59942. export type int = number;
  59943. /** Alias type for number array or Float32Array */
  59944. export type FloatArray = number[] | Float32Array;
  59945. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59946. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59947. /**
  59948. * Alias for types that can be used by a Buffer or VertexBuffer.
  59949. */
  59950. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59951. /**
  59952. * Alias type for primitive types
  59953. * @ignorenaming
  59954. */
  59955. type Primitive = undefined | null | boolean | string | number | Function;
  59956. /**
  59957. * Type modifier to make all the properties of an object Readonly
  59958. */
  59959. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59960. /**
  59961. * Type modifier to make all the properties of an object Readonly recursively
  59962. */
  59963. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59964. /** @hidden */
  59965. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59966. }
  59967. /** @hidden */
  59968. /** @hidden */
  59969. type DeepImmutableObject<T> = {
  59970. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59971. };
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * Class containing a set of static utilities functions for arrays.
  59976. */
  59977. export class ArrayTools {
  59978. /**
  59979. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59980. * @param size the number of element to construct and put in the array
  59981. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59982. * @returns a new array filled with new objects
  59983. */
  59984. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59985. }
  59986. }
  59987. declare module BABYLON {
  59988. /**
  59989. * Scalar computation library
  59990. */
  59991. export class Scalar {
  59992. /**
  59993. * Two pi constants convenient for computation.
  59994. */
  59995. static TwoPi: number;
  59996. /**
  59997. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59998. * @param a number
  59999. * @param b number
  60000. * @param epsilon (default = 1.401298E-45)
  60001. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  60002. */
  60003. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  60004. /**
  60005. * Returns a string : the upper case translation of the number i to hexadecimal.
  60006. * @param i number
  60007. * @returns the upper case translation of the number i to hexadecimal.
  60008. */
  60009. static ToHex(i: number): string;
  60010. /**
  60011. * Returns -1 if value is negative and +1 is value is positive.
  60012. * @param value the value
  60013. * @returns the value itself if it's equal to zero.
  60014. */
  60015. static Sign(value: number): number;
  60016. /**
  60017. * Returns the value itself if it's between min and max.
  60018. * Returns min if the value is lower than min.
  60019. * Returns max if the value is greater than max.
  60020. * @param value the value to clmap
  60021. * @param min the min value to clamp to (default: 0)
  60022. * @param max the max value to clamp to (default: 1)
  60023. * @returns the clamped value
  60024. */
  60025. static Clamp(value: number, min?: number, max?: number): number;
  60026. /**
  60027. * the log2 of value.
  60028. * @param value the value to compute log2 of
  60029. * @returns the log2 of value.
  60030. */
  60031. static Log2(value: number): number;
  60032. /**
  60033. * Loops the value, so that it is never larger than length and never smaller than 0.
  60034. *
  60035. * This is similar to the modulo operator but it works with floating point numbers.
  60036. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  60037. * With t = 5 and length = 2.5, the result would be 0.0.
  60038. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  60039. * @param value the value
  60040. * @param length the length
  60041. * @returns the looped value
  60042. */
  60043. static Repeat(value: number, length: number): number;
  60044. /**
  60045. * Normalize the value between 0.0 and 1.0 using min and max values
  60046. * @param value value to normalize
  60047. * @param min max to normalize between
  60048. * @param max min to normalize between
  60049. * @returns the normalized value
  60050. */
  60051. static Normalize(value: number, min: number, max: number): number;
  60052. /**
  60053. * Denormalize the value from 0.0 and 1.0 using min and max values
  60054. * @param normalized value to denormalize
  60055. * @param min max to denormalize between
  60056. * @param max min to denormalize between
  60057. * @returns the denormalized value
  60058. */
  60059. static Denormalize(normalized: number, min: number, max: number): number;
  60060. /**
  60061. * Calculates the shortest difference between two given angles given in degrees.
  60062. * @param current current angle in degrees
  60063. * @param target target angle in degrees
  60064. * @returns the delta
  60065. */
  60066. static DeltaAngle(current: number, target: number): number;
  60067. /**
  60068. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  60069. * @param tx value
  60070. * @param length length
  60071. * @returns The returned value will move back and forth between 0 and length
  60072. */
  60073. static PingPong(tx: number, length: number): number;
  60074. /**
  60075. * Interpolates between min and max with smoothing at the limits.
  60076. *
  60077. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  60078. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  60079. * @param from from
  60080. * @param to to
  60081. * @param tx value
  60082. * @returns the smooth stepped value
  60083. */
  60084. static SmoothStep(from: number, to: number, tx: number): number;
  60085. /**
  60086. * Moves a value current towards target.
  60087. *
  60088. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  60089. * Negative values of maxDelta pushes the value away from target.
  60090. * @param current current value
  60091. * @param target target value
  60092. * @param maxDelta max distance to move
  60093. * @returns resulting value
  60094. */
  60095. static MoveTowards(current: number, target: number, maxDelta: number): number;
  60096. /**
  60097. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60098. *
  60099. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  60100. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  60101. * @param current current value
  60102. * @param target target value
  60103. * @param maxDelta max distance to move
  60104. * @returns resulting angle
  60105. */
  60106. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  60107. /**
  60108. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  60109. * @param start start value
  60110. * @param end target value
  60111. * @param amount amount to lerp between
  60112. * @returns the lerped value
  60113. */
  60114. static Lerp(start: number, end: number, amount: number): number;
  60115. /**
  60116. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  60117. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  60118. * @param start start value
  60119. * @param end target value
  60120. * @param amount amount to lerp between
  60121. * @returns the lerped value
  60122. */
  60123. static LerpAngle(start: number, end: number, amount: number): number;
  60124. /**
  60125. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  60126. * @param a start value
  60127. * @param b target value
  60128. * @param value value between a and b
  60129. * @returns the inverseLerp value
  60130. */
  60131. static InverseLerp(a: number, b: number, value: number): number;
  60132. /**
  60133. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  60134. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  60135. * @param value1 spline value
  60136. * @param tangent1 spline value
  60137. * @param value2 spline value
  60138. * @param tangent2 spline value
  60139. * @param amount input value
  60140. * @returns hermite result
  60141. */
  60142. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  60143. /**
  60144. * Returns a random float number between and min and max values
  60145. * @param min min value of random
  60146. * @param max max value of random
  60147. * @returns random value
  60148. */
  60149. static RandomRange(min: number, max: number): number;
  60150. /**
  60151. * This function returns percentage of a number in a given range.
  60152. *
  60153. * RangeToPercent(40,20,60) will return 0.5 (50%)
  60154. * RangeToPercent(34,0,100) will return 0.34 (34%)
  60155. * @param number to convert to percentage
  60156. * @param min min range
  60157. * @param max max range
  60158. * @returns the percentage
  60159. */
  60160. static RangeToPercent(number: number, min: number, max: number): number;
  60161. /**
  60162. * This function returns number that corresponds to the percentage in a given range.
  60163. *
  60164. * PercentToRange(0.34,0,100) will return 34.
  60165. * @param percent to convert to number
  60166. * @param min min range
  60167. * @param max max range
  60168. * @returns the number
  60169. */
  60170. static PercentToRange(percent: number, min: number, max: number): number;
  60171. /**
  60172. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  60173. * @param angle The angle to normalize in radian.
  60174. * @return The converted angle.
  60175. */
  60176. static NormalizeRadians(angle: number): number;
  60177. }
  60178. }
  60179. declare module BABYLON {
  60180. /**
  60181. * Constant used to convert a value to gamma space
  60182. * @ignorenaming
  60183. */
  60184. export const ToGammaSpace: number;
  60185. /**
  60186. * Constant used to convert a value to linear space
  60187. * @ignorenaming
  60188. */
  60189. export const ToLinearSpace = 2.2;
  60190. /**
  60191. * Constant used to define the minimal number value in Babylon.js
  60192. * @ignorenaming
  60193. */
  60194. let Epsilon: number;
  60195. /**
  60196. * Class used to hold a RBG color
  60197. */
  60198. export class Color3 {
  60199. /**
  60200. * Defines the red component (between 0 and 1, default is 0)
  60201. */
  60202. r: number;
  60203. /**
  60204. * Defines the green component (between 0 and 1, default is 0)
  60205. */
  60206. g: number;
  60207. /**
  60208. * Defines the blue component (between 0 and 1, default is 0)
  60209. */
  60210. b: number;
  60211. /**
  60212. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  60213. * @param r defines the red component (between 0 and 1, default is 0)
  60214. * @param g defines the green component (between 0 and 1, default is 0)
  60215. * @param b defines the blue component (between 0 and 1, default is 0)
  60216. */
  60217. constructor(
  60218. /**
  60219. * Defines the red component (between 0 and 1, default is 0)
  60220. */
  60221. r?: number,
  60222. /**
  60223. * Defines the green component (between 0 and 1, default is 0)
  60224. */
  60225. g?: number,
  60226. /**
  60227. * Defines the blue component (between 0 and 1, default is 0)
  60228. */
  60229. b?: number);
  60230. /**
  60231. * Creates a string with the Color3 current values
  60232. * @returns the string representation of the Color3 object
  60233. */
  60234. toString(): string;
  60235. /**
  60236. * Returns the string "Color3"
  60237. * @returns "Color3"
  60238. */
  60239. getClassName(): string;
  60240. /**
  60241. * Compute the Color3 hash code
  60242. * @returns an unique number that can be used to hash Color3 objects
  60243. */
  60244. getHashCode(): number;
  60245. /**
  60246. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  60247. * @param array defines the array where to store the r,g,b components
  60248. * @param index defines an optional index in the target array to define where to start storing values
  60249. * @returns the current Color3 object
  60250. */
  60251. toArray(array: FloatArray, index?: number): Color3;
  60252. /**
  60253. * Returns a new Color4 object from the current Color3 and the given alpha
  60254. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  60255. * @returns a new Color4 object
  60256. */
  60257. toColor4(alpha?: number): Color4;
  60258. /**
  60259. * Returns a new array populated with 3 numeric elements : red, green and blue values
  60260. * @returns the new array
  60261. */
  60262. asArray(): number[];
  60263. /**
  60264. * Returns the luminance value
  60265. * @returns a float value
  60266. */
  60267. toLuminance(): number;
  60268. /**
  60269. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  60270. * @param otherColor defines the second operand
  60271. * @returns the new Color3 object
  60272. */
  60273. multiply(otherColor: DeepImmutable<Color3>): Color3;
  60274. /**
  60275. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  60276. * @param otherColor defines the second operand
  60277. * @param result defines the Color3 object where to store the result
  60278. * @returns the current Color3
  60279. */
  60280. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60281. /**
  60282. * Determines equality between Color3 objects
  60283. * @param otherColor defines the second operand
  60284. * @returns true if the rgb values are equal to the given ones
  60285. */
  60286. equals(otherColor: DeepImmutable<Color3>): boolean;
  60287. /**
  60288. * Determines equality between the current Color3 object and a set of r,b,g values
  60289. * @param r defines the red component to check
  60290. * @param g defines the green component to check
  60291. * @param b defines the blue component to check
  60292. * @returns true if the rgb values are equal to the given ones
  60293. */
  60294. equalsFloats(r: number, g: number, b: number): boolean;
  60295. /**
  60296. * Multiplies in place each rgb value by scale
  60297. * @param scale defines the scaling factor
  60298. * @returns the updated Color3
  60299. */
  60300. scale(scale: number): Color3;
  60301. /**
  60302. * Multiplies the rgb values by scale and stores the result into "result"
  60303. * @param scale defines the scaling factor
  60304. * @param result defines the Color3 object where to store the result
  60305. * @returns the unmodified current Color3
  60306. */
  60307. scaleToRef(scale: number, result: Color3): Color3;
  60308. /**
  60309. * Scale the current Color3 values by a factor and add the result to a given Color3
  60310. * @param scale defines the scale factor
  60311. * @param result defines color to store the result into
  60312. * @returns the unmodified current Color3
  60313. */
  60314. scaleAndAddToRef(scale: number, result: Color3): Color3;
  60315. /**
  60316. * Clamps the rgb values by the min and max values and stores the result into "result"
  60317. * @param min defines minimum clamping value (default is 0)
  60318. * @param max defines maximum clamping value (default is 1)
  60319. * @param result defines color to store the result into
  60320. * @returns the original Color3
  60321. */
  60322. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  60323. /**
  60324. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  60325. * @param otherColor defines the second operand
  60326. * @returns the new Color3
  60327. */
  60328. add(otherColor: DeepImmutable<Color3>): Color3;
  60329. /**
  60330. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  60331. * @param otherColor defines the second operand
  60332. * @param result defines Color3 object to store the result into
  60333. * @returns the unmodified current Color3
  60334. */
  60335. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60336. /**
  60337. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  60338. * @param otherColor defines the second operand
  60339. * @returns the new Color3
  60340. */
  60341. subtract(otherColor: DeepImmutable<Color3>): Color3;
  60342. /**
  60343. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  60344. * @param otherColor defines the second operand
  60345. * @param result defines Color3 object to store the result into
  60346. * @returns the unmodified current Color3
  60347. */
  60348. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  60349. /**
  60350. * Copy the current object
  60351. * @returns a new Color3 copied the current one
  60352. */
  60353. clone(): Color3;
  60354. /**
  60355. * Copies the rgb values from the source in the current Color3
  60356. * @param source defines the source Color3 object
  60357. * @returns the updated Color3 object
  60358. */
  60359. copyFrom(source: DeepImmutable<Color3>): Color3;
  60360. /**
  60361. * Updates the Color3 rgb values from the given floats
  60362. * @param r defines the red component to read from
  60363. * @param g defines the green component to read from
  60364. * @param b defines the blue component to read from
  60365. * @returns the current Color3 object
  60366. */
  60367. copyFromFloats(r: number, g: number, b: number): Color3;
  60368. /**
  60369. * Updates the Color3 rgb values from the given floats
  60370. * @param r defines the red component to read from
  60371. * @param g defines the green component to read from
  60372. * @param b defines the blue component to read from
  60373. * @returns the current Color3 object
  60374. */
  60375. set(r: number, g: number, b: number): Color3;
  60376. /**
  60377. * Compute the Color3 hexadecimal code as a string
  60378. * @returns a string containing the hexadecimal representation of the Color3 object
  60379. */
  60380. toHexString(): string;
  60381. /**
  60382. * Computes a new Color3 converted from the current one to linear space
  60383. * @returns a new Color3 object
  60384. */
  60385. toLinearSpace(): Color3;
  60386. /**
  60387. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60388. * @param convertedColor defines the Color3 object where to store the linear space version
  60389. * @returns the unmodified Color3
  60390. */
  60391. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60392. /**
  60393. * Computes a new Color3 converted from the current one to gamma space
  60394. * @returns a new Color3 object
  60395. */
  60396. toGammaSpace(): Color3;
  60397. /**
  60398. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60399. * @param convertedColor defines the Color3 object where to store the gamma space version
  60400. * @returns the unmodified Color3
  60401. */
  60402. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60403. private static _BlackReadOnly;
  60404. /**
  60405. * Creates a new Color3 from the string containing valid hexadecimal values
  60406. * @param hex defines a string containing valid hexadecimal values
  60407. * @returns a new Color3 object
  60408. */
  60409. static FromHexString(hex: string): Color3;
  60410. /**
  60411. * Creates a new Color3 from the starting index of the given array
  60412. * @param array defines the source array
  60413. * @param offset defines an offset in the source array
  60414. * @returns a new Color3 object
  60415. */
  60416. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60417. /**
  60418. * Creates a new Color3 from integer values (< 256)
  60419. * @param r defines the red component to read from (value between 0 and 255)
  60420. * @param g defines the green component to read from (value between 0 and 255)
  60421. * @param b defines the blue component to read from (value between 0 and 255)
  60422. * @returns a new Color3 object
  60423. */
  60424. static FromInts(r: number, g: number, b: number): Color3;
  60425. /**
  60426. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60427. * @param start defines the start Color3 value
  60428. * @param end defines the end Color3 value
  60429. * @param amount defines the gradient value between start and end
  60430. * @returns a new Color3 object
  60431. */
  60432. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60433. /**
  60434. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60435. * @param left defines the start value
  60436. * @param right defines the end value
  60437. * @param amount defines the gradient factor
  60438. * @param result defines the Color3 object where to store the result
  60439. */
  60440. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60441. /**
  60442. * Returns a Color3 value containing a red color
  60443. * @returns a new Color3 object
  60444. */
  60445. static Red(): Color3;
  60446. /**
  60447. * Returns a Color3 value containing a green color
  60448. * @returns a new Color3 object
  60449. */
  60450. static Green(): Color3;
  60451. /**
  60452. * Returns a Color3 value containing a blue color
  60453. * @returns a new Color3 object
  60454. */
  60455. static Blue(): Color3;
  60456. /**
  60457. * Returns a Color3 value containing a black color
  60458. * @returns a new Color3 object
  60459. */
  60460. static Black(): Color3;
  60461. /**
  60462. * Gets a Color3 value containing a black color that must not be updated
  60463. */
  60464. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60465. /**
  60466. * Returns a Color3 value containing a white color
  60467. * @returns a new Color3 object
  60468. */
  60469. static White(): Color3;
  60470. /**
  60471. * Returns a Color3 value containing a purple color
  60472. * @returns a new Color3 object
  60473. */
  60474. static Purple(): Color3;
  60475. /**
  60476. * Returns a Color3 value containing a magenta color
  60477. * @returns a new Color3 object
  60478. */
  60479. static Magenta(): Color3;
  60480. /**
  60481. * Returns a Color3 value containing a yellow color
  60482. * @returns a new Color3 object
  60483. */
  60484. static Yellow(): Color3;
  60485. /**
  60486. * Returns a Color3 value containing a gray color
  60487. * @returns a new Color3 object
  60488. */
  60489. static Gray(): Color3;
  60490. /**
  60491. * Returns a Color3 value containing a teal color
  60492. * @returns a new Color3 object
  60493. */
  60494. static Teal(): Color3;
  60495. /**
  60496. * Returns a Color3 value containing a random color
  60497. * @returns a new Color3 object
  60498. */
  60499. static Random(): Color3;
  60500. }
  60501. /**
  60502. * Class used to hold a RBGA color
  60503. */
  60504. export class Color4 {
  60505. /**
  60506. * Defines the red component (between 0 and 1, default is 0)
  60507. */
  60508. r: number;
  60509. /**
  60510. * Defines the green component (between 0 and 1, default is 0)
  60511. */
  60512. g: number;
  60513. /**
  60514. * Defines the blue component (between 0 and 1, default is 0)
  60515. */
  60516. b: number;
  60517. /**
  60518. * Defines the alpha component (between 0 and 1, default is 1)
  60519. */
  60520. a: number;
  60521. /**
  60522. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60523. * @param r defines the red component (between 0 and 1, default is 0)
  60524. * @param g defines the green component (between 0 and 1, default is 0)
  60525. * @param b defines the blue component (between 0 and 1, default is 0)
  60526. * @param a defines the alpha component (between 0 and 1, default is 1)
  60527. */
  60528. constructor(
  60529. /**
  60530. * Defines the red component (between 0 and 1, default is 0)
  60531. */
  60532. r?: number,
  60533. /**
  60534. * Defines the green component (between 0 and 1, default is 0)
  60535. */
  60536. g?: number,
  60537. /**
  60538. * Defines the blue component (between 0 and 1, default is 0)
  60539. */
  60540. b?: number,
  60541. /**
  60542. * Defines the alpha component (between 0 and 1, default is 1)
  60543. */
  60544. a?: number);
  60545. /**
  60546. * Adds in place the given Color4 values to the current Color4 object
  60547. * @param right defines the second operand
  60548. * @returns the current updated Color4 object
  60549. */
  60550. addInPlace(right: DeepImmutable<Color4>): Color4;
  60551. /**
  60552. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60553. * @returns the new array
  60554. */
  60555. asArray(): number[];
  60556. /**
  60557. * Stores from the starting index in the given array the Color4 successive values
  60558. * @param array defines the array where to store the r,g,b components
  60559. * @param index defines an optional index in the target array to define where to start storing values
  60560. * @returns the current Color4 object
  60561. */
  60562. toArray(array: number[], index?: number): Color4;
  60563. /**
  60564. * Determines equality between Color4 objects
  60565. * @param otherColor defines the second operand
  60566. * @returns true if the rgba values are equal to the given ones
  60567. */
  60568. equals(otherColor: DeepImmutable<Color4>): boolean;
  60569. /**
  60570. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60571. * @param right defines the second operand
  60572. * @returns a new Color4 object
  60573. */
  60574. add(right: DeepImmutable<Color4>): Color4;
  60575. /**
  60576. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60577. * @param right defines the second operand
  60578. * @returns a new Color4 object
  60579. */
  60580. subtract(right: DeepImmutable<Color4>): Color4;
  60581. /**
  60582. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60583. * @param right defines the second operand
  60584. * @param result defines the Color4 object where to store the result
  60585. * @returns the current Color4 object
  60586. */
  60587. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60588. /**
  60589. * Creates a new Color4 with the current Color4 values multiplied by scale
  60590. * @param scale defines the scaling factor to apply
  60591. * @returns a new Color4 object
  60592. */
  60593. scale(scale: number): Color4;
  60594. /**
  60595. * Multiplies the current Color4 values by scale and stores the result in "result"
  60596. * @param scale defines the scaling factor to apply
  60597. * @param result defines the Color4 object where to store the result
  60598. * @returns the current unmodified Color4
  60599. */
  60600. scaleToRef(scale: number, result: Color4): Color4;
  60601. /**
  60602. * Scale the current Color4 values by a factor and add the result to a given Color4
  60603. * @param scale defines the scale factor
  60604. * @param result defines the Color4 object where to store the result
  60605. * @returns the unmodified current Color4
  60606. */
  60607. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60608. /**
  60609. * Clamps the rgb values by the min and max values and stores the result into "result"
  60610. * @param min defines minimum clamping value (default is 0)
  60611. * @param max defines maximum clamping value (default is 1)
  60612. * @param result defines color to store the result into.
  60613. * @returns the cuurent Color4
  60614. */
  60615. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60616. /**
  60617. * Multipy an Color4 value by another and return a new Color4 object
  60618. * @param color defines the Color4 value to multiply by
  60619. * @returns a new Color4 object
  60620. */
  60621. multiply(color: Color4): Color4;
  60622. /**
  60623. * Multipy a Color4 value by another and push the result in a reference value
  60624. * @param color defines the Color4 value to multiply by
  60625. * @param result defines the Color4 to fill the result in
  60626. * @returns the result Color4
  60627. */
  60628. multiplyToRef(color: Color4, result: Color4): Color4;
  60629. /**
  60630. * Creates a string with the Color4 current values
  60631. * @returns the string representation of the Color4 object
  60632. */
  60633. toString(): string;
  60634. /**
  60635. * Returns the string "Color4"
  60636. * @returns "Color4"
  60637. */
  60638. getClassName(): string;
  60639. /**
  60640. * Compute the Color4 hash code
  60641. * @returns an unique number that can be used to hash Color4 objects
  60642. */
  60643. getHashCode(): number;
  60644. /**
  60645. * Creates a new Color4 copied from the current one
  60646. * @returns a new Color4 object
  60647. */
  60648. clone(): Color4;
  60649. /**
  60650. * Copies the given Color4 values into the current one
  60651. * @param source defines the source Color4 object
  60652. * @returns the current updated Color4 object
  60653. */
  60654. copyFrom(source: Color4): Color4;
  60655. /**
  60656. * Copies the given float values into the current one
  60657. * @param r defines the red component to read from
  60658. * @param g defines the green component to read from
  60659. * @param b defines the blue component to read from
  60660. * @param a defines the alpha component to read from
  60661. * @returns the current updated Color4 object
  60662. */
  60663. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60664. /**
  60665. * Copies the given float values into the current one
  60666. * @param r defines the red component to read from
  60667. * @param g defines the green component to read from
  60668. * @param b defines the blue component to read from
  60669. * @param a defines the alpha component to read from
  60670. * @returns the current updated Color4 object
  60671. */
  60672. set(r: number, g: number, b: number, a: number): Color4;
  60673. /**
  60674. * Compute the Color4 hexadecimal code as a string
  60675. * @returns a string containing the hexadecimal representation of the Color4 object
  60676. */
  60677. toHexString(): string;
  60678. /**
  60679. * Computes a new Color4 converted from the current one to linear space
  60680. * @returns a new Color4 object
  60681. */
  60682. toLinearSpace(): Color4;
  60683. /**
  60684. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60685. * @param convertedColor defines the Color4 object where to store the linear space version
  60686. * @returns the unmodified Color4
  60687. */
  60688. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60689. /**
  60690. * Computes a new Color4 converted from the current one to gamma space
  60691. * @returns a new Color4 object
  60692. */
  60693. toGammaSpace(): Color4;
  60694. /**
  60695. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60696. * @param convertedColor defines the Color4 object where to store the gamma space version
  60697. * @returns the unmodified Color4
  60698. */
  60699. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60700. /**
  60701. * Creates a new Color4 from the string containing valid hexadecimal values
  60702. * @param hex defines a string containing valid hexadecimal values
  60703. * @returns a new Color4 object
  60704. */
  60705. static FromHexString(hex: string): Color4;
  60706. /**
  60707. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60708. * @param left defines the start value
  60709. * @param right defines the end value
  60710. * @param amount defines the gradient factor
  60711. * @returns a new Color4 object
  60712. */
  60713. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60714. /**
  60715. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60716. * @param left defines the start value
  60717. * @param right defines the end value
  60718. * @param amount defines the gradient factor
  60719. * @param result defines the Color4 object where to store data
  60720. */
  60721. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60722. /**
  60723. * Creates a new Color4 from a Color3 and an alpha value
  60724. * @param color3 defines the source Color3 to read from
  60725. * @param alpha defines the alpha component (1.0 by default)
  60726. * @returns a new Color4 object
  60727. */
  60728. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60729. /**
  60730. * Creates a new Color4 from the starting index element of the given array
  60731. * @param array defines the source array to read from
  60732. * @param offset defines the offset in the source array
  60733. * @returns a new Color4 object
  60734. */
  60735. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60736. /**
  60737. * Creates a new Color3 from integer values (< 256)
  60738. * @param r defines the red component to read from (value between 0 and 255)
  60739. * @param g defines the green component to read from (value between 0 and 255)
  60740. * @param b defines the blue component to read from (value between 0 and 255)
  60741. * @param a defines the alpha component to read from (value between 0 and 255)
  60742. * @returns a new Color3 object
  60743. */
  60744. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60745. /**
  60746. * Check the content of a given array and convert it to an array containing RGBA data
  60747. * If the original array was already containing count * 4 values then it is returned directly
  60748. * @param colors defines the array to check
  60749. * @param count defines the number of RGBA data to expect
  60750. * @returns an array containing count * 4 values (RGBA)
  60751. */
  60752. static CheckColors4(colors: number[], count: number): number[];
  60753. }
  60754. /**
  60755. * Class representing a vector containing 2 coordinates
  60756. */
  60757. export class Vector2 {
  60758. /** defines the first coordinate */
  60759. x: number;
  60760. /** defines the second coordinate */
  60761. y: number;
  60762. /**
  60763. * Creates a new Vector2 from the given x and y coordinates
  60764. * @param x defines the first coordinate
  60765. * @param y defines the second coordinate
  60766. */
  60767. constructor(
  60768. /** defines the first coordinate */
  60769. x?: number,
  60770. /** defines the second coordinate */
  60771. y?: number);
  60772. /**
  60773. * Gets a string with the Vector2 coordinates
  60774. * @returns a string with the Vector2 coordinates
  60775. */
  60776. toString(): string;
  60777. /**
  60778. * Gets class name
  60779. * @returns the string "Vector2"
  60780. */
  60781. getClassName(): string;
  60782. /**
  60783. * Gets current vector hash code
  60784. * @returns the Vector2 hash code as a number
  60785. */
  60786. getHashCode(): number;
  60787. /**
  60788. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60789. * @param array defines the source array
  60790. * @param index defines the offset in source array
  60791. * @returns the current Vector2
  60792. */
  60793. toArray(array: FloatArray, index?: number): Vector2;
  60794. /**
  60795. * Copy the current vector to an array
  60796. * @returns a new array with 2 elements: the Vector2 coordinates.
  60797. */
  60798. asArray(): number[];
  60799. /**
  60800. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60801. * @param source defines the source Vector2
  60802. * @returns the current updated Vector2
  60803. */
  60804. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60805. /**
  60806. * Sets the Vector2 coordinates with the given floats
  60807. * @param x defines the first coordinate
  60808. * @param y defines the second coordinate
  60809. * @returns the current updated Vector2
  60810. */
  60811. copyFromFloats(x: number, y: number): Vector2;
  60812. /**
  60813. * Sets the Vector2 coordinates with the given floats
  60814. * @param x defines the first coordinate
  60815. * @param y defines the second coordinate
  60816. * @returns the current updated Vector2
  60817. */
  60818. set(x: number, y: number): Vector2;
  60819. /**
  60820. * Add another vector with the current one
  60821. * @param otherVector defines the other vector
  60822. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60823. */
  60824. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60825. /**
  60826. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60827. * @param otherVector defines the other vector
  60828. * @param result defines the target vector
  60829. * @returns the unmodified current Vector2
  60830. */
  60831. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60832. /**
  60833. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60834. * @param otherVector defines the other vector
  60835. * @returns the current updated Vector2
  60836. */
  60837. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60838. /**
  60839. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60840. * @param otherVector defines the other vector
  60841. * @returns a new Vector2
  60842. */
  60843. addVector3(otherVector: Vector3): Vector2;
  60844. /**
  60845. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60846. * @param otherVector defines the other vector
  60847. * @returns a new Vector2
  60848. */
  60849. subtract(otherVector: Vector2): Vector2;
  60850. /**
  60851. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60852. * @param otherVector defines the other vector
  60853. * @param result defines the target vector
  60854. * @returns the unmodified current Vector2
  60855. */
  60856. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60857. /**
  60858. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60859. * @param otherVector defines the other vector
  60860. * @returns the current updated Vector2
  60861. */
  60862. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60863. /**
  60864. * Multiplies in place the current Vector2 coordinates by the given ones
  60865. * @param otherVector defines the other vector
  60866. * @returns the current updated Vector2
  60867. */
  60868. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60869. /**
  60870. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60871. * @param otherVector defines the other vector
  60872. * @returns a new Vector2
  60873. */
  60874. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60875. /**
  60876. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60877. * @param otherVector defines the other vector
  60878. * @param result defines the target vector
  60879. * @returns the unmodified current Vector2
  60880. */
  60881. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60882. /**
  60883. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60884. * @param x defines the first coordinate
  60885. * @param y defines the second coordinate
  60886. * @returns a new Vector2
  60887. */
  60888. multiplyByFloats(x: number, y: number): Vector2;
  60889. /**
  60890. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60891. * @param otherVector defines the other vector
  60892. * @returns a new Vector2
  60893. */
  60894. divide(otherVector: Vector2): Vector2;
  60895. /**
  60896. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60897. * @param otherVector defines the other vector
  60898. * @param result defines the target vector
  60899. * @returns the unmodified current Vector2
  60900. */
  60901. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60902. /**
  60903. * Divides the current Vector2 coordinates by the given ones
  60904. * @param otherVector defines the other vector
  60905. * @returns the current updated Vector2
  60906. */
  60907. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60908. /**
  60909. * Gets a new Vector2 with current Vector2 negated coordinates
  60910. * @returns a new Vector2
  60911. */
  60912. negate(): Vector2;
  60913. /**
  60914. * Multiply the Vector2 coordinates by scale
  60915. * @param scale defines the scaling factor
  60916. * @returns the current updated Vector2
  60917. */
  60918. scaleInPlace(scale: number): Vector2;
  60919. /**
  60920. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60921. * @param scale defines the scaling factor
  60922. * @returns a new Vector2
  60923. */
  60924. scale(scale: number): Vector2;
  60925. /**
  60926. * Scale the current Vector2 values by a factor to a given Vector2
  60927. * @param scale defines the scale factor
  60928. * @param result defines the Vector2 object where to store the result
  60929. * @returns the unmodified current Vector2
  60930. */
  60931. scaleToRef(scale: number, result: Vector2): Vector2;
  60932. /**
  60933. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60934. * @param scale defines the scale factor
  60935. * @param result defines the Vector2 object where to store the result
  60936. * @returns the unmodified current Vector2
  60937. */
  60938. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60939. /**
  60940. * Gets a boolean if two vectors are equals
  60941. * @param otherVector defines the other vector
  60942. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60943. */
  60944. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60945. /**
  60946. * Gets a boolean if two vectors are equals (using an epsilon value)
  60947. * @param otherVector defines the other vector
  60948. * @param epsilon defines the minimal distance to consider equality
  60949. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60950. */
  60951. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60952. /**
  60953. * Gets a new Vector2 from current Vector2 floored values
  60954. * @returns a new Vector2
  60955. */
  60956. floor(): Vector2;
  60957. /**
  60958. * Gets a new Vector2 from current Vector2 floored values
  60959. * @returns a new Vector2
  60960. */
  60961. fract(): Vector2;
  60962. /**
  60963. * Gets the length of the vector
  60964. * @returns the vector length (float)
  60965. */
  60966. length(): number;
  60967. /**
  60968. * Gets the vector squared length
  60969. * @returns the vector squared length (float)
  60970. */
  60971. lengthSquared(): number;
  60972. /**
  60973. * Normalize the vector
  60974. * @returns the current updated Vector2
  60975. */
  60976. normalize(): Vector2;
  60977. /**
  60978. * Gets a new Vector2 copied from the Vector2
  60979. * @returns a new Vector2
  60980. */
  60981. clone(): Vector2;
  60982. /**
  60983. * Gets a new Vector2(0, 0)
  60984. * @returns a new Vector2
  60985. */
  60986. static Zero(): Vector2;
  60987. /**
  60988. * Gets a new Vector2(1, 1)
  60989. * @returns a new Vector2
  60990. */
  60991. static One(): Vector2;
  60992. /**
  60993. * Gets a new Vector2 set from the given index element of the given array
  60994. * @param array defines the data source
  60995. * @param offset defines the offset in the data source
  60996. * @returns a new Vector2
  60997. */
  60998. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60999. /**
  61000. * Sets "result" from the given index element of the given array
  61001. * @param array defines the data source
  61002. * @param offset defines the offset in the data source
  61003. * @param result defines the target vector
  61004. */
  61005. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  61006. /**
  61007. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  61008. * @param value1 defines 1st point of control
  61009. * @param value2 defines 2nd point of control
  61010. * @param value3 defines 3rd point of control
  61011. * @param value4 defines 4th point of control
  61012. * @param amount defines the interpolation factor
  61013. * @returns a new Vector2
  61014. */
  61015. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  61016. /**
  61017. * 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".
  61018. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  61019. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  61020. * @param value defines the value to clamp
  61021. * @param min defines the lower limit
  61022. * @param max defines the upper limit
  61023. * @returns a new Vector2
  61024. */
  61025. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  61026. /**
  61027. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  61028. * @param value1 defines the 1st control point
  61029. * @param tangent1 defines the outgoing tangent
  61030. * @param value2 defines the 2nd control point
  61031. * @param tangent2 defines the incoming tangent
  61032. * @param amount defines the interpolation factor
  61033. * @returns a new Vector2
  61034. */
  61035. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  61036. /**
  61037. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  61038. * @param start defines the start vector
  61039. * @param end defines the end vector
  61040. * @param amount defines the interpolation factor
  61041. * @returns a new Vector2
  61042. */
  61043. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  61044. /**
  61045. * Gets the dot product of the vector "left" and the vector "right"
  61046. * @param left defines first vector
  61047. * @param right defines second vector
  61048. * @returns the dot product (float)
  61049. */
  61050. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  61051. /**
  61052. * Returns a new Vector2 equal to the normalized given vector
  61053. * @param vector defines the vector to normalize
  61054. * @returns a new Vector2
  61055. */
  61056. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  61057. /**
  61058. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  61059. * @param left defines 1st vector
  61060. * @param right defines 2nd vector
  61061. * @returns a new Vector2
  61062. */
  61063. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61064. /**
  61065. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  61066. * @param left defines 1st vector
  61067. * @param right defines 2nd vector
  61068. * @returns a new Vector2
  61069. */
  61070. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  61071. /**
  61072. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  61073. * @param vector defines the vector to transform
  61074. * @param transformation defines the matrix to apply
  61075. * @returns a new Vector2
  61076. */
  61077. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  61078. /**
  61079. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  61080. * @param vector defines the vector to transform
  61081. * @param transformation defines the matrix to apply
  61082. * @param result defines the target vector
  61083. */
  61084. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  61085. /**
  61086. * Determines if a given vector is included in a triangle
  61087. * @param p defines the vector to test
  61088. * @param p0 defines 1st triangle point
  61089. * @param p1 defines 2nd triangle point
  61090. * @param p2 defines 3rd triangle point
  61091. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  61092. */
  61093. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  61094. /**
  61095. * Gets the distance between the vectors "value1" and "value2"
  61096. * @param value1 defines first vector
  61097. * @param value2 defines second vector
  61098. * @returns the distance between vectors
  61099. */
  61100. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61101. /**
  61102. * Returns the squared distance between the vectors "value1" and "value2"
  61103. * @param value1 defines first vector
  61104. * @param value2 defines second vector
  61105. * @returns the squared distance between vectors
  61106. */
  61107. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  61108. /**
  61109. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  61110. * @param value1 defines first vector
  61111. * @param value2 defines second vector
  61112. * @returns a new Vector2
  61113. */
  61114. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  61115. /**
  61116. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  61117. * @param p defines the middle point
  61118. * @param segA defines one point of the segment
  61119. * @param segB defines the other point of the segment
  61120. * @returns the shortest distance
  61121. */
  61122. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  61123. }
  61124. /**
  61125. * Classed used to store (x,y,z) vector representation
  61126. * A Vector3 is the main object used in 3D geometry
  61127. * It can represent etiher the coordinates of a point the space, either a direction
  61128. * Reminder: js uses a left handed forward facing system
  61129. */
  61130. export class Vector3 {
  61131. /**
  61132. * Defines the first coordinates (on X axis)
  61133. */
  61134. x: number;
  61135. /**
  61136. * Defines the second coordinates (on Y axis)
  61137. */
  61138. y: number;
  61139. /**
  61140. * Defines the third coordinates (on Z axis)
  61141. */
  61142. z: number;
  61143. private static _UpReadOnly;
  61144. /**
  61145. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  61146. * @param x defines the first coordinates (on X axis)
  61147. * @param y defines the second coordinates (on Y axis)
  61148. * @param z defines the third coordinates (on Z axis)
  61149. */
  61150. constructor(
  61151. /**
  61152. * Defines the first coordinates (on X axis)
  61153. */
  61154. x?: number,
  61155. /**
  61156. * Defines the second coordinates (on Y axis)
  61157. */
  61158. y?: number,
  61159. /**
  61160. * Defines the third coordinates (on Z axis)
  61161. */
  61162. z?: number);
  61163. /**
  61164. * Creates a string representation of the Vector3
  61165. * @returns a string with the Vector3 coordinates.
  61166. */
  61167. toString(): string;
  61168. /**
  61169. * Gets the class name
  61170. * @returns the string "Vector3"
  61171. */
  61172. getClassName(): string;
  61173. /**
  61174. * Creates the Vector3 hash code
  61175. * @returns a number which tends to be unique between Vector3 instances
  61176. */
  61177. getHashCode(): number;
  61178. /**
  61179. * Creates an array containing three elements : the coordinates of the Vector3
  61180. * @returns a new array of numbers
  61181. */
  61182. asArray(): number[];
  61183. /**
  61184. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  61185. * @param array defines the destination array
  61186. * @param index defines the offset in the destination array
  61187. * @returns the current Vector3
  61188. */
  61189. toArray(array: FloatArray, index?: number): Vector3;
  61190. /**
  61191. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  61192. * @returns a new Quaternion object, computed from the Vector3 coordinates
  61193. */
  61194. toQuaternion(): Quaternion;
  61195. /**
  61196. * Adds the given vector to the current Vector3
  61197. * @param otherVector defines the second operand
  61198. * @returns the current updated Vector3
  61199. */
  61200. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61201. /**
  61202. * Adds the given coordinates to the current Vector3
  61203. * @param x defines the x coordinate of the operand
  61204. * @param y defines the y coordinate of the operand
  61205. * @param z defines the z coordinate of the operand
  61206. * @returns the current updated Vector3
  61207. */
  61208. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61209. /**
  61210. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  61211. * @param otherVector defines the second operand
  61212. * @returns the resulting Vector3
  61213. */
  61214. add(otherVector: DeepImmutable<Vector3>): Vector3;
  61215. /**
  61216. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  61217. * @param otherVector defines the second operand
  61218. * @param result defines the Vector3 object where to store the result
  61219. * @returns the current Vector3
  61220. */
  61221. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61222. /**
  61223. * Subtract the given vector from the current Vector3
  61224. * @param otherVector defines the second operand
  61225. * @returns the current updated Vector3
  61226. */
  61227. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61228. /**
  61229. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  61230. * @param otherVector defines the second operand
  61231. * @returns the resulting Vector3
  61232. */
  61233. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  61234. /**
  61235. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  61236. * @param otherVector defines the second operand
  61237. * @param result defines the Vector3 object where to store the result
  61238. * @returns the current Vector3
  61239. */
  61240. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61241. /**
  61242. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  61243. * @param x defines the x coordinate of the operand
  61244. * @param y defines the y coordinate of the operand
  61245. * @param z defines the z coordinate of the operand
  61246. * @returns the resulting Vector3
  61247. */
  61248. subtractFromFloats(x: number, y: number, z: number): Vector3;
  61249. /**
  61250. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  61251. * @param x defines the x coordinate of the operand
  61252. * @param y defines the y coordinate of the operand
  61253. * @param z defines the z coordinate of the operand
  61254. * @param result defines the Vector3 object where to store the result
  61255. * @returns the current Vector3
  61256. */
  61257. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  61258. /**
  61259. * Gets a new Vector3 set with the current Vector3 negated coordinates
  61260. * @returns a new Vector3
  61261. */
  61262. negate(): Vector3;
  61263. /**
  61264. * Multiplies the Vector3 coordinates by the float "scale"
  61265. * @param scale defines the multiplier factor
  61266. * @returns the current updated Vector3
  61267. */
  61268. scaleInPlace(scale: number): Vector3;
  61269. /**
  61270. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  61271. * @param scale defines the multiplier factor
  61272. * @returns a new Vector3
  61273. */
  61274. scale(scale: number): Vector3;
  61275. /**
  61276. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  61277. * @param scale defines the multiplier factor
  61278. * @param result defines the Vector3 object where to store the result
  61279. * @returns the current Vector3
  61280. */
  61281. scaleToRef(scale: number, result: Vector3): Vector3;
  61282. /**
  61283. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  61284. * @param scale defines the scale factor
  61285. * @param result defines the Vector3 object where to store the result
  61286. * @returns the unmodified current Vector3
  61287. */
  61288. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  61289. /**
  61290. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  61291. * @param otherVector defines the second operand
  61292. * @returns true if both vectors are equals
  61293. */
  61294. equals(otherVector: DeepImmutable<Vector3>): boolean;
  61295. /**
  61296. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  61297. * @param otherVector defines the second operand
  61298. * @param epsilon defines the minimal distance to define values as equals
  61299. * @returns true if both vectors are distant less than epsilon
  61300. */
  61301. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  61302. /**
  61303. * Returns true if the current Vector3 coordinates equals the given floats
  61304. * @param x defines the x coordinate of the operand
  61305. * @param y defines the y coordinate of the operand
  61306. * @param z defines the z coordinate of the operand
  61307. * @returns true if both vectors are equals
  61308. */
  61309. equalsToFloats(x: number, y: number, z: number): boolean;
  61310. /**
  61311. * Multiplies the current Vector3 coordinates by the given ones
  61312. * @param otherVector defines the second operand
  61313. * @returns the current updated Vector3
  61314. */
  61315. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  61316. /**
  61317. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  61318. * @param otherVector defines the second operand
  61319. * @returns the new Vector3
  61320. */
  61321. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  61322. /**
  61323. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  61324. * @param otherVector defines the second operand
  61325. * @param result defines the Vector3 object where to store the result
  61326. * @returns the current Vector3
  61327. */
  61328. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61329. /**
  61330. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  61331. * @param x defines the x coordinate of the operand
  61332. * @param y defines the y coordinate of the operand
  61333. * @param z defines the z coordinate of the operand
  61334. * @returns the new Vector3
  61335. */
  61336. multiplyByFloats(x: number, y: number, z: number): Vector3;
  61337. /**
  61338. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  61339. * @param otherVector defines the second operand
  61340. * @returns the new Vector3
  61341. */
  61342. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  61343. /**
  61344. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  61345. * @param otherVector defines the second operand
  61346. * @param result defines the Vector3 object where to store the result
  61347. * @returns the current Vector3
  61348. */
  61349. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  61350. /**
  61351. * Divides the current Vector3 coordinates by the given ones.
  61352. * @param otherVector defines the second operand
  61353. * @returns the current updated Vector3
  61354. */
  61355. divideInPlace(otherVector: Vector3): Vector3;
  61356. /**
  61357. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  61358. * @param other defines the second operand
  61359. * @returns the current updated Vector3
  61360. */
  61361. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61362. /**
  61363. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  61364. * @param other defines the second operand
  61365. * @returns the current updated Vector3
  61366. */
  61367. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61368. /**
  61369. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61370. * @param x defines the x coordinate of the operand
  61371. * @param y defines the y coordinate of the operand
  61372. * @param z defines the z coordinate of the operand
  61373. * @returns the current updated Vector3
  61374. */
  61375. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61376. /**
  61377. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61378. * @param x defines the x coordinate of the operand
  61379. * @param y defines the y coordinate of the operand
  61380. * @param z defines the z coordinate of the operand
  61381. * @returns the current updated Vector3
  61382. */
  61383. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61384. /**
  61385. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61386. * Check if is non uniform within a certain amount of decimal places to account for this
  61387. * @param epsilon the amount the values can differ
  61388. * @returns if the the vector is non uniform to a certain number of decimal places
  61389. */
  61390. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61391. /**
  61392. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61393. */
  61394. readonly isNonUniform: boolean;
  61395. /**
  61396. * Gets a new Vector3 from current Vector3 floored values
  61397. * @returns a new Vector3
  61398. */
  61399. floor(): Vector3;
  61400. /**
  61401. * Gets a new Vector3 from current Vector3 floored values
  61402. * @returns a new Vector3
  61403. */
  61404. fract(): Vector3;
  61405. /**
  61406. * Gets the length of the Vector3
  61407. * @returns the length of the Vecto3
  61408. */
  61409. length(): number;
  61410. /**
  61411. * Gets the squared length of the Vector3
  61412. * @returns squared length of the Vector3
  61413. */
  61414. lengthSquared(): number;
  61415. /**
  61416. * Normalize the current Vector3.
  61417. * Please note that this is an in place operation.
  61418. * @returns the current updated Vector3
  61419. */
  61420. normalize(): Vector3;
  61421. /**
  61422. * Reorders the x y z properties of the vector in place
  61423. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61424. * @returns the current updated vector
  61425. */
  61426. reorderInPlace(order: string): this;
  61427. /**
  61428. * Rotates the vector around 0,0,0 by a quaternion
  61429. * @param quaternion the rotation quaternion
  61430. * @param result vector to store the result
  61431. * @returns the resulting vector
  61432. */
  61433. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61434. /**
  61435. * Rotates a vector around a given point
  61436. * @param quaternion the rotation quaternion
  61437. * @param point the point to rotate around
  61438. * @param result vector to store the result
  61439. * @returns the resulting vector
  61440. */
  61441. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61442. /**
  61443. * Normalize the current Vector3 with the given input length.
  61444. * Please note that this is an in place operation.
  61445. * @param len the length of the vector
  61446. * @returns the current updated Vector3
  61447. */
  61448. normalizeFromLength(len: number): Vector3;
  61449. /**
  61450. * Normalize the current Vector3 to a new vector
  61451. * @returns the new Vector3
  61452. */
  61453. normalizeToNew(): Vector3;
  61454. /**
  61455. * Normalize the current Vector3 to the reference
  61456. * @param reference define the Vector3 to update
  61457. * @returns the updated Vector3
  61458. */
  61459. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61460. /**
  61461. * Creates a new Vector3 copied from the current Vector3
  61462. * @returns the new Vector3
  61463. */
  61464. clone(): Vector3;
  61465. /**
  61466. * Copies the given vector coordinates to the current Vector3 ones
  61467. * @param source defines the source Vector3
  61468. * @returns the current updated Vector3
  61469. */
  61470. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61471. /**
  61472. * Copies the given floats to the current Vector3 coordinates
  61473. * @param x defines the x coordinate of the operand
  61474. * @param y defines the y coordinate of the operand
  61475. * @param z defines the z coordinate of the operand
  61476. * @returns the current updated Vector3
  61477. */
  61478. copyFromFloats(x: number, y: number, z: number): Vector3;
  61479. /**
  61480. * Copies the given floats to the current Vector3 coordinates
  61481. * @param x defines the x coordinate of the operand
  61482. * @param y defines the y coordinate of the operand
  61483. * @param z defines the z coordinate of the operand
  61484. * @returns the current updated Vector3
  61485. */
  61486. set(x: number, y: number, z: number): Vector3;
  61487. /**
  61488. * Copies the given float to the current Vector3 coordinates
  61489. * @param v defines the x, y and z coordinates of the operand
  61490. * @returns the current updated Vector3
  61491. */
  61492. setAll(v: number): Vector3;
  61493. /**
  61494. * Get the clip factor between two vectors
  61495. * @param vector0 defines the first operand
  61496. * @param vector1 defines the second operand
  61497. * @param axis defines the axis to use
  61498. * @param size defines the size along the axis
  61499. * @returns the clip factor
  61500. */
  61501. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61502. /**
  61503. * Get angle between two vectors
  61504. * @param vector0 angle between vector0 and vector1
  61505. * @param vector1 angle between vector0 and vector1
  61506. * @param normal direction of the normal
  61507. * @return the angle between vector0 and vector1
  61508. */
  61509. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61510. /**
  61511. * Returns a new Vector3 set from the index "offset" of the given array
  61512. * @param array defines the source array
  61513. * @param offset defines the offset in the source array
  61514. * @returns the new Vector3
  61515. */
  61516. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61517. /**
  61518. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61519. * This function is deprecated. Use FromArray instead
  61520. * @param array defines the source array
  61521. * @param offset defines the offset in the source array
  61522. * @returns the new Vector3
  61523. */
  61524. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61525. /**
  61526. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61527. * @param array defines the source array
  61528. * @param offset defines the offset in the source array
  61529. * @param result defines the Vector3 where to store the result
  61530. */
  61531. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61532. /**
  61533. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61534. * This function is deprecated. Use FromArrayToRef instead.
  61535. * @param array defines the source array
  61536. * @param offset defines the offset in the source array
  61537. * @param result defines the Vector3 where to store the result
  61538. */
  61539. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61540. /**
  61541. * Sets the given vector "result" with the given floats.
  61542. * @param x defines the x coordinate of the source
  61543. * @param y defines the y coordinate of the source
  61544. * @param z defines the z coordinate of the source
  61545. * @param result defines the Vector3 where to store the result
  61546. */
  61547. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61548. /**
  61549. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61550. * @returns a new empty Vector3
  61551. */
  61552. static Zero(): Vector3;
  61553. /**
  61554. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61555. * @returns a new unit Vector3
  61556. */
  61557. static One(): Vector3;
  61558. /**
  61559. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61560. * @returns a new up Vector3
  61561. */
  61562. static Up(): Vector3;
  61563. /**
  61564. * Gets a up Vector3 that must not be updated
  61565. */
  61566. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61567. /**
  61568. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61569. * @returns a new down Vector3
  61570. */
  61571. static Down(): Vector3;
  61572. /**
  61573. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61574. * @returns a new forward Vector3
  61575. */
  61576. static Forward(): Vector3;
  61577. /**
  61578. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61579. * @returns a new forward Vector3
  61580. */
  61581. static Backward(): Vector3;
  61582. /**
  61583. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61584. * @returns a new right Vector3
  61585. */
  61586. static Right(): Vector3;
  61587. /**
  61588. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61589. * @returns a new left Vector3
  61590. */
  61591. static Left(): Vector3;
  61592. /**
  61593. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61594. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61595. * @param vector defines the Vector3 to transform
  61596. * @param transformation defines the transformation matrix
  61597. * @returns the transformed Vector3
  61598. */
  61599. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61600. /**
  61601. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61602. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61603. * @param vector defines the Vector3 to transform
  61604. * @param transformation defines the transformation matrix
  61605. * @param result defines the Vector3 where to store the result
  61606. */
  61607. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61608. /**
  61609. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61610. * This method computes tranformed coordinates only, not transformed direction vectors
  61611. * @param x define the x coordinate of the source vector
  61612. * @param y define the y coordinate of the source vector
  61613. * @param z define the z coordinate of the source vector
  61614. * @param transformation defines the transformation matrix
  61615. * @param result defines the Vector3 where to store the result
  61616. */
  61617. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61618. /**
  61619. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61620. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61621. * @param vector defines the Vector3 to transform
  61622. * @param transformation defines the transformation matrix
  61623. * @returns the new Vector3
  61624. */
  61625. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61626. /**
  61627. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61628. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61629. * @param vector defines the Vector3 to transform
  61630. * @param transformation defines the transformation matrix
  61631. * @param result defines the Vector3 where to store the result
  61632. */
  61633. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61634. /**
  61635. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61636. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61637. * @param x define the x coordinate of the source vector
  61638. * @param y define the y coordinate of the source vector
  61639. * @param z define the z coordinate of the source vector
  61640. * @param transformation defines the transformation matrix
  61641. * @param result defines the Vector3 where to store the result
  61642. */
  61643. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61644. /**
  61645. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61646. * @param value1 defines the first control point
  61647. * @param value2 defines the second control point
  61648. * @param value3 defines the third control point
  61649. * @param value4 defines the fourth control point
  61650. * @param amount defines the amount on the spline to use
  61651. * @returns the new Vector3
  61652. */
  61653. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61654. /**
  61655. * 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"
  61656. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61657. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61658. * @param value defines the current value
  61659. * @param min defines the lower range value
  61660. * @param max defines the upper range value
  61661. * @returns the new Vector3
  61662. */
  61663. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61664. /**
  61665. * 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"
  61666. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61667. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61668. * @param value defines the current value
  61669. * @param min defines the lower range value
  61670. * @param max defines the upper range value
  61671. * @param result defines the Vector3 where to store the result
  61672. */
  61673. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61674. /**
  61675. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61676. * @param value1 defines the first control point
  61677. * @param tangent1 defines the first tangent vector
  61678. * @param value2 defines the second control point
  61679. * @param tangent2 defines the second tangent vector
  61680. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61681. * @returns the new Vector3
  61682. */
  61683. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61684. /**
  61685. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61686. * @param start defines the start value
  61687. * @param end defines the end value
  61688. * @param amount max defines amount between both (between 0 and 1)
  61689. * @returns the new Vector3
  61690. */
  61691. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61692. /**
  61693. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61694. * @param start defines the start value
  61695. * @param end defines the end value
  61696. * @param amount max defines amount between both (between 0 and 1)
  61697. * @param result defines the Vector3 where to store the result
  61698. */
  61699. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61700. /**
  61701. * Returns the dot product (float) between the vectors "left" and "right"
  61702. * @param left defines the left operand
  61703. * @param right defines the right operand
  61704. * @returns the dot product
  61705. */
  61706. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61707. /**
  61708. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61709. * The cross product is then orthogonal to both "left" and "right"
  61710. * @param left defines the left operand
  61711. * @param right defines the right operand
  61712. * @returns the cross product
  61713. */
  61714. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61715. /**
  61716. * Sets the given vector "result" with the cross product of "left" and "right"
  61717. * The cross product is then orthogonal to both "left" and "right"
  61718. * @param left defines the left operand
  61719. * @param right defines the right operand
  61720. * @param result defines the Vector3 where to store the result
  61721. */
  61722. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61723. /**
  61724. * Returns a new Vector3 as the normalization of the given vector
  61725. * @param vector defines the Vector3 to normalize
  61726. * @returns the new Vector3
  61727. */
  61728. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61729. /**
  61730. * Sets the given vector "result" with the normalization of the given first vector
  61731. * @param vector defines the Vector3 to normalize
  61732. * @param result defines the Vector3 where to store the result
  61733. */
  61734. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61735. /**
  61736. * Project a Vector3 onto screen space
  61737. * @param vector defines the Vector3 to project
  61738. * @param world defines the world matrix to use
  61739. * @param transform defines the transform (view x projection) matrix to use
  61740. * @param viewport defines the screen viewport to use
  61741. * @returns the new Vector3
  61742. */
  61743. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61744. /** @hidden */
  61745. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61746. /**
  61747. * Unproject from screen space to object space
  61748. * @param source defines the screen space Vector3 to use
  61749. * @param viewportWidth defines the current width of the viewport
  61750. * @param viewportHeight defines the current height of the viewport
  61751. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61752. * @param transform defines the transform (view x projection) matrix to use
  61753. * @returns the new Vector3
  61754. */
  61755. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61756. /**
  61757. * Unproject from screen space to object space
  61758. * @param source defines the screen space Vector3 to use
  61759. * @param viewportWidth defines the current width of the viewport
  61760. * @param viewportHeight defines the current height of the viewport
  61761. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61762. * @param view defines the view matrix to use
  61763. * @param projection defines the projection matrix to use
  61764. * @returns the new Vector3
  61765. */
  61766. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61767. /**
  61768. * Unproject from screen space to object space
  61769. * @param source defines the screen space Vector3 to use
  61770. * @param viewportWidth defines the current width of the viewport
  61771. * @param viewportHeight defines the current height of the viewport
  61772. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61773. * @param view defines the view matrix to use
  61774. * @param projection defines the projection matrix to use
  61775. * @param result defines the Vector3 where to store the result
  61776. */
  61777. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61778. /**
  61779. * Unproject from screen space to object space
  61780. * @param sourceX defines the screen space x coordinate to use
  61781. * @param sourceY defines the screen space y coordinate to use
  61782. * @param sourceZ defines the screen space z coordinate to use
  61783. * @param viewportWidth defines the current width of the viewport
  61784. * @param viewportHeight defines the current height of the viewport
  61785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61786. * @param view defines the view matrix to use
  61787. * @param projection defines the projection matrix to use
  61788. * @param result defines the Vector3 where to store the result
  61789. */
  61790. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61791. /**
  61792. * Gets the minimal coordinate values between two Vector3
  61793. * @param left defines the first operand
  61794. * @param right defines the second operand
  61795. * @returns the new Vector3
  61796. */
  61797. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61798. /**
  61799. * Gets the maximal coordinate values between two Vector3
  61800. * @param left defines the first operand
  61801. * @param right defines the second operand
  61802. * @returns the new Vector3
  61803. */
  61804. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61805. /**
  61806. * Returns the distance between the vectors "value1" and "value2"
  61807. * @param value1 defines the first operand
  61808. * @param value2 defines the second operand
  61809. * @returns the distance
  61810. */
  61811. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61812. /**
  61813. * Returns the squared distance between the vectors "value1" and "value2"
  61814. * @param value1 defines the first operand
  61815. * @param value2 defines the second operand
  61816. * @returns the squared distance
  61817. */
  61818. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61819. /**
  61820. * Returns a new Vector3 located at the center between "value1" and "value2"
  61821. * @param value1 defines the first operand
  61822. * @param value2 defines the second operand
  61823. * @returns the new Vector3
  61824. */
  61825. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61826. /**
  61827. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61828. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61829. * to something in order to rotate it from its local system to the given target system
  61830. * Note: axis1, axis2 and axis3 are normalized during this operation
  61831. * @param axis1 defines the first axis
  61832. * @param axis2 defines the second axis
  61833. * @param axis3 defines the third axis
  61834. * @returns a new Vector3
  61835. */
  61836. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61837. /**
  61838. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61839. * @param axis1 defines the first axis
  61840. * @param axis2 defines the second axis
  61841. * @param axis3 defines the third axis
  61842. * @param ref defines the Vector3 where to store the result
  61843. */
  61844. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61845. }
  61846. /**
  61847. * Vector4 class created for EulerAngle class conversion to Quaternion
  61848. */
  61849. export class Vector4 {
  61850. /** x value of the vector */
  61851. x: number;
  61852. /** y value of the vector */
  61853. y: number;
  61854. /** z value of the vector */
  61855. z: number;
  61856. /** w value of the vector */
  61857. w: number;
  61858. /**
  61859. * Creates a Vector4 object from the given floats.
  61860. * @param x x value of the vector
  61861. * @param y y value of the vector
  61862. * @param z z value of the vector
  61863. * @param w w value of the vector
  61864. */
  61865. constructor(
  61866. /** x value of the vector */
  61867. x: number,
  61868. /** y value of the vector */
  61869. y: number,
  61870. /** z value of the vector */
  61871. z: number,
  61872. /** w value of the vector */
  61873. w: number);
  61874. /**
  61875. * Returns the string with the Vector4 coordinates.
  61876. * @returns a string containing all the vector values
  61877. */
  61878. toString(): string;
  61879. /**
  61880. * Returns the string "Vector4".
  61881. * @returns "Vector4"
  61882. */
  61883. getClassName(): string;
  61884. /**
  61885. * Returns the Vector4 hash code.
  61886. * @returns a unique hash code
  61887. */
  61888. getHashCode(): number;
  61889. /**
  61890. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61891. * @returns the resulting array
  61892. */
  61893. asArray(): number[];
  61894. /**
  61895. * Populates the given array from the given index with the Vector4 coordinates.
  61896. * @param array array to populate
  61897. * @param index index of the array to start at (default: 0)
  61898. * @returns the Vector4.
  61899. */
  61900. toArray(array: FloatArray, index?: number): Vector4;
  61901. /**
  61902. * Adds the given vector to the current Vector4.
  61903. * @param otherVector the vector to add
  61904. * @returns the updated Vector4.
  61905. */
  61906. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61907. /**
  61908. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61909. * @param otherVector the vector to add
  61910. * @returns the resulting vector
  61911. */
  61912. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61913. /**
  61914. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61915. * @param otherVector the vector to add
  61916. * @param result the vector to store the result
  61917. * @returns the current Vector4.
  61918. */
  61919. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61920. /**
  61921. * Subtract in place the given vector from the current Vector4.
  61922. * @param otherVector the vector to subtract
  61923. * @returns the updated Vector4.
  61924. */
  61925. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61926. /**
  61927. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61928. * @param otherVector the vector to add
  61929. * @returns the new vector with the result
  61930. */
  61931. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61932. /**
  61933. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61934. * @param otherVector the vector to subtract
  61935. * @param result the vector to store the result
  61936. * @returns the current Vector4.
  61937. */
  61938. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61939. /**
  61940. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61941. */
  61942. /**
  61943. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61944. * @param x value to subtract
  61945. * @param y value to subtract
  61946. * @param z value to subtract
  61947. * @param w value to subtract
  61948. * @returns new vector containing the result
  61949. */
  61950. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61951. /**
  61952. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61953. * @param x value to subtract
  61954. * @param y value to subtract
  61955. * @param z value to subtract
  61956. * @param w value to subtract
  61957. * @param result the vector to store the result in
  61958. * @returns the current Vector4.
  61959. */
  61960. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61961. /**
  61962. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61963. * @returns a new vector with the negated values
  61964. */
  61965. negate(): Vector4;
  61966. /**
  61967. * Multiplies the current Vector4 coordinates by scale (float).
  61968. * @param scale the number to scale with
  61969. * @returns the updated Vector4.
  61970. */
  61971. scaleInPlace(scale: number): Vector4;
  61972. /**
  61973. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61974. * @param scale the number to scale with
  61975. * @returns a new vector with the result
  61976. */
  61977. scale(scale: number): Vector4;
  61978. /**
  61979. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61980. * @param scale the number to scale with
  61981. * @param result a vector to store the result in
  61982. * @returns the current Vector4.
  61983. */
  61984. scaleToRef(scale: number, result: Vector4): Vector4;
  61985. /**
  61986. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61987. * @param scale defines the scale factor
  61988. * @param result defines the Vector4 object where to store the result
  61989. * @returns the unmodified current Vector4
  61990. */
  61991. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61992. /**
  61993. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61994. * @param otherVector the vector to compare against
  61995. * @returns true if they are equal
  61996. */
  61997. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61998. /**
  61999. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  62000. * @param otherVector vector to compare against
  62001. * @param epsilon (Default: very small number)
  62002. * @returns true if they are equal
  62003. */
  62004. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  62005. /**
  62006. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  62007. * @param x x value to compare against
  62008. * @param y y value to compare against
  62009. * @param z z value to compare against
  62010. * @param w w value to compare against
  62011. * @returns true if equal
  62012. */
  62013. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  62014. /**
  62015. * Multiplies in place the current Vector4 by the given one.
  62016. * @param otherVector vector to multiple with
  62017. * @returns the updated Vector4.
  62018. */
  62019. multiplyInPlace(otherVector: Vector4): Vector4;
  62020. /**
  62021. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  62022. * @param otherVector vector to multiple with
  62023. * @returns resulting new vector
  62024. */
  62025. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  62026. /**
  62027. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  62028. * @param otherVector vector to multiple with
  62029. * @param result vector to store the result
  62030. * @returns the current Vector4.
  62031. */
  62032. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62033. /**
  62034. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  62035. * @param x x value multiply with
  62036. * @param y y value multiply with
  62037. * @param z z value multiply with
  62038. * @param w w value multiply with
  62039. * @returns resulting new vector
  62040. */
  62041. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  62042. /**
  62043. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  62044. * @param otherVector vector to devide with
  62045. * @returns resulting new vector
  62046. */
  62047. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  62048. /**
  62049. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  62050. * @param otherVector vector to devide with
  62051. * @param result vector to store the result
  62052. * @returns the current Vector4.
  62053. */
  62054. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  62055. /**
  62056. * Divides the current Vector3 coordinates by the given ones.
  62057. * @param otherVector vector to devide with
  62058. * @returns the updated Vector3.
  62059. */
  62060. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  62061. /**
  62062. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  62063. * @param other defines the second operand
  62064. * @returns the current updated Vector4
  62065. */
  62066. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62067. /**
  62068. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  62069. * @param other defines the second operand
  62070. * @returns the current updated Vector4
  62071. */
  62072. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  62073. /**
  62074. * Gets a new Vector4 from current Vector4 floored values
  62075. * @returns a new Vector4
  62076. */
  62077. floor(): Vector4;
  62078. /**
  62079. * Gets a new Vector4 from current Vector3 floored values
  62080. * @returns a new Vector4
  62081. */
  62082. fract(): Vector4;
  62083. /**
  62084. * Returns the Vector4 length (float).
  62085. * @returns the length
  62086. */
  62087. length(): number;
  62088. /**
  62089. * Returns the Vector4 squared length (float).
  62090. * @returns the length squared
  62091. */
  62092. lengthSquared(): number;
  62093. /**
  62094. * Normalizes in place the Vector4.
  62095. * @returns the updated Vector4.
  62096. */
  62097. normalize(): Vector4;
  62098. /**
  62099. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  62100. * @returns this converted to a new vector3
  62101. */
  62102. toVector3(): Vector3;
  62103. /**
  62104. * Returns a new Vector4 copied from the current one.
  62105. * @returns the new cloned vector
  62106. */
  62107. clone(): Vector4;
  62108. /**
  62109. * Updates the current Vector4 with the given one coordinates.
  62110. * @param source the source vector to copy from
  62111. * @returns the updated Vector4.
  62112. */
  62113. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  62114. /**
  62115. * Updates the current Vector4 coordinates with the given floats.
  62116. * @param x float to copy from
  62117. * @param y float to copy from
  62118. * @param z float to copy from
  62119. * @param w float to copy from
  62120. * @returns the updated Vector4.
  62121. */
  62122. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  62123. /**
  62124. * Updates the current Vector4 coordinates with the given floats.
  62125. * @param x float to set from
  62126. * @param y float to set from
  62127. * @param z float to set from
  62128. * @param w float to set from
  62129. * @returns the updated Vector4.
  62130. */
  62131. set(x: number, y: number, z: number, w: number): Vector4;
  62132. /**
  62133. * Copies the given float to the current Vector3 coordinates
  62134. * @param v defines the x, y, z and w coordinates of the operand
  62135. * @returns the current updated Vector3
  62136. */
  62137. setAll(v: number): Vector4;
  62138. /**
  62139. * Returns a new Vector4 set from the starting index of the given array.
  62140. * @param array the array to pull values from
  62141. * @param offset the offset into the array to start at
  62142. * @returns the new vector
  62143. */
  62144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  62145. /**
  62146. * Updates the given vector "result" from the starting index of the given array.
  62147. * @param array the array to pull values from
  62148. * @param offset the offset into the array to start at
  62149. * @param result the vector to store the result in
  62150. */
  62151. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  62152. /**
  62153. * Updates the given vector "result" from the starting index of the given Float32Array.
  62154. * @param array the array to pull values from
  62155. * @param offset the offset into the array to start at
  62156. * @param result the vector to store the result in
  62157. */
  62158. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  62159. /**
  62160. * Updates the given vector "result" coordinates from the given floats.
  62161. * @param x float to set from
  62162. * @param y float to set from
  62163. * @param z float to set from
  62164. * @param w float to set from
  62165. * @param result the vector to the floats in
  62166. */
  62167. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  62168. /**
  62169. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  62170. * @returns the new vector
  62171. */
  62172. static Zero(): Vector4;
  62173. /**
  62174. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  62175. * @returns the new vector
  62176. */
  62177. static One(): Vector4;
  62178. /**
  62179. * Returns a new normalized Vector4 from the given one.
  62180. * @param vector the vector to normalize
  62181. * @returns the vector
  62182. */
  62183. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  62184. /**
  62185. * Updates the given vector "result" from the normalization of the given one.
  62186. * @param vector the vector to normalize
  62187. * @param result the vector to store the result in
  62188. */
  62189. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  62190. /**
  62191. * Returns a vector with the minimum values from the left and right vectors
  62192. * @param left left vector to minimize
  62193. * @param right right vector to minimize
  62194. * @returns a new vector with the minimum of the left and right vector values
  62195. */
  62196. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62197. /**
  62198. * Returns a vector with the maximum values from the left and right vectors
  62199. * @param left left vector to maximize
  62200. * @param right right vector to maximize
  62201. * @returns a new vector with the maximum of the left and right vector values
  62202. */
  62203. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  62204. /**
  62205. * Returns the distance (float) between the vectors "value1" and "value2".
  62206. * @param value1 value to calulate the distance between
  62207. * @param value2 value to calulate the distance between
  62208. * @return the distance between the two vectors
  62209. */
  62210. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62211. /**
  62212. * Returns the squared distance (float) between the vectors "value1" and "value2".
  62213. * @param value1 value to calulate the distance between
  62214. * @param value2 value to calulate the distance between
  62215. * @return the distance between the two vectors squared
  62216. */
  62217. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  62218. /**
  62219. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  62220. * @param value1 value to calulate the center between
  62221. * @param value2 value to calulate the center between
  62222. * @return the center between the two vectors
  62223. */
  62224. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  62225. /**
  62226. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  62227. * This methods computes transformed normalized direction vectors only.
  62228. * @param vector the vector to transform
  62229. * @param transformation the transformation matrix to apply
  62230. * @returns the new vector
  62231. */
  62232. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  62233. /**
  62234. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  62235. * This methods computes transformed normalized direction vectors only.
  62236. * @param vector the vector to transform
  62237. * @param transformation the transformation matrix to apply
  62238. * @param result the vector to store the result in
  62239. */
  62240. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62241. /**
  62242. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  62243. * This methods computes transformed normalized direction vectors only.
  62244. * @param x value to transform
  62245. * @param y value to transform
  62246. * @param z value to transform
  62247. * @param w value to transform
  62248. * @param transformation the transformation matrix to apply
  62249. * @param result the vector to store the results in
  62250. */
  62251. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  62252. /**
  62253. * Creates a new Vector4 from a Vector3
  62254. * @param source defines the source data
  62255. * @param w defines the 4th component (default is 0)
  62256. * @returns a new Vector4
  62257. */
  62258. static FromVector3(source: Vector3, w?: number): Vector4;
  62259. }
  62260. /**
  62261. * Interface for the size containing width and height
  62262. */
  62263. export interface ISize {
  62264. /**
  62265. * Width
  62266. */
  62267. width: number;
  62268. /**
  62269. * Heighht
  62270. */
  62271. height: number;
  62272. }
  62273. /**
  62274. * Size containing widht and height
  62275. */
  62276. export class Size implements ISize {
  62277. /**
  62278. * Width
  62279. */
  62280. width: number;
  62281. /**
  62282. * Height
  62283. */
  62284. height: number;
  62285. /**
  62286. * Creates a Size object from the given width and height (floats).
  62287. * @param width width of the new size
  62288. * @param height height of the new size
  62289. */
  62290. constructor(width: number, height: number);
  62291. /**
  62292. * Returns a string with the Size width and height
  62293. * @returns a string with the Size width and height
  62294. */
  62295. toString(): string;
  62296. /**
  62297. * "Size"
  62298. * @returns the string "Size"
  62299. */
  62300. getClassName(): string;
  62301. /**
  62302. * Returns the Size hash code.
  62303. * @returns a hash code for a unique width and height
  62304. */
  62305. getHashCode(): number;
  62306. /**
  62307. * Updates the current size from the given one.
  62308. * @param src the given size
  62309. */
  62310. copyFrom(src: Size): void;
  62311. /**
  62312. * Updates in place the current Size from the given floats.
  62313. * @param width width of the new size
  62314. * @param height height of the new size
  62315. * @returns the updated Size.
  62316. */
  62317. copyFromFloats(width: number, height: number): Size;
  62318. /**
  62319. * Updates in place the current Size from the given floats.
  62320. * @param width width to set
  62321. * @param height height to set
  62322. * @returns the updated Size.
  62323. */
  62324. set(width: number, height: number): Size;
  62325. /**
  62326. * Multiplies the width and height by numbers
  62327. * @param w factor to multiple the width by
  62328. * @param h factor to multiple the height by
  62329. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  62330. */
  62331. multiplyByFloats(w: number, h: number): Size;
  62332. /**
  62333. * Clones the size
  62334. * @returns a new Size copied from the given one.
  62335. */
  62336. clone(): Size;
  62337. /**
  62338. * True if the current Size and the given one width and height are strictly equal.
  62339. * @param other the other size to compare against
  62340. * @returns True if the current Size and the given one width and height are strictly equal.
  62341. */
  62342. equals(other: Size): boolean;
  62343. /**
  62344. * The surface of the Size : width * height (float).
  62345. */
  62346. readonly surface: number;
  62347. /**
  62348. * Create a new size of zero
  62349. * @returns a new Size set to (0.0, 0.0)
  62350. */
  62351. static Zero(): Size;
  62352. /**
  62353. * Sums the width and height of two sizes
  62354. * @param otherSize size to add to this size
  62355. * @returns a new Size set as the addition result of the current Size and the given one.
  62356. */
  62357. add(otherSize: Size): Size;
  62358. /**
  62359. * Subtracts the width and height of two
  62360. * @param otherSize size to subtract to this size
  62361. * @returns a new Size set as the subtraction result of the given one from the current Size.
  62362. */
  62363. subtract(otherSize: Size): Size;
  62364. /**
  62365. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62366. * @param start starting size to lerp between
  62367. * @param end end size to lerp between
  62368. * @param amount amount to lerp between the start and end values
  62369. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62370. */
  62371. static Lerp(start: Size, end: Size, amount: number): Size;
  62372. }
  62373. /**
  62374. * Class used to store quaternion data
  62375. * @see https://en.wikipedia.org/wiki/Quaternion
  62376. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62377. */
  62378. export class Quaternion {
  62379. /** defines the first component (0 by default) */
  62380. x: number;
  62381. /** defines the second component (0 by default) */
  62382. y: number;
  62383. /** defines the third component (0 by default) */
  62384. z: number;
  62385. /** defines the fourth component (1.0 by default) */
  62386. w: number;
  62387. /**
  62388. * Creates a new Quaternion from the given floats
  62389. * @param x defines the first component (0 by default)
  62390. * @param y defines the second component (0 by default)
  62391. * @param z defines the third component (0 by default)
  62392. * @param w defines the fourth component (1.0 by default)
  62393. */
  62394. constructor(
  62395. /** defines the first component (0 by default) */
  62396. x?: number,
  62397. /** defines the second component (0 by default) */
  62398. y?: number,
  62399. /** defines the third component (0 by default) */
  62400. z?: number,
  62401. /** defines the fourth component (1.0 by default) */
  62402. w?: number);
  62403. /**
  62404. * Gets a string representation for the current quaternion
  62405. * @returns a string with the Quaternion coordinates
  62406. */
  62407. toString(): string;
  62408. /**
  62409. * Gets the class name of the quaternion
  62410. * @returns the string "Quaternion"
  62411. */
  62412. getClassName(): string;
  62413. /**
  62414. * Gets a hash code for this quaternion
  62415. * @returns the quaternion hash code
  62416. */
  62417. getHashCode(): number;
  62418. /**
  62419. * Copy the quaternion to an array
  62420. * @returns a new array populated with 4 elements from the quaternion coordinates
  62421. */
  62422. asArray(): number[];
  62423. /**
  62424. * Check if two quaternions are equals
  62425. * @param otherQuaternion defines the second operand
  62426. * @return true if the current quaternion and the given one coordinates are strictly equals
  62427. */
  62428. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62429. /**
  62430. * Clone the current quaternion
  62431. * @returns a new quaternion copied from the current one
  62432. */
  62433. clone(): Quaternion;
  62434. /**
  62435. * Copy a quaternion to the current one
  62436. * @param other defines the other quaternion
  62437. * @returns the updated current quaternion
  62438. */
  62439. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62440. /**
  62441. * Updates the current quaternion with the given float coordinates
  62442. * @param x defines the x coordinate
  62443. * @param y defines the y coordinate
  62444. * @param z defines the z coordinate
  62445. * @param w defines the w coordinate
  62446. * @returns the updated current quaternion
  62447. */
  62448. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62449. /**
  62450. * Updates the current quaternion from the given float coordinates
  62451. * @param x defines the x coordinate
  62452. * @param y defines the y coordinate
  62453. * @param z defines the z coordinate
  62454. * @param w defines the w coordinate
  62455. * @returns the updated current quaternion
  62456. */
  62457. set(x: number, y: number, z: number, w: number): Quaternion;
  62458. /**
  62459. * Adds two quaternions
  62460. * @param other defines the second operand
  62461. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62462. */
  62463. add(other: DeepImmutable<Quaternion>): Quaternion;
  62464. /**
  62465. * Add a quaternion to the current one
  62466. * @param other defines the quaternion to add
  62467. * @returns the current quaternion
  62468. */
  62469. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62470. /**
  62471. * Subtract two quaternions
  62472. * @param other defines the second operand
  62473. * @returns a new quaternion as the subtraction result of the given one from the current one
  62474. */
  62475. subtract(other: Quaternion): Quaternion;
  62476. /**
  62477. * Multiplies the current quaternion by a scale factor
  62478. * @param value defines the scale factor
  62479. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62480. */
  62481. scale(value: number): Quaternion;
  62482. /**
  62483. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62484. * @param scale defines the scale factor
  62485. * @param result defines the Quaternion object where to store the result
  62486. * @returns the unmodified current quaternion
  62487. */
  62488. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62489. /**
  62490. * Multiplies in place the current quaternion by a scale factor
  62491. * @param value defines the scale factor
  62492. * @returns the current modified quaternion
  62493. */
  62494. scaleInPlace(value: number): Quaternion;
  62495. /**
  62496. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62497. * @param scale defines the scale factor
  62498. * @param result defines the Quaternion object where to store the result
  62499. * @returns the unmodified current quaternion
  62500. */
  62501. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62502. /**
  62503. * Multiplies two quaternions
  62504. * @param q1 defines the second operand
  62505. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62506. */
  62507. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62508. /**
  62509. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62510. * @param q1 defines the second operand
  62511. * @param result defines the target quaternion
  62512. * @returns the current quaternion
  62513. */
  62514. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62515. /**
  62516. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62517. * @param q1 defines the second operand
  62518. * @returns the currentupdated quaternion
  62519. */
  62520. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62521. /**
  62522. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62523. * @param ref defines the target quaternion
  62524. * @returns the current quaternion
  62525. */
  62526. conjugateToRef(ref: Quaternion): Quaternion;
  62527. /**
  62528. * Conjugates in place (1-q) the current quaternion
  62529. * @returns the current updated quaternion
  62530. */
  62531. conjugateInPlace(): Quaternion;
  62532. /**
  62533. * Conjugates in place (1-q) the current quaternion
  62534. * @returns a new quaternion
  62535. */
  62536. conjugate(): Quaternion;
  62537. /**
  62538. * Gets length of current quaternion
  62539. * @returns the quaternion length (float)
  62540. */
  62541. length(): number;
  62542. /**
  62543. * Normalize in place the current quaternion
  62544. * @returns the current updated quaternion
  62545. */
  62546. normalize(): Quaternion;
  62547. /**
  62548. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62549. * @param order is a reserved parameter and is ignore for now
  62550. * @returns a new Vector3 containing the Euler angles
  62551. */
  62552. toEulerAngles(order?: string): Vector3;
  62553. /**
  62554. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62555. * @param result defines the vector which will be filled with the Euler angles
  62556. * @param order is a reserved parameter and is ignore for now
  62557. * @returns the current unchanged quaternion
  62558. */
  62559. toEulerAnglesToRef(result: Vector3): Quaternion;
  62560. /**
  62561. * Updates the given rotation matrix with the current quaternion values
  62562. * @param result defines the target matrix
  62563. * @returns the current unchanged quaternion
  62564. */
  62565. toRotationMatrix(result: Matrix): Quaternion;
  62566. /**
  62567. * Updates the current quaternion from the given rotation matrix values
  62568. * @param matrix defines the source matrix
  62569. * @returns the current updated quaternion
  62570. */
  62571. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62572. /**
  62573. * Creates a new quaternion from a rotation matrix
  62574. * @param matrix defines the source matrix
  62575. * @returns a new quaternion created from the given rotation matrix values
  62576. */
  62577. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62578. /**
  62579. * Updates the given quaternion with the given rotation matrix values
  62580. * @param matrix defines the source matrix
  62581. * @param result defines the target quaternion
  62582. */
  62583. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62584. /**
  62585. * Returns the dot product (float) between the quaternions "left" and "right"
  62586. * @param left defines the left operand
  62587. * @param right defines the right operand
  62588. * @returns the dot product
  62589. */
  62590. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62591. /**
  62592. * Checks if the two quaternions are close to each other
  62593. * @param quat0 defines the first quaternion to check
  62594. * @param quat1 defines the second quaternion to check
  62595. * @returns true if the two quaternions are close to each other
  62596. */
  62597. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62598. /**
  62599. * Creates an empty quaternion
  62600. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62601. */
  62602. static Zero(): Quaternion;
  62603. /**
  62604. * Inverse a given quaternion
  62605. * @param q defines the source quaternion
  62606. * @returns a new quaternion as the inverted current quaternion
  62607. */
  62608. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62609. /**
  62610. * Inverse a given quaternion
  62611. * @param q defines the source quaternion
  62612. * @param result the quaternion the result will be stored in
  62613. * @returns the result quaternion
  62614. */
  62615. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62616. /**
  62617. * Creates an identity quaternion
  62618. * @returns the identity quaternion
  62619. */
  62620. static Identity(): Quaternion;
  62621. /**
  62622. * Gets a boolean indicating if the given quaternion is identity
  62623. * @param quaternion defines the quaternion to check
  62624. * @returns true if the quaternion is identity
  62625. */
  62626. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62627. /**
  62628. * Creates a quaternion from a rotation around an axis
  62629. * @param axis defines the axis to use
  62630. * @param angle defines the angle to use
  62631. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62632. */
  62633. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62634. /**
  62635. * Creates a rotation around an axis and stores it into the given quaternion
  62636. * @param axis defines the axis to use
  62637. * @param angle defines the angle to use
  62638. * @param result defines the target quaternion
  62639. * @returns the target quaternion
  62640. */
  62641. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62642. /**
  62643. * Creates a new quaternion from data stored into an array
  62644. * @param array defines the data source
  62645. * @param offset defines the offset in the source array where the data starts
  62646. * @returns a new quaternion
  62647. */
  62648. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62649. /**
  62650. * Create a quaternion from Euler rotation angles
  62651. * @param x Pitch
  62652. * @param y Yaw
  62653. * @param z Roll
  62654. * @returns the new Quaternion
  62655. */
  62656. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62657. /**
  62658. * Updates a quaternion from Euler rotation angles
  62659. * @param x Pitch
  62660. * @param y Yaw
  62661. * @param z Roll
  62662. * @param result the quaternion to store the result
  62663. * @returns the updated quaternion
  62664. */
  62665. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62666. /**
  62667. * Create a quaternion from Euler rotation vector
  62668. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62669. * @returns the new Quaternion
  62670. */
  62671. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62672. /**
  62673. * Updates a quaternion from Euler rotation vector
  62674. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62675. * @param result the quaternion to store the result
  62676. * @returns the updated quaternion
  62677. */
  62678. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62679. /**
  62680. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62681. * @param yaw defines the rotation around Y axis
  62682. * @param pitch defines the rotation around X axis
  62683. * @param roll defines the rotation around Z axis
  62684. * @returns the new quaternion
  62685. */
  62686. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62687. /**
  62688. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62689. * @param yaw defines the rotation around Y axis
  62690. * @param pitch defines the rotation around X axis
  62691. * @param roll defines the rotation around Z axis
  62692. * @param result defines the target quaternion
  62693. */
  62694. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62695. /**
  62696. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62697. * @param alpha defines the rotation around first axis
  62698. * @param beta defines the rotation around second axis
  62699. * @param gamma defines the rotation around third axis
  62700. * @returns the new quaternion
  62701. */
  62702. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62703. /**
  62704. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62705. * @param alpha defines the rotation around first axis
  62706. * @param beta defines the rotation around second axis
  62707. * @param gamma defines the rotation around third axis
  62708. * @param result defines the target quaternion
  62709. */
  62710. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62711. /**
  62712. * 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)
  62713. * @param axis1 defines the first axis
  62714. * @param axis2 defines the second axis
  62715. * @param axis3 defines the third axis
  62716. * @returns the new quaternion
  62717. */
  62718. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62719. /**
  62720. * 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
  62721. * @param axis1 defines the first axis
  62722. * @param axis2 defines the second axis
  62723. * @param axis3 defines the third axis
  62724. * @param ref defines the target quaternion
  62725. */
  62726. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62727. /**
  62728. * Interpolates between two quaternions
  62729. * @param left defines first quaternion
  62730. * @param right defines second quaternion
  62731. * @param amount defines the gradient to use
  62732. * @returns the new interpolated quaternion
  62733. */
  62734. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62735. /**
  62736. * Interpolates between two quaternions and stores it into a target quaternion
  62737. * @param left defines first quaternion
  62738. * @param right defines second quaternion
  62739. * @param amount defines the gradient to use
  62740. * @param result defines the target quaternion
  62741. */
  62742. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62743. /**
  62744. * Interpolate between two quaternions using Hermite interpolation
  62745. * @param value1 defines first quaternion
  62746. * @param tangent1 defines the incoming tangent
  62747. * @param value2 defines second quaternion
  62748. * @param tangent2 defines the outgoing tangent
  62749. * @param amount defines the target quaternion
  62750. * @returns the new interpolated quaternion
  62751. */
  62752. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62753. }
  62754. /**
  62755. * Class used to store matrix data (4x4)
  62756. */
  62757. export class Matrix {
  62758. private static _updateFlagSeed;
  62759. private static _identityReadOnly;
  62760. private _isIdentity;
  62761. private _isIdentityDirty;
  62762. private _isIdentity3x2;
  62763. private _isIdentity3x2Dirty;
  62764. /**
  62765. * Gets the update flag of the matrix which is an unique number for the matrix.
  62766. * It will be incremented every time the matrix data change.
  62767. * You can use it to speed the comparison between two versions of the same matrix.
  62768. */
  62769. updateFlag: number;
  62770. private readonly _m;
  62771. /**
  62772. * Gets the internal data of the matrix
  62773. */
  62774. readonly m: DeepImmutable<Float32Array>;
  62775. /** @hidden */
  62776. _markAsUpdated(): void;
  62777. /** @hidden */
  62778. private _updateIdentityStatus;
  62779. /**
  62780. * Creates an empty matrix (filled with zeros)
  62781. */
  62782. constructor();
  62783. /**
  62784. * Check if the current matrix is identity
  62785. * @returns true is the matrix is the identity matrix
  62786. */
  62787. isIdentity(): boolean;
  62788. /**
  62789. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62790. * @returns true is the matrix is the identity matrix
  62791. */
  62792. isIdentityAs3x2(): boolean;
  62793. /**
  62794. * Gets the determinant of the matrix
  62795. * @returns the matrix determinant
  62796. */
  62797. determinant(): number;
  62798. /**
  62799. * Returns the matrix as a Float32Array
  62800. * @returns the matrix underlying array
  62801. */
  62802. toArray(): DeepImmutable<Float32Array>;
  62803. /**
  62804. * Returns the matrix as a Float32Array
  62805. * @returns the matrix underlying array.
  62806. */
  62807. asArray(): DeepImmutable<Float32Array>;
  62808. /**
  62809. * Inverts the current matrix in place
  62810. * @returns the current inverted matrix
  62811. */
  62812. invert(): Matrix;
  62813. /**
  62814. * Sets all the matrix elements to zero
  62815. * @returns the current matrix
  62816. */
  62817. reset(): Matrix;
  62818. /**
  62819. * Adds the current matrix with a second one
  62820. * @param other defines the matrix to add
  62821. * @returns a new matrix as the addition of the current matrix and the given one
  62822. */
  62823. add(other: DeepImmutable<Matrix>): Matrix;
  62824. /**
  62825. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62826. * @param other defines the matrix to add
  62827. * @param result defines the target matrix
  62828. * @returns the current matrix
  62829. */
  62830. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62831. /**
  62832. * Adds in place the given matrix to the current matrix
  62833. * @param other defines the second operand
  62834. * @returns the current updated matrix
  62835. */
  62836. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62837. /**
  62838. * Sets the given matrix to the current inverted Matrix
  62839. * @param other defines the target matrix
  62840. * @returns the unmodified current matrix
  62841. */
  62842. invertToRef(other: Matrix): Matrix;
  62843. /**
  62844. * add a value at the specified position in the current Matrix
  62845. * @param index the index of the value within the matrix. between 0 and 15.
  62846. * @param value the value to be added
  62847. * @returns the current updated matrix
  62848. */
  62849. addAtIndex(index: number, value: number): Matrix;
  62850. /**
  62851. * mutiply the specified position in the current Matrix by a value
  62852. * @param index the index of the value within the matrix. between 0 and 15.
  62853. * @param value the value to be added
  62854. * @returns the current updated matrix
  62855. */
  62856. multiplyAtIndex(index: number, value: number): Matrix;
  62857. /**
  62858. * Inserts the translation vector (using 3 floats) in the current matrix
  62859. * @param x defines the 1st component of the translation
  62860. * @param y defines the 2nd component of the translation
  62861. * @param z defines the 3rd component of the translation
  62862. * @returns the current updated matrix
  62863. */
  62864. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62865. /**
  62866. * Adds the translation vector (using 3 floats) in the current matrix
  62867. * @param x defines the 1st component of the translation
  62868. * @param y defines the 2nd component of the translation
  62869. * @param z defines the 3rd component of the translation
  62870. * @returns the current updated matrix
  62871. */
  62872. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62873. /**
  62874. * Inserts the translation vector in the current matrix
  62875. * @param vector3 defines the translation to insert
  62876. * @returns the current updated matrix
  62877. */
  62878. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62879. /**
  62880. * Gets the translation value of the current matrix
  62881. * @returns a new Vector3 as the extracted translation from the matrix
  62882. */
  62883. getTranslation(): Vector3;
  62884. /**
  62885. * Fill a Vector3 with the extracted translation from the matrix
  62886. * @param result defines the Vector3 where to store the translation
  62887. * @returns the current matrix
  62888. */
  62889. getTranslationToRef(result: Vector3): Matrix;
  62890. /**
  62891. * Remove rotation and scaling part from the matrix
  62892. * @returns the updated matrix
  62893. */
  62894. removeRotationAndScaling(): Matrix;
  62895. /**
  62896. * Multiply two matrices
  62897. * @param other defines the second operand
  62898. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62899. */
  62900. multiply(other: DeepImmutable<Matrix>): Matrix;
  62901. /**
  62902. * Copy the current matrix from the given one
  62903. * @param other defines the source matrix
  62904. * @returns the current updated matrix
  62905. */
  62906. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62907. /**
  62908. * Populates the given array from the starting index with the current matrix values
  62909. * @param array defines the target array
  62910. * @param offset defines the offset in the target array where to start storing values
  62911. * @returns the current matrix
  62912. */
  62913. copyToArray(array: Float32Array, offset?: number): Matrix;
  62914. /**
  62915. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62916. * @param other defines the second operand
  62917. * @param result defines the matrix where to store the multiplication
  62918. * @returns the current matrix
  62919. */
  62920. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62921. /**
  62922. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62923. * @param other defines the second operand
  62924. * @param result defines the array where to store the multiplication
  62925. * @param offset defines the offset in the target array where to start storing values
  62926. * @returns the current matrix
  62927. */
  62928. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62929. /**
  62930. * Check equality between this matrix and a second one
  62931. * @param value defines the second matrix to compare
  62932. * @returns true is the current matrix and the given one values are strictly equal
  62933. */
  62934. equals(value: DeepImmutable<Matrix>): boolean;
  62935. /**
  62936. * Clone the current matrix
  62937. * @returns a new matrix from the current matrix
  62938. */
  62939. clone(): Matrix;
  62940. /**
  62941. * Returns the name of the current matrix class
  62942. * @returns the string "Matrix"
  62943. */
  62944. getClassName(): string;
  62945. /**
  62946. * Gets the hash code of the current matrix
  62947. * @returns the hash code
  62948. */
  62949. getHashCode(): number;
  62950. /**
  62951. * Decomposes the current Matrix into a translation, rotation and scaling components
  62952. * @param scale defines the scale vector3 given as a reference to update
  62953. * @param rotation defines the rotation quaternion given as a reference to update
  62954. * @param translation defines the translation vector3 given as a reference to update
  62955. * @returns true if operation was successful
  62956. */
  62957. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62958. /**
  62959. * Gets specific row of the matrix
  62960. * @param index defines the number of the row to get
  62961. * @returns the index-th row of the current matrix as a new Vector4
  62962. */
  62963. getRow(index: number): Nullable<Vector4>;
  62964. /**
  62965. * Sets the index-th row of the current matrix to the vector4 values
  62966. * @param index defines the number of the row to set
  62967. * @param row defines the target vector4
  62968. * @returns the updated current matrix
  62969. */
  62970. setRow(index: number, row: Vector4): Matrix;
  62971. /**
  62972. * Compute the transpose of the matrix
  62973. * @returns the new transposed matrix
  62974. */
  62975. transpose(): Matrix;
  62976. /**
  62977. * Compute the transpose of the matrix and store it in a given matrix
  62978. * @param result defines the target matrix
  62979. * @returns the current matrix
  62980. */
  62981. transposeToRef(result: Matrix): Matrix;
  62982. /**
  62983. * Sets the index-th row of the current matrix with the given 4 x float values
  62984. * @param index defines the row index
  62985. * @param x defines the x component to set
  62986. * @param y defines the y component to set
  62987. * @param z defines the z component to set
  62988. * @param w defines the w component to set
  62989. * @returns the updated current matrix
  62990. */
  62991. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62992. /**
  62993. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62994. * @param scale defines the scale factor
  62995. * @returns a new matrix
  62996. */
  62997. scale(scale: number): Matrix;
  62998. /**
  62999. * Scale the current matrix values by a factor to a given result matrix
  63000. * @param scale defines the scale factor
  63001. * @param result defines the matrix to store the result
  63002. * @returns the current matrix
  63003. */
  63004. scaleToRef(scale: number, result: Matrix): Matrix;
  63005. /**
  63006. * Scale the current matrix values by a factor and add the result to a given matrix
  63007. * @param scale defines the scale factor
  63008. * @param result defines the Matrix to store the result
  63009. * @returns the current matrix
  63010. */
  63011. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  63012. /**
  63013. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  63014. * @param ref matrix to store the result
  63015. */
  63016. toNormalMatrix(ref: Matrix): void;
  63017. /**
  63018. * Gets only rotation part of the current matrix
  63019. * @returns a new matrix sets to the extracted rotation matrix from the current one
  63020. */
  63021. getRotationMatrix(): Matrix;
  63022. /**
  63023. * Extracts the rotation matrix from the current one and sets it as the given "result"
  63024. * @param result defines the target matrix to store data to
  63025. * @returns the current matrix
  63026. */
  63027. getRotationMatrixToRef(result: Matrix): Matrix;
  63028. /**
  63029. * Toggles model matrix from being right handed to left handed in place and vice versa
  63030. */
  63031. toggleModelMatrixHandInPlace(): void;
  63032. /**
  63033. * Toggles projection matrix from being right handed to left handed in place and vice versa
  63034. */
  63035. toggleProjectionMatrixHandInPlace(): void;
  63036. /**
  63037. * Creates a matrix from an array
  63038. * @param array defines the source array
  63039. * @param offset defines an offset in the source array
  63040. * @returns a new Matrix set from the starting index of the given array
  63041. */
  63042. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  63043. /**
  63044. * Copy the content of an array into a given matrix
  63045. * @param array defines the source array
  63046. * @param offset defines an offset in the source array
  63047. * @param result defines the target matrix
  63048. */
  63049. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  63050. /**
  63051. * Stores an array into a matrix after having multiplied each component by a given factor
  63052. * @param array defines the source array
  63053. * @param offset defines the offset in the source array
  63054. * @param scale defines the scaling factor
  63055. * @param result defines the target matrix
  63056. */
  63057. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  63058. /**
  63059. * Gets an identity matrix that must not be updated
  63060. */
  63061. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  63062. /**
  63063. * Stores a list of values (16) inside a given matrix
  63064. * @param initialM11 defines 1st value of 1st row
  63065. * @param initialM12 defines 2nd value of 1st row
  63066. * @param initialM13 defines 3rd value of 1st row
  63067. * @param initialM14 defines 4th value of 1st row
  63068. * @param initialM21 defines 1st value of 2nd row
  63069. * @param initialM22 defines 2nd value of 2nd row
  63070. * @param initialM23 defines 3rd value of 2nd row
  63071. * @param initialM24 defines 4th value of 2nd row
  63072. * @param initialM31 defines 1st value of 3rd row
  63073. * @param initialM32 defines 2nd value of 3rd row
  63074. * @param initialM33 defines 3rd value of 3rd row
  63075. * @param initialM34 defines 4th value of 3rd row
  63076. * @param initialM41 defines 1st value of 4th row
  63077. * @param initialM42 defines 2nd value of 4th row
  63078. * @param initialM43 defines 3rd value of 4th row
  63079. * @param initialM44 defines 4th value of 4th row
  63080. * @param result defines the target matrix
  63081. */
  63082. 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;
  63083. /**
  63084. * Creates new matrix from a list of values (16)
  63085. * @param initialM11 defines 1st value of 1st row
  63086. * @param initialM12 defines 2nd value of 1st row
  63087. * @param initialM13 defines 3rd value of 1st row
  63088. * @param initialM14 defines 4th value of 1st row
  63089. * @param initialM21 defines 1st value of 2nd row
  63090. * @param initialM22 defines 2nd value of 2nd row
  63091. * @param initialM23 defines 3rd value of 2nd row
  63092. * @param initialM24 defines 4th value of 2nd row
  63093. * @param initialM31 defines 1st value of 3rd row
  63094. * @param initialM32 defines 2nd value of 3rd row
  63095. * @param initialM33 defines 3rd value of 3rd row
  63096. * @param initialM34 defines 4th value of 3rd row
  63097. * @param initialM41 defines 1st value of 4th row
  63098. * @param initialM42 defines 2nd value of 4th row
  63099. * @param initialM43 defines 3rd value of 4th row
  63100. * @param initialM44 defines 4th value of 4th row
  63101. * @returns the new matrix
  63102. */
  63103. 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;
  63104. /**
  63105. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63106. * @param scale defines the scale vector3
  63107. * @param rotation defines the rotation quaternion
  63108. * @param translation defines the translation vector3
  63109. * @returns a new matrix
  63110. */
  63111. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  63112. /**
  63113. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  63114. * @param scale defines the scale vector3
  63115. * @param rotation defines the rotation quaternion
  63116. * @param translation defines the translation vector3
  63117. * @param result defines the target matrix
  63118. */
  63119. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  63120. /**
  63121. * Creates a new identity matrix
  63122. * @returns a new identity matrix
  63123. */
  63124. static Identity(): Matrix;
  63125. /**
  63126. * Creates a new identity matrix and stores the result in a given matrix
  63127. * @param result defines the target matrix
  63128. */
  63129. static IdentityToRef(result: Matrix): void;
  63130. /**
  63131. * Creates a new zero matrix
  63132. * @returns a new zero matrix
  63133. */
  63134. static Zero(): Matrix;
  63135. /**
  63136. * Creates a new rotation matrix for "angle" radians around the X axis
  63137. * @param angle defines the angle (in radians) to use
  63138. * @return the new matrix
  63139. */
  63140. static RotationX(angle: number): Matrix;
  63141. /**
  63142. * Creates a new matrix as the invert of a given matrix
  63143. * @param source defines the source matrix
  63144. * @returns the new matrix
  63145. */
  63146. static Invert(source: DeepImmutable<Matrix>): Matrix;
  63147. /**
  63148. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  63149. * @param angle defines the angle (in radians) to use
  63150. * @param result defines the target matrix
  63151. */
  63152. static RotationXToRef(angle: number, result: Matrix): void;
  63153. /**
  63154. * Creates a new rotation matrix for "angle" radians around the Y axis
  63155. * @param angle defines the angle (in radians) to use
  63156. * @return the new matrix
  63157. */
  63158. static RotationY(angle: number): Matrix;
  63159. /**
  63160. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  63161. * @param angle defines the angle (in radians) to use
  63162. * @param result defines the target matrix
  63163. */
  63164. static RotationYToRef(angle: number, result: Matrix): void;
  63165. /**
  63166. * Creates a new rotation matrix for "angle" radians around the Z axis
  63167. * @param angle defines the angle (in radians) to use
  63168. * @return the new matrix
  63169. */
  63170. static RotationZ(angle: number): Matrix;
  63171. /**
  63172. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  63173. * @param angle defines the angle (in radians) to use
  63174. * @param result defines the target matrix
  63175. */
  63176. static RotationZToRef(angle: number, result: Matrix): void;
  63177. /**
  63178. * Creates a new rotation matrix for "angle" radians around the given axis
  63179. * @param axis defines the axis to use
  63180. * @param angle defines the angle (in radians) to use
  63181. * @return the new matrix
  63182. */
  63183. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  63184. /**
  63185. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  63186. * @param axis defines the axis to use
  63187. * @param angle defines the angle (in radians) to use
  63188. * @param result defines the target matrix
  63189. */
  63190. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  63191. /**
  63192. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  63193. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  63194. * @param from defines the vector to align
  63195. * @param to defines the vector to align to
  63196. * @param result defines the target matrix
  63197. */
  63198. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  63199. /**
  63200. * Creates a rotation matrix
  63201. * @param yaw defines the yaw angle in radians (Y axis)
  63202. * @param pitch defines the pitch angle in radians (X axis)
  63203. * @param roll defines the roll angle in radians (X axis)
  63204. * @returns the new rotation matrix
  63205. */
  63206. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  63207. /**
  63208. * Creates a rotation matrix and stores it in a given matrix
  63209. * @param yaw defines the yaw angle in radians (Y axis)
  63210. * @param pitch defines the pitch angle in radians (X axis)
  63211. * @param roll defines the roll angle in radians (X axis)
  63212. * @param result defines the target matrix
  63213. */
  63214. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  63215. /**
  63216. * Creates a scaling matrix
  63217. * @param x defines the scale factor on X axis
  63218. * @param y defines the scale factor on Y axis
  63219. * @param z defines the scale factor on Z axis
  63220. * @returns the new matrix
  63221. */
  63222. static Scaling(x: number, y: number, z: number): Matrix;
  63223. /**
  63224. * Creates a scaling matrix and stores it in a given matrix
  63225. * @param x defines the scale factor on X axis
  63226. * @param y defines the scale factor on Y axis
  63227. * @param z defines the scale factor on Z axis
  63228. * @param result defines the target matrix
  63229. */
  63230. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  63231. /**
  63232. * Creates a translation matrix
  63233. * @param x defines the translation on X axis
  63234. * @param y defines the translation on Y axis
  63235. * @param z defines the translationon Z axis
  63236. * @returns the new matrix
  63237. */
  63238. static Translation(x: number, y: number, z: number): Matrix;
  63239. /**
  63240. * Creates a translation matrix and stores it in a given matrix
  63241. * @param x defines the translation on X axis
  63242. * @param y defines the translation on Y axis
  63243. * @param z defines the translationon Z axis
  63244. * @param result defines the target matrix
  63245. */
  63246. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  63247. /**
  63248. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63249. * @param startValue defines the start value
  63250. * @param endValue defines the end value
  63251. * @param gradient defines the gradient factor
  63252. * @returns the new matrix
  63253. */
  63254. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63255. /**
  63256. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  63257. * @param startValue defines the start value
  63258. * @param endValue defines the end value
  63259. * @param gradient defines the gradient factor
  63260. * @param result defines the Matrix object where to store data
  63261. */
  63262. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63263. /**
  63264. * Builds a new matrix whose values are computed by:
  63265. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63266. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63267. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63268. * @param startValue defines the first matrix
  63269. * @param endValue defines the second matrix
  63270. * @param gradient defines the gradient between the two matrices
  63271. * @returns the new matrix
  63272. */
  63273. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  63274. /**
  63275. * Update a matrix to values which are computed by:
  63276. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  63277. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  63278. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  63279. * @param startValue defines the first matrix
  63280. * @param endValue defines the second matrix
  63281. * @param gradient defines the gradient between the two matrices
  63282. * @param result defines the target matrix
  63283. */
  63284. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  63285. /**
  63286. * 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"
  63287. * This function works in left handed mode
  63288. * @param eye defines the final position of the entity
  63289. * @param target defines where the entity should look at
  63290. * @param up defines the up vector for the entity
  63291. * @returns the new matrix
  63292. */
  63293. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63294. /**
  63295. * 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".
  63296. * This function works in left handed mode
  63297. * @param eye defines the final position of the entity
  63298. * @param target defines where the entity should look at
  63299. * @param up defines the up vector for the entity
  63300. * @param result defines the target matrix
  63301. */
  63302. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63303. /**
  63304. * 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"
  63305. * This function works in right handed mode
  63306. * @param eye defines the final position of the entity
  63307. * @param target defines where the entity should look at
  63308. * @param up defines the up vector for the entity
  63309. * @returns the new matrix
  63310. */
  63311. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  63312. /**
  63313. * 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".
  63314. * This function works in right handed mode
  63315. * @param eye defines the final position of the entity
  63316. * @param target defines where the entity should look at
  63317. * @param up defines the up vector for the entity
  63318. * @param result defines the target matrix
  63319. */
  63320. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  63321. /**
  63322. * Create a left-handed orthographic projection matrix
  63323. * @param width defines the viewport width
  63324. * @param height defines the viewport height
  63325. * @param znear defines the near clip plane
  63326. * @param zfar defines the far clip plane
  63327. * @returns a new matrix as a left-handed orthographic projection matrix
  63328. */
  63329. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63330. /**
  63331. * Store a left-handed orthographic projection to a given matrix
  63332. * @param width defines the viewport width
  63333. * @param height defines the viewport height
  63334. * @param znear defines the near clip plane
  63335. * @param zfar defines the far clip plane
  63336. * @param result defines the target matrix
  63337. */
  63338. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  63339. /**
  63340. * Create a left-handed orthographic projection matrix
  63341. * @param left defines the viewport left coordinate
  63342. * @param right defines the viewport right coordinate
  63343. * @param bottom defines the viewport bottom coordinate
  63344. * @param top defines the viewport top coordinate
  63345. * @param znear defines the near clip plane
  63346. * @param zfar defines the far clip plane
  63347. * @returns a new matrix as a left-handed orthographic projection matrix
  63348. */
  63349. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63350. /**
  63351. * Stores a left-handed orthographic projection into a given matrix
  63352. * @param left defines the viewport left coordinate
  63353. * @param right defines the viewport right coordinate
  63354. * @param bottom defines the viewport bottom coordinate
  63355. * @param top defines the viewport top coordinate
  63356. * @param znear defines the near clip plane
  63357. * @param zfar defines the far clip plane
  63358. * @param result defines the target matrix
  63359. */
  63360. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63361. /**
  63362. * Creates a right-handed orthographic projection matrix
  63363. * @param left defines the viewport left coordinate
  63364. * @param right defines the viewport right coordinate
  63365. * @param bottom defines the viewport bottom coordinate
  63366. * @param top defines the viewport top coordinate
  63367. * @param znear defines the near clip plane
  63368. * @param zfar defines the far clip plane
  63369. * @returns a new matrix as a right-handed orthographic projection matrix
  63370. */
  63371. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63372. /**
  63373. * Stores a right-handed orthographic projection into a given matrix
  63374. * @param left defines the viewport left coordinate
  63375. * @param right defines the viewport right coordinate
  63376. * @param bottom defines the viewport bottom coordinate
  63377. * @param top defines the viewport top coordinate
  63378. * @param znear defines the near clip plane
  63379. * @param zfar defines the far clip plane
  63380. * @param result defines the target matrix
  63381. */
  63382. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63383. /**
  63384. * Creates a left-handed perspective projection matrix
  63385. * @param width defines the viewport width
  63386. * @param height defines the viewport height
  63387. * @param znear defines the near clip plane
  63388. * @param zfar defines the far clip plane
  63389. * @returns a new matrix as a left-handed perspective projection matrix
  63390. */
  63391. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63392. /**
  63393. * Creates a left-handed perspective projection matrix
  63394. * @param fov defines the horizontal field of view
  63395. * @param aspect defines the aspect ratio
  63396. * @param znear defines the near clip plane
  63397. * @param zfar defines the far clip plane
  63398. * @returns a new matrix as a left-handed perspective projection matrix
  63399. */
  63400. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63401. /**
  63402. * Stores a left-handed perspective projection into a given matrix
  63403. * @param fov defines the horizontal field of view
  63404. * @param aspect defines the aspect ratio
  63405. * @param znear defines the near clip plane
  63406. * @param zfar defines the far clip plane
  63407. * @param result defines the target matrix
  63408. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63409. */
  63410. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63411. /**
  63412. * Creates a right-handed perspective projection matrix
  63413. * @param fov defines the horizontal field of view
  63414. * @param aspect defines the aspect ratio
  63415. * @param znear defines the near clip plane
  63416. * @param zfar defines the far clip plane
  63417. * @returns a new matrix as a right-handed perspective projection matrix
  63418. */
  63419. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63420. /**
  63421. * Stores a right-handed perspective projection into a given matrix
  63422. * @param fov defines the horizontal field of view
  63423. * @param aspect defines the aspect ratio
  63424. * @param znear defines the near clip plane
  63425. * @param zfar defines the far clip plane
  63426. * @param result defines the target matrix
  63427. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63428. */
  63429. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63430. /**
  63431. * Stores a perspective projection for WebVR info a given matrix
  63432. * @param fov defines the field of view
  63433. * @param znear defines the near clip plane
  63434. * @param zfar defines the far clip plane
  63435. * @param result defines the target matrix
  63436. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63437. */
  63438. static PerspectiveFovWebVRToRef(fov: {
  63439. upDegrees: number;
  63440. downDegrees: number;
  63441. leftDegrees: number;
  63442. rightDegrees: number;
  63443. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63444. /**
  63445. * Computes a complete transformation matrix
  63446. * @param viewport defines the viewport to use
  63447. * @param world defines the world matrix
  63448. * @param view defines the view matrix
  63449. * @param projection defines the projection matrix
  63450. * @param zmin defines the near clip plane
  63451. * @param zmax defines the far clip plane
  63452. * @returns the transformation matrix
  63453. */
  63454. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63455. /**
  63456. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63457. * @param matrix defines the matrix to use
  63458. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63459. */
  63460. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63461. /**
  63462. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63463. * @param matrix defines the matrix to use
  63464. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63465. */
  63466. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63467. /**
  63468. * Compute the transpose of a given matrix
  63469. * @param matrix defines the matrix to transpose
  63470. * @returns the new matrix
  63471. */
  63472. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63473. /**
  63474. * Compute the transpose of a matrix and store it in a target matrix
  63475. * @param matrix defines the matrix to transpose
  63476. * @param result defines the target matrix
  63477. */
  63478. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63479. /**
  63480. * Computes a reflection matrix from a plane
  63481. * @param plane defines the reflection plane
  63482. * @returns a new matrix
  63483. */
  63484. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63485. /**
  63486. * Computes a reflection matrix from a plane
  63487. * @param plane defines the reflection plane
  63488. * @param result defines the target matrix
  63489. */
  63490. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63491. /**
  63492. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63493. * @param xaxis defines the value of the 1st axis
  63494. * @param yaxis defines the value of the 2nd axis
  63495. * @param zaxis defines the value of the 3rd axis
  63496. * @param result defines the target matrix
  63497. */
  63498. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63499. /**
  63500. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63501. * @param quat defines the quaternion to use
  63502. * @param result defines the target matrix
  63503. */
  63504. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63505. }
  63506. /**
  63507. * Represens a plane by the equation ax + by + cz + d = 0
  63508. */
  63509. export class Plane {
  63510. /**
  63511. * Normal of the plane (a,b,c)
  63512. */
  63513. normal: Vector3;
  63514. /**
  63515. * d component of the plane
  63516. */
  63517. d: number;
  63518. /**
  63519. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63520. * @param a a component of the plane
  63521. * @param b b component of the plane
  63522. * @param c c component of the plane
  63523. * @param d d component of the plane
  63524. */
  63525. constructor(a: number, b: number, c: number, d: number);
  63526. /**
  63527. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63528. */
  63529. asArray(): number[];
  63530. /**
  63531. * @returns a new plane copied from the current Plane.
  63532. */
  63533. clone(): Plane;
  63534. /**
  63535. * @returns the string "Plane".
  63536. */
  63537. getClassName(): string;
  63538. /**
  63539. * @returns the Plane hash code.
  63540. */
  63541. getHashCode(): number;
  63542. /**
  63543. * Normalize the current Plane in place.
  63544. * @returns the updated Plane.
  63545. */
  63546. normalize(): Plane;
  63547. /**
  63548. * Applies a transformation the plane and returns the result
  63549. * @param transformation the transformation matrix to be applied to the plane
  63550. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63551. */
  63552. transform(transformation: DeepImmutable<Matrix>): Plane;
  63553. /**
  63554. * Calcualtte the dot product between the point and the plane normal
  63555. * @param point point to calculate the dot product with
  63556. * @returns the dot product (float) of the point coordinates and the plane normal.
  63557. */
  63558. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63559. /**
  63560. * Updates the current Plane from the plane defined by the three given points.
  63561. * @param point1 one of the points used to contruct the plane
  63562. * @param point2 one of the points used to contruct the plane
  63563. * @param point3 one of the points used to contruct the plane
  63564. * @returns the updated Plane.
  63565. */
  63566. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63567. /**
  63568. * Checks if the plane is facing a given direction
  63569. * @param direction the direction to check if the plane is facing
  63570. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63571. * @returns True is the vector "direction" is the same side than the plane normal.
  63572. */
  63573. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63574. /**
  63575. * Calculates the distance to a point
  63576. * @param point point to calculate distance to
  63577. * @returns the signed distance (float) from the given point to the Plane.
  63578. */
  63579. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63580. /**
  63581. * Creates a plane from an array
  63582. * @param array the array to create a plane from
  63583. * @returns a new Plane from the given array.
  63584. */
  63585. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63586. /**
  63587. * Creates a plane from three points
  63588. * @param point1 point used to create the plane
  63589. * @param point2 point used to create the plane
  63590. * @param point3 point used to create the plane
  63591. * @returns a new Plane defined by the three given points.
  63592. */
  63593. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63594. /**
  63595. * Creates a plane from an origin point and a normal
  63596. * @param origin origin of the plane to be constructed
  63597. * @param normal normal of the plane to be constructed
  63598. * @returns a new Plane the normal vector to this plane at the given origin point.
  63599. * Note : the vector "normal" is updated because normalized.
  63600. */
  63601. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63602. /**
  63603. * Calculates the distance from a plane and a point
  63604. * @param origin origin of the plane to be constructed
  63605. * @param normal normal of the plane to be constructed
  63606. * @param point point to calculate distance to
  63607. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63608. */
  63609. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63610. }
  63611. /**
  63612. * Class used to represent a viewport on screen
  63613. */
  63614. export class Viewport {
  63615. /** viewport left coordinate */
  63616. x: number;
  63617. /** viewport top coordinate */
  63618. y: number;
  63619. /**viewport width */
  63620. width: number;
  63621. /** viewport height */
  63622. height: number;
  63623. /**
  63624. * Creates a Viewport object located at (x, y) and sized (width, height)
  63625. * @param x defines viewport left coordinate
  63626. * @param y defines viewport top coordinate
  63627. * @param width defines the viewport width
  63628. * @param height defines the viewport height
  63629. */
  63630. constructor(
  63631. /** viewport left coordinate */
  63632. x: number,
  63633. /** viewport top coordinate */
  63634. y: number,
  63635. /**viewport width */
  63636. width: number,
  63637. /** viewport height */
  63638. height: number);
  63639. /**
  63640. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63641. * @param renderWidth defines the rendering width
  63642. * @param renderHeight defines the rendering height
  63643. * @returns a new Viewport
  63644. */
  63645. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63646. /**
  63647. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63648. * @param renderWidth defines the rendering width
  63649. * @param renderHeight defines the rendering height
  63650. * @param ref defines the target viewport
  63651. * @returns the current viewport
  63652. */
  63653. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63654. /**
  63655. * Returns a new Viewport copied from the current one
  63656. * @returns a new Viewport
  63657. */
  63658. clone(): Viewport;
  63659. }
  63660. /**
  63661. * Reprasents a camera frustum
  63662. */
  63663. export class Frustum {
  63664. /**
  63665. * Gets the planes representing the frustum
  63666. * @param transform matrix to be applied to the returned planes
  63667. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63668. */
  63669. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63670. /**
  63671. * Gets the near frustum plane transformed by the transform matrix
  63672. * @param transform transformation matrix to be applied to the resulting frustum plane
  63673. * @param frustumPlane the resuling frustum plane
  63674. */
  63675. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63676. /**
  63677. * Gets the far frustum plane transformed by the transform matrix
  63678. * @param transform transformation matrix to be applied to the resulting frustum plane
  63679. * @param frustumPlane the resuling frustum plane
  63680. */
  63681. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63682. /**
  63683. * Gets the left frustum plane transformed by the transform matrix
  63684. * @param transform transformation matrix to be applied to the resulting frustum plane
  63685. * @param frustumPlane the resuling frustum plane
  63686. */
  63687. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63688. /**
  63689. * Gets the right frustum plane transformed by the transform matrix
  63690. * @param transform transformation matrix to be applied to the resulting frustum plane
  63691. * @param frustumPlane the resuling frustum plane
  63692. */
  63693. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63694. /**
  63695. * Gets the top frustum plane transformed by the transform matrix
  63696. * @param transform transformation matrix to be applied to the resulting frustum plane
  63697. * @param frustumPlane the resuling frustum plane
  63698. */
  63699. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63700. /**
  63701. * Gets the bottom frustum plane transformed by the transform matrix
  63702. * @param transform transformation matrix to be applied to the resulting frustum plane
  63703. * @param frustumPlane the resuling frustum plane
  63704. */
  63705. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63706. /**
  63707. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63708. * @param transform transformation matrix to be applied to the resulting frustum planes
  63709. * @param frustumPlanes the resuling frustum planes
  63710. */
  63711. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63712. }
  63713. /** Defines supported spaces */
  63714. export enum Space {
  63715. /** Local (object) space */
  63716. LOCAL = 0,
  63717. /** World space */
  63718. WORLD = 1,
  63719. /** Bone space */
  63720. BONE = 2
  63721. }
  63722. /** Defines the 3 main axes */
  63723. export class Axis {
  63724. /** X axis */
  63725. static X: Vector3;
  63726. /** Y axis */
  63727. static Y: Vector3;
  63728. /** Z axis */
  63729. static Z: Vector3;
  63730. }
  63731. /** Class used to represent a Bezier curve */
  63732. export class BezierCurve {
  63733. /**
  63734. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63735. * @param t defines the time
  63736. * @param x1 defines the left coordinate on X axis
  63737. * @param y1 defines the left coordinate on Y axis
  63738. * @param x2 defines the right coordinate on X axis
  63739. * @param y2 defines the right coordinate on Y axis
  63740. * @returns the interpolated value
  63741. */
  63742. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63743. }
  63744. /**
  63745. * Defines potential orientation for back face culling
  63746. */
  63747. export enum Orientation {
  63748. /**
  63749. * Clockwise
  63750. */
  63751. CW = 0,
  63752. /** Counter clockwise */
  63753. CCW = 1
  63754. }
  63755. /**
  63756. * Defines angle representation
  63757. */
  63758. export class Angle {
  63759. private _radians;
  63760. /**
  63761. * Creates an Angle object of "radians" radians (float).
  63762. * @param radians the angle in radians
  63763. */
  63764. constructor(radians: number);
  63765. /**
  63766. * Get value in degrees
  63767. * @returns the Angle value in degrees (float)
  63768. */
  63769. degrees(): number;
  63770. /**
  63771. * Get value in radians
  63772. * @returns the Angle value in radians (float)
  63773. */
  63774. radians(): number;
  63775. /**
  63776. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63777. * @param a defines first vector
  63778. * @param b defines second vector
  63779. * @returns a new Angle
  63780. */
  63781. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63782. /**
  63783. * Gets a new Angle object from the given float in radians
  63784. * @param radians defines the angle value in radians
  63785. * @returns a new Angle
  63786. */
  63787. static FromRadians(radians: number): Angle;
  63788. /**
  63789. * Gets a new Angle object from the given float in degrees
  63790. * @param degrees defines the angle value in degrees
  63791. * @returns a new Angle
  63792. */
  63793. static FromDegrees(degrees: number): Angle;
  63794. }
  63795. /**
  63796. * This represents an arc in a 2d space.
  63797. */
  63798. export class Arc2 {
  63799. /** Defines the start point of the arc */
  63800. startPoint: Vector2;
  63801. /** Defines the mid point of the arc */
  63802. midPoint: Vector2;
  63803. /** Defines the end point of the arc */
  63804. endPoint: Vector2;
  63805. /**
  63806. * Defines the center point of the arc.
  63807. */
  63808. centerPoint: Vector2;
  63809. /**
  63810. * Defines the radius of the arc.
  63811. */
  63812. radius: number;
  63813. /**
  63814. * Defines the angle of the arc (from mid point to end point).
  63815. */
  63816. angle: Angle;
  63817. /**
  63818. * Defines the start angle of the arc (from start point to middle point).
  63819. */
  63820. startAngle: Angle;
  63821. /**
  63822. * Defines the orientation of the arc (clock wise/counter clock wise).
  63823. */
  63824. orientation: Orientation;
  63825. /**
  63826. * Creates an Arc object from the three given points : start, middle and end.
  63827. * @param startPoint Defines the start point of the arc
  63828. * @param midPoint Defines the midlle point of the arc
  63829. * @param endPoint Defines the end point of the arc
  63830. */
  63831. constructor(
  63832. /** Defines the start point of the arc */
  63833. startPoint: Vector2,
  63834. /** Defines the mid point of the arc */
  63835. midPoint: Vector2,
  63836. /** Defines the end point of the arc */
  63837. endPoint: Vector2);
  63838. }
  63839. /**
  63840. * Represents a 2D path made up of multiple 2D points
  63841. */
  63842. export class Path2 {
  63843. private _points;
  63844. private _length;
  63845. /**
  63846. * If the path start and end point are the same
  63847. */
  63848. closed: boolean;
  63849. /**
  63850. * Creates a Path2 object from the starting 2D coordinates x and y.
  63851. * @param x the starting points x value
  63852. * @param y the starting points y value
  63853. */
  63854. constructor(x: number, y: number);
  63855. /**
  63856. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63857. * @param x the added points x value
  63858. * @param y the added points y value
  63859. * @returns the updated Path2.
  63860. */
  63861. addLineTo(x: number, y: number): Path2;
  63862. /**
  63863. * 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.
  63864. * @param midX middle point x value
  63865. * @param midY middle point y value
  63866. * @param endX end point x value
  63867. * @param endY end point y value
  63868. * @param numberOfSegments (default: 36)
  63869. * @returns the updated Path2.
  63870. */
  63871. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63872. /**
  63873. * Closes the Path2.
  63874. * @returns the Path2.
  63875. */
  63876. close(): Path2;
  63877. /**
  63878. * Gets the sum of the distance between each sequential point in the path
  63879. * @returns the Path2 total length (float).
  63880. */
  63881. length(): number;
  63882. /**
  63883. * Gets the points which construct the path
  63884. * @returns the Path2 internal array of points.
  63885. */
  63886. getPoints(): Vector2[];
  63887. /**
  63888. * Retreives the point at the distance aways from the starting point
  63889. * @param normalizedLengthPosition the length along the path to retreive the point from
  63890. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63891. */
  63892. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63893. /**
  63894. * Creates a new path starting from an x and y position
  63895. * @param x starting x value
  63896. * @param y starting y value
  63897. * @returns a new Path2 starting at the coordinates (x, y).
  63898. */
  63899. static StartingAt(x: number, y: number): Path2;
  63900. }
  63901. /**
  63902. * Represents a 3D path made up of multiple 3D points
  63903. */
  63904. export class Path3D {
  63905. /**
  63906. * an array of Vector3, the curve axis of the Path3D
  63907. */
  63908. path: Vector3[];
  63909. private _curve;
  63910. private _distances;
  63911. private _tangents;
  63912. private _normals;
  63913. private _binormals;
  63914. private _raw;
  63915. /**
  63916. * new Path3D(path, normal, raw)
  63917. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63918. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63919. * @param path an array of Vector3, the curve axis of the Path3D
  63920. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63921. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63922. */
  63923. constructor(
  63924. /**
  63925. * an array of Vector3, the curve axis of the Path3D
  63926. */
  63927. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63928. /**
  63929. * Returns the Path3D array of successive Vector3 designing its curve.
  63930. * @returns the Path3D array of successive Vector3 designing its curve.
  63931. */
  63932. getCurve(): Vector3[];
  63933. /**
  63934. * Returns an array populated with tangent vectors on each Path3D curve point.
  63935. * @returns an array populated with tangent vectors on each Path3D curve point.
  63936. */
  63937. getTangents(): Vector3[];
  63938. /**
  63939. * Returns an array populated with normal vectors on each Path3D curve point.
  63940. * @returns an array populated with normal vectors on each Path3D curve point.
  63941. */
  63942. getNormals(): Vector3[];
  63943. /**
  63944. * Returns an array populated with binormal vectors on each Path3D curve point.
  63945. * @returns an array populated with binormal vectors on each Path3D curve point.
  63946. */
  63947. getBinormals(): Vector3[];
  63948. /**
  63949. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63950. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63951. */
  63952. getDistances(): number[];
  63953. /**
  63954. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63955. * @param path path which all values are copied into the curves points
  63956. * @param firstNormal which should be projected onto the curve
  63957. * @returns the same object updated.
  63958. */
  63959. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63960. private _compute;
  63961. private _getFirstNonNullVector;
  63962. private _getLastNonNullVector;
  63963. private _normalVector;
  63964. }
  63965. /**
  63966. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63967. * A Curve3 is designed from a series of successive Vector3.
  63968. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63969. */
  63970. export class Curve3 {
  63971. private _points;
  63972. private _length;
  63973. /**
  63974. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63975. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63976. * @param v1 (Vector3) the control point
  63977. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63978. * @param nbPoints (integer) the wanted number of points in the curve
  63979. * @returns the created Curve3
  63980. */
  63981. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63982. /**
  63983. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63984. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63985. * @param v1 (Vector3) the first control point
  63986. * @param v2 (Vector3) the second control point
  63987. * @param v3 (Vector3) the end point of the Cubic Bezier
  63988. * @param nbPoints (integer) the wanted number of points in the curve
  63989. * @returns the created Curve3
  63990. */
  63991. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63992. /**
  63993. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63994. * @param p1 (Vector3) the origin point of the Hermite Spline
  63995. * @param t1 (Vector3) the tangent vector at the origin point
  63996. * @param p2 (Vector3) the end point of the Hermite Spline
  63997. * @param t2 (Vector3) the tangent vector at the end point
  63998. * @param nbPoints (integer) the wanted number of points in the curve
  63999. * @returns the created Curve3
  64000. */
  64001. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  64002. /**
  64003. * Returns a Curve3 object along a CatmullRom Spline curve :
  64004. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  64005. * @param nbPoints (integer) the wanted number of points between each curve control points
  64006. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  64007. * @returns the created Curve3
  64008. */
  64009. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  64010. /**
  64011. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  64012. * A Curve3 is designed from a series of successive Vector3.
  64013. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  64014. * @param points points which make up the curve
  64015. */
  64016. constructor(points: Vector3[]);
  64017. /**
  64018. * @returns the Curve3 stored array of successive Vector3
  64019. */
  64020. getPoints(): Vector3[];
  64021. /**
  64022. * @returns the computed length (float) of the curve.
  64023. */
  64024. length(): number;
  64025. /**
  64026. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  64027. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  64028. * curveA and curveB keep unchanged.
  64029. * @param curve the curve to continue from this curve
  64030. * @returns the newly constructed curve
  64031. */
  64032. continue(curve: DeepImmutable<Curve3>): Curve3;
  64033. private _computeLength;
  64034. }
  64035. /**
  64036. * Contains position and normal vectors for a vertex
  64037. */
  64038. export class PositionNormalVertex {
  64039. /** the position of the vertex (defaut: 0,0,0) */
  64040. position: Vector3;
  64041. /** the normal of the vertex (defaut: 0,1,0) */
  64042. normal: Vector3;
  64043. /**
  64044. * Creates a PositionNormalVertex
  64045. * @param position the position of the vertex (defaut: 0,0,0)
  64046. * @param normal the normal of the vertex (defaut: 0,1,0)
  64047. */
  64048. constructor(
  64049. /** the position of the vertex (defaut: 0,0,0) */
  64050. position?: Vector3,
  64051. /** the normal of the vertex (defaut: 0,1,0) */
  64052. normal?: Vector3);
  64053. /**
  64054. * Clones the PositionNormalVertex
  64055. * @returns the cloned PositionNormalVertex
  64056. */
  64057. clone(): PositionNormalVertex;
  64058. }
  64059. /**
  64060. * Contains position, normal and uv vectors for a vertex
  64061. */
  64062. export class PositionNormalTextureVertex {
  64063. /** the position of the vertex (defaut: 0,0,0) */
  64064. position: Vector3;
  64065. /** the normal of the vertex (defaut: 0,1,0) */
  64066. normal: Vector3;
  64067. /** the uv of the vertex (default: 0,0) */
  64068. uv: Vector2;
  64069. /**
  64070. * Creates a PositionNormalTextureVertex
  64071. * @param position the position of the vertex (defaut: 0,0,0)
  64072. * @param normal the normal of the vertex (defaut: 0,1,0)
  64073. * @param uv the uv of the vertex (default: 0,0)
  64074. */
  64075. constructor(
  64076. /** the position of the vertex (defaut: 0,0,0) */
  64077. position?: Vector3,
  64078. /** the normal of the vertex (defaut: 0,1,0) */
  64079. normal?: Vector3,
  64080. /** the uv of the vertex (default: 0,0) */
  64081. uv?: Vector2);
  64082. /**
  64083. * Clones the PositionNormalTextureVertex
  64084. * @returns the cloned PositionNormalTextureVertex
  64085. */
  64086. clone(): PositionNormalTextureVertex;
  64087. }
  64088. /**
  64089. * @hidden
  64090. */
  64091. export class Tmp {
  64092. static Color3: Color3[];
  64093. static Color4: Color4[];
  64094. static Vector2: Vector2[];
  64095. static Vector3: Vector3[];
  64096. static Vector4: Vector4[];
  64097. static Quaternion: Quaternion[];
  64098. static Matrix: Matrix[];
  64099. }
  64100. }
  64101. declare module BABYLON {
  64102. /**
  64103. * Class used to enable access to offline support
  64104. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64105. */
  64106. export interface IOfflineProvider {
  64107. /**
  64108. * Gets a boolean indicating if scene must be saved in the database
  64109. */
  64110. enableSceneOffline: boolean;
  64111. /**
  64112. * Gets a boolean indicating if textures must be saved in the database
  64113. */
  64114. enableTexturesOffline: boolean;
  64115. /**
  64116. * Open the offline support and make it available
  64117. * @param successCallback defines the callback to call on success
  64118. * @param errorCallback defines the callback to call on error
  64119. */
  64120. open(successCallback: () => void, errorCallback: () => void): void;
  64121. /**
  64122. * Loads an image from the offline support
  64123. * @param url defines the url to load from
  64124. * @param image defines the target DOM image
  64125. */
  64126. loadImage(url: string, image: HTMLImageElement): void;
  64127. /**
  64128. * Loads a file from offline support
  64129. * @param url defines the URL to load from
  64130. * @param sceneLoaded defines a callback to call on success
  64131. * @param progressCallBack defines a callback to call when progress changed
  64132. * @param errorCallback defines a callback to call on error
  64133. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64134. */
  64135. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64136. }
  64137. }
  64138. declare module BABYLON {
  64139. /**
  64140. * A class serves as a medium between the observable and its observers
  64141. */
  64142. export class EventState {
  64143. /**
  64144. * Create a new EventState
  64145. * @param mask defines the mask associated with this state
  64146. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64147. * @param target defines the original target of the state
  64148. * @param currentTarget defines the current target of the state
  64149. */
  64150. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64151. /**
  64152. * Initialize the current event state
  64153. * @param mask defines the mask associated with this state
  64154. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64155. * @param target defines the original target of the state
  64156. * @param currentTarget defines the current target of the state
  64157. * @returns the current event state
  64158. */
  64159. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64160. /**
  64161. * An Observer can set this property to true to prevent subsequent observers of being notified
  64162. */
  64163. skipNextObservers: boolean;
  64164. /**
  64165. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64166. */
  64167. mask: number;
  64168. /**
  64169. * The object that originally notified the event
  64170. */
  64171. target?: any;
  64172. /**
  64173. * The current object in the bubbling phase
  64174. */
  64175. currentTarget?: any;
  64176. /**
  64177. * This will be populated with the return value of the last function that was executed.
  64178. * If it is the first function in the callback chain it will be the event data.
  64179. */
  64180. lastReturnValue?: any;
  64181. }
  64182. /**
  64183. * Represent an Observer registered to a given Observable object.
  64184. */
  64185. export class Observer<T> {
  64186. /**
  64187. * Defines the callback to call when the observer is notified
  64188. */
  64189. callback: (eventData: T, eventState: EventState) => void;
  64190. /**
  64191. * Defines the mask of the observer (used to filter notifications)
  64192. */
  64193. mask: number;
  64194. /**
  64195. * Defines the current scope used to restore the JS context
  64196. */
  64197. scope: any;
  64198. /** @hidden */
  64199. _willBeUnregistered: boolean;
  64200. /**
  64201. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64202. */
  64203. unregisterOnNextCall: boolean;
  64204. /**
  64205. * Creates a new observer
  64206. * @param callback defines the callback to call when the observer is notified
  64207. * @param mask defines the mask of the observer (used to filter notifications)
  64208. * @param scope defines the current scope used to restore the JS context
  64209. */
  64210. constructor(
  64211. /**
  64212. * Defines the callback to call when the observer is notified
  64213. */
  64214. callback: (eventData: T, eventState: EventState) => void,
  64215. /**
  64216. * Defines the mask of the observer (used to filter notifications)
  64217. */
  64218. mask: number,
  64219. /**
  64220. * Defines the current scope used to restore the JS context
  64221. */
  64222. scope?: any);
  64223. }
  64224. /**
  64225. * Represent a list of observers registered to multiple Observables object.
  64226. */
  64227. export class MultiObserver<T> {
  64228. private _observers;
  64229. private _observables;
  64230. /**
  64231. * Release associated resources
  64232. */
  64233. dispose(): void;
  64234. /**
  64235. * Raise a callback when one of the observable will notify
  64236. * @param observables defines a list of observables to watch
  64237. * @param callback defines the callback to call on notification
  64238. * @param mask defines the mask used to filter notifications
  64239. * @param scope defines the current scope used to restore the JS context
  64240. * @returns the new MultiObserver
  64241. */
  64242. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64243. }
  64244. /**
  64245. * The Observable class is a simple implementation of the Observable pattern.
  64246. *
  64247. * 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.
  64248. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64249. * 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).
  64250. * 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.
  64251. */
  64252. export class Observable<T> {
  64253. private _observers;
  64254. private _eventState;
  64255. private _onObserverAdded;
  64256. /**
  64257. * Creates a new observable
  64258. * @param onObserverAdded defines a callback to call when a new observer is added
  64259. */
  64260. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64261. /**
  64262. * Create a new Observer with the specified callback
  64263. * @param callback the callback that will be executed for that Observer
  64264. * @param mask the mask used to filter observers
  64265. * @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.
  64266. * @param scope optional scope for the callback to be called from
  64267. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64268. * @returns the new observer created for the callback
  64269. */
  64270. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64271. /**
  64272. * Create a new Observer with the specified callback and unregisters after the next notification
  64273. * @param callback the callback that will be executed for that Observer
  64274. * @returns the new observer created for the callback
  64275. */
  64276. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64277. /**
  64278. * Remove an Observer from the Observable object
  64279. * @param observer the instance of the Observer to remove
  64280. * @returns false if it doesn't belong to this Observable
  64281. */
  64282. remove(observer: Nullable<Observer<T>>): boolean;
  64283. /**
  64284. * Remove a callback from the Observable object
  64285. * @param callback the callback to remove
  64286. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64287. * @returns false if it doesn't belong to this Observable
  64288. */
  64289. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64290. private _deferUnregister;
  64291. private _remove;
  64292. /**
  64293. * Moves the observable to the top of the observer list making it get called first when notified
  64294. * @param observer the observer to move
  64295. */
  64296. makeObserverTopPriority(observer: Observer<T>): void;
  64297. /**
  64298. * Moves the observable to the bottom of the observer list making it get called last when notified
  64299. * @param observer the observer to move
  64300. */
  64301. makeObserverBottomPriority(observer: Observer<T>): void;
  64302. /**
  64303. * Notify all Observers by calling their respective callback with the given data
  64304. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64305. * @param eventData defines the data to send to all observers
  64306. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64307. * @param target defines the original target of the state
  64308. * @param currentTarget defines the current target of the state
  64309. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64310. */
  64311. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64312. /**
  64313. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64314. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64315. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64316. * and it is crucial that all callbacks will be executed.
  64317. * The order of the callbacks is kept, callbacks are not executed parallel.
  64318. *
  64319. * @param eventData The data to be sent to each callback
  64320. * @param mask is used to filter observers defaults to -1
  64321. * @param target defines the callback target (see EventState)
  64322. * @param currentTarget defines he current object in the bubbling phase
  64323. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64324. */
  64325. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64326. /**
  64327. * Notify a specific observer
  64328. * @param observer defines the observer to notify
  64329. * @param eventData defines the data to be sent to each callback
  64330. * @param mask is used to filter observers defaults to -1
  64331. */
  64332. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64333. /**
  64334. * Gets a boolean indicating if the observable has at least one observer
  64335. * @returns true is the Observable has at least one Observer registered
  64336. */
  64337. hasObservers(): boolean;
  64338. /**
  64339. * Clear the list of observers
  64340. */
  64341. clear(): void;
  64342. /**
  64343. * Clone the current observable
  64344. * @returns a new observable
  64345. */
  64346. clone(): Observable<T>;
  64347. /**
  64348. * Does this observable handles observer registered with a given mask
  64349. * @param mask defines the mask to be tested
  64350. * @return whether or not one observer registered with the given mask is handeled
  64351. **/
  64352. hasSpecificMask(mask?: number): boolean;
  64353. }
  64354. }
  64355. declare module BABYLON {
  64356. /**
  64357. * Class used to help managing file picking and drag'n'drop
  64358. * File Storage
  64359. */
  64360. export class FilesInputStore {
  64361. /**
  64362. * List of files ready to be loaded
  64363. */
  64364. static FilesToLoad: {
  64365. [key: string]: File;
  64366. };
  64367. }
  64368. }
  64369. declare module BABYLON {
  64370. /** Defines the cross module used constants to avoid circular dependncies */
  64371. export class Constants {
  64372. /** Defines that alpha blending is disabled */
  64373. static readonly ALPHA_DISABLE: number;
  64374. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64375. static readonly ALPHA_ADD: number;
  64376. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64377. static readonly ALPHA_COMBINE: number;
  64378. /** Defines that alpha blending to DEST - SRC * DEST */
  64379. static readonly ALPHA_SUBTRACT: number;
  64380. /** Defines that alpha blending to SRC * DEST */
  64381. static readonly ALPHA_MULTIPLY: number;
  64382. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64383. static readonly ALPHA_MAXIMIZED: number;
  64384. /** Defines that alpha blending to SRC + DEST */
  64385. static readonly ALPHA_ONEONE: number;
  64386. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64387. static readonly ALPHA_PREMULTIPLIED: number;
  64388. /**
  64389. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64390. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64391. */
  64392. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64393. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64394. static readonly ALPHA_INTERPOLATE: number;
  64395. /**
  64396. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64397. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64398. */
  64399. static readonly ALPHA_SCREENMODE: number;
  64400. /** Defines that the ressource is not delayed*/
  64401. static readonly DELAYLOADSTATE_NONE: number;
  64402. /** Defines that the ressource was successfully delay loaded */
  64403. static readonly DELAYLOADSTATE_LOADED: number;
  64404. /** Defines that the ressource is currently delay loading */
  64405. static readonly DELAYLOADSTATE_LOADING: number;
  64406. /** Defines that the ressource is delayed and has not started loading */
  64407. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64408. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64409. static readonly NEVER: number;
  64410. /** 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 */
  64411. static readonly ALWAYS: number;
  64412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64413. static readonly LESS: number;
  64414. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64415. static readonly EQUAL: number;
  64416. /** 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 */
  64417. static readonly LEQUAL: number;
  64418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64419. static readonly GREATER: number;
  64420. /** 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 */
  64421. static readonly GEQUAL: number;
  64422. /** 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 */
  64423. static readonly NOTEQUAL: number;
  64424. /** Passed to stencilOperation to specify that stencil value must be kept */
  64425. static readonly KEEP: number;
  64426. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64427. static readonly REPLACE: number;
  64428. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64429. static readonly INCR: number;
  64430. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64431. static readonly DECR: number;
  64432. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64433. static readonly INVERT: number;
  64434. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64435. static readonly INCR_WRAP: number;
  64436. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64437. static readonly DECR_WRAP: number;
  64438. /** Texture is not repeating outside of 0..1 UVs */
  64439. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64440. /** Texture is repeating outside of 0..1 UVs */
  64441. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64442. /** Texture is repeating and mirrored */
  64443. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64444. /** ALPHA */
  64445. static readonly TEXTUREFORMAT_ALPHA: number;
  64446. /** LUMINANCE */
  64447. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64448. /** LUMINANCE_ALPHA */
  64449. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64450. /** RGB */
  64451. static readonly TEXTUREFORMAT_RGB: number;
  64452. /** RGBA */
  64453. static readonly TEXTUREFORMAT_RGBA: number;
  64454. /** RED */
  64455. static readonly TEXTUREFORMAT_RED: number;
  64456. /** RED (2nd reference) */
  64457. static readonly TEXTUREFORMAT_R: number;
  64458. /** RG */
  64459. static readonly TEXTUREFORMAT_RG: number;
  64460. /** RED_INTEGER */
  64461. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64462. /** RED_INTEGER (2nd reference) */
  64463. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64464. /** RG_INTEGER */
  64465. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64466. /** RGB_INTEGER */
  64467. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64468. /** RGBA_INTEGER */
  64469. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64470. /** UNSIGNED_BYTE */
  64471. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64472. /** UNSIGNED_BYTE (2nd reference) */
  64473. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64474. /** FLOAT */
  64475. static readonly TEXTURETYPE_FLOAT: number;
  64476. /** HALF_FLOAT */
  64477. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64478. /** BYTE */
  64479. static readonly TEXTURETYPE_BYTE: number;
  64480. /** SHORT */
  64481. static readonly TEXTURETYPE_SHORT: number;
  64482. /** UNSIGNED_SHORT */
  64483. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64484. /** INT */
  64485. static readonly TEXTURETYPE_INT: number;
  64486. /** UNSIGNED_INT */
  64487. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64488. /** UNSIGNED_SHORT_4_4_4_4 */
  64489. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64490. /** UNSIGNED_SHORT_5_5_5_1 */
  64491. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64492. /** UNSIGNED_SHORT_5_6_5 */
  64493. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64494. /** UNSIGNED_INT_2_10_10_10_REV */
  64495. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64496. /** UNSIGNED_INT_24_8 */
  64497. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64498. /** UNSIGNED_INT_10F_11F_11F_REV */
  64499. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64500. /** UNSIGNED_INT_5_9_9_9_REV */
  64501. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64502. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64503. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64504. /** nearest is mag = nearest and min = nearest and mip = linear */
  64505. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64506. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64507. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64508. /** Trilinear is mag = linear and min = linear and mip = linear */
  64509. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64510. /** nearest is mag = nearest and min = nearest and mip = linear */
  64511. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64512. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64513. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64514. /** Trilinear is mag = linear and min = linear and mip = linear */
  64515. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64516. /** mag = nearest and min = nearest and mip = nearest */
  64517. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64518. /** mag = nearest and min = linear and mip = nearest */
  64519. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64520. /** mag = nearest and min = linear and mip = linear */
  64521. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64522. /** mag = nearest and min = linear and mip = none */
  64523. static readonly TEXTURE_NEAREST_LINEAR: number;
  64524. /** mag = nearest and min = nearest and mip = none */
  64525. static readonly TEXTURE_NEAREST_NEAREST: number;
  64526. /** mag = linear and min = nearest and mip = nearest */
  64527. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64528. /** mag = linear and min = nearest and mip = linear */
  64529. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64530. /** mag = linear and min = linear and mip = none */
  64531. static readonly TEXTURE_LINEAR_LINEAR: number;
  64532. /** mag = linear and min = nearest and mip = none */
  64533. static readonly TEXTURE_LINEAR_NEAREST: number;
  64534. /** Explicit coordinates mode */
  64535. static readonly TEXTURE_EXPLICIT_MODE: number;
  64536. /** Spherical coordinates mode */
  64537. static readonly TEXTURE_SPHERICAL_MODE: number;
  64538. /** Planar coordinates mode */
  64539. static readonly TEXTURE_PLANAR_MODE: number;
  64540. /** Cubic coordinates mode */
  64541. static readonly TEXTURE_CUBIC_MODE: number;
  64542. /** Projection coordinates mode */
  64543. static readonly TEXTURE_PROJECTION_MODE: number;
  64544. /** Skybox coordinates mode */
  64545. static readonly TEXTURE_SKYBOX_MODE: number;
  64546. /** Inverse Cubic coordinates mode */
  64547. static readonly TEXTURE_INVCUBIC_MODE: number;
  64548. /** Equirectangular coordinates mode */
  64549. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64550. /** Equirectangular Fixed coordinates mode */
  64551. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64552. /** Equirectangular Fixed Mirrored coordinates mode */
  64553. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64554. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64555. static readonly SCALEMODE_FLOOR: number;
  64556. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64557. static readonly SCALEMODE_NEAREST: number;
  64558. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64559. static readonly SCALEMODE_CEILING: number;
  64560. /**
  64561. * The dirty texture flag value
  64562. */
  64563. static readonly MATERIAL_TextureDirtyFlag: number;
  64564. /**
  64565. * The dirty light flag value
  64566. */
  64567. static readonly MATERIAL_LightDirtyFlag: number;
  64568. /**
  64569. * The dirty fresnel flag value
  64570. */
  64571. static readonly MATERIAL_FresnelDirtyFlag: number;
  64572. /**
  64573. * The dirty attribute flag value
  64574. */
  64575. static readonly MATERIAL_AttributesDirtyFlag: number;
  64576. /**
  64577. * The dirty misc flag value
  64578. */
  64579. static readonly MATERIAL_MiscDirtyFlag: number;
  64580. /**
  64581. * The all dirty flag value
  64582. */
  64583. static readonly MATERIAL_AllDirtyFlag: number;
  64584. /**
  64585. * Returns the triangle fill mode
  64586. */
  64587. static readonly MATERIAL_TriangleFillMode: number;
  64588. /**
  64589. * Returns the wireframe mode
  64590. */
  64591. static readonly MATERIAL_WireFrameFillMode: number;
  64592. /**
  64593. * Returns the point fill mode
  64594. */
  64595. static readonly MATERIAL_PointFillMode: number;
  64596. /**
  64597. * Returns the point list draw mode
  64598. */
  64599. static readonly MATERIAL_PointListDrawMode: number;
  64600. /**
  64601. * Returns the line list draw mode
  64602. */
  64603. static readonly MATERIAL_LineListDrawMode: number;
  64604. /**
  64605. * Returns the line loop draw mode
  64606. */
  64607. static readonly MATERIAL_LineLoopDrawMode: number;
  64608. /**
  64609. * Returns the line strip draw mode
  64610. */
  64611. static readonly MATERIAL_LineStripDrawMode: number;
  64612. /**
  64613. * Returns the triangle strip draw mode
  64614. */
  64615. static readonly MATERIAL_TriangleStripDrawMode: number;
  64616. /**
  64617. * Returns the triangle fan draw mode
  64618. */
  64619. static readonly MATERIAL_TriangleFanDrawMode: number;
  64620. /**
  64621. * Stores the clock-wise side orientation
  64622. */
  64623. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64624. /**
  64625. * Stores the counter clock-wise side orientation
  64626. */
  64627. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64628. /**
  64629. * Nothing
  64630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64631. */
  64632. static readonly ACTION_NothingTrigger: number;
  64633. /**
  64634. * On pick
  64635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64636. */
  64637. static readonly ACTION_OnPickTrigger: number;
  64638. /**
  64639. * On left pick
  64640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64641. */
  64642. static readonly ACTION_OnLeftPickTrigger: number;
  64643. /**
  64644. * On right pick
  64645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64646. */
  64647. static readonly ACTION_OnRightPickTrigger: number;
  64648. /**
  64649. * On center pick
  64650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64651. */
  64652. static readonly ACTION_OnCenterPickTrigger: number;
  64653. /**
  64654. * On pick down
  64655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64656. */
  64657. static readonly ACTION_OnPickDownTrigger: number;
  64658. /**
  64659. * On double pick
  64660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64661. */
  64662. static readonly ACTION_OnDoublePickTrigger: number;
  64663. /**
  64664. * On pick up
  64665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64666. */
  64667. static readonly ACTION_OnPickUpTrigger: number;
  64668. /**
  64669. * On pick out.
  64670. * This trigger will only be raised if you also declared a OnPickDown
  64671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64672. */
  64673. static readonly ACTION_OnPickOutTrigger: number;
  64674. /**
  64675. * On long press
  64676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64677. */
  64678. static readonly ACTION_OnLongPressTrigger: number;
  64679. /**
  64680. * On pointer over
  64681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64682. */
  64683. static readonly ACTION_OnPointerOverTrigger: number;
  64684. /**
  64685. * On pointer out
  64686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64687. */
  64688. static readonly ACTION_OnPointerOutTrigger: number;
  64689. /**
  64690. * On every frame
  64691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64692. */
  64693. static readonly ACTION_OnEveryFrameTrigger: number;
  64694. /**
  64695. * On intersection enter
  64696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64697. */
  64698. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64699. /**
  64700. * On intersection exit
  64701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64702. */
  64703. static readonly ACTION_OnIntersectionExitTrigger: number;
  64704. /**
  64705. * On key down
  64706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64707. */
  64708. static readonly ACTION_OnKeyDownTrigger: number;
  64709. /**
  64710. * On key up
  64711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64712. */
  64713. static readonly ACTION_OnKeyUpTrigger: number;
  64714. /**
  64715. * Billboard mode will only apply to Y axis
  64716. */
  64717. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64718. /**
  64719. * Billboard mode will apply to all axes
  64720. */
  64721. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64722. /**
  64723. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64724. */
  64725. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64726. /**
  64727. * Gets or sets base Assets URL
  64728. */
  64729. static readonly PARTICLES_BaseAssetsUrl: string;
  64730. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64731. * Test order :
  64732. * Is the bounding sphere outside the frustum ?
  64733. * If not, are the bounding box vertices outside the frustum ?
  64734. * It not, then the cullable object is in the frustum.
  64735. */
  64736. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64737. /** Culling strategy : Bounding Sphere Only.
  64738. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64739. * It's also less accurate than the standard because some not visible objects can still be selected.
  64740. * Test : is the bounding sphere outside the frustum ?
  64741. * If not, then the cullable object is in the frustum.
  64742. */
  64743. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64744. /** Culling strategy : Optimistic Inclusion.
  64745. * This in an inclusion test first, then the standard exclusion test.
  64746. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64747. * 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.
  64748. * Anyway, it's as accurate as the standard strategy.
  64749. * Test :
  64750. * Is the cullable object bounding sphere center in the frustum ?
  64751. * If not, apply the default culling strategy.
  64752. */
  64753. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64754. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64755. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64756. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64757. * 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.
  64758. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64759. * Test :
  64760. * Is the cullable object bounding sphere center in the frustum ?
  64761. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64762. */
  64763. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64764. /**
  64765. * No logging while loading
  64766. */
  64767. static readonly SCENELOADER_NO_LOGGING: number;
  64768. /**
  64769. * Minimal logging while loading
  64770. */
  64771. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64772. /**
  64773. * Summary logging while loading
  64774. */
  64775. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64776. /**
  64777. * Detailled logging while loading
  64778. */
  64779. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64780. }
  64781. }
  64782. declare module BABYLON {
  64783. /**
  64784. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64785. * Babylon.js
  64786. */
  64787. export class DomManagement {
  64788. /**
  64789. * Checks if the window object exists
  64790. * @returns true if the window object exists
  64791. */
  64792. static IsWindowObjectExist(): boolean;
  64793. /**
  64794. * Extracts text content from a DOM element hierarchy
  64795. * @param element defines the root element
  64796. * @returns a string
  64797. */
  64798. static GetDOMTextContent(element: HTMLElement): string;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Logger used througouht the application to allow configuration of
  64804. * the log level required for the messages.
  64805. */
  64806. export class Logger {
  64807. /**
  64808. * No log
  64809. */
  64810. static readonly NoneLogLevel: number;
  64811. /**
  64812. * Only message logs
  64813. */
  64814. static readonly MessageLogLevel: number;
  64815. /**
  64816. * Only warning logs
  64817. */
  64818. static readonly WarningLogLevel: number;
  64819. /**
  64820. * Only error logs
  64821. */
  64822. static readonly ErrorLogLevel: number;
  64823. /**
  64824. * All logs
  64825. */
  64826. static readonly AllLogLevel: number;
  64827. private static _LogCache;
  64828. /**
  64829. * Gets a value indicating the number of loading errors
  64830. * @ignorenaming
  64831. */
  64832. static errorsCount: number;
  64833. /**
  64834. * Callback called when a new log is added
  64835. */
  64836. static OnNewCacheEntry: (entry: string) => void;
  64837. private static _AddLogEntry;
  64838. private static _FormatMessage;
  64839. private static _LogDisabled;
  64840. private static _LogEnabled;
  64841. private static _WarnDisabled;
  64842. private static _WarnEnabled;
  64843. private static _ErrorDisabled;
  64844. private static _ErrorEnabled;
  64845. /**
  64846. * Log a message to the console
  64847. */
  64848. static Log: (message: string) => void;
  64849. /**
  64850. * Write a warning message to the console
  64851. */
  64852. static Warn: (message: string) => void;
  64853. /**
  64854. * Write an error message to the console
  64855. */
  64856. static Error: (message: string) => void;
  64857. /**
  64858. * Gets current log cache (list of logs)
  64859. */
  64860. static readonly LogCache: string;
  64861. /**
  64862. * Clears the log cache
  64863. */
  64864. static ClearLogCache(): void;
  64865. /**
  64866. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64867. */
  64868. static LogLevels: number;
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /** @hidden */
  64873. export class _TypeStore {
  64874. /** @hidden */
  64875. static RegisteredTypes: {
  64876. [key: string]: Object;
  64877. };
  64878. /** @hidden */
  64879. static GetClass(fqdn: string): any;
  64880. }
  64881. }
  64882. declare module BABYLON {
  64883. /**
  64884. * Class containing a set of static utilities functions for deep copy.
  64885. */
  64886. export class DeepCopier {
  64887. /**
  64888. * Tries to copy an object by duplicating every property
  64889. * @param source defines the source object
  64890. * @param destination defines the target object
  64891. * @param doNotCopyList defines a list of properties to avoid
  64892. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64893. */
  64894. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64895. }
  64896. }
  64897. declare module BABYLON {
  64898. /**
  64899. * Class containing a set of static utilities functions for precision date
  64900. */
  64901. export class PrecisionDate {
  64902. /**
  64903. * Gets either window.performance.now() if supported or Date.now() else
  64904. */
  64905. static readonly Now: number;
  64906. }
  64907. }
  64908. declare module BABYLON {
  64909. /** @hidden */
  64910. export class _DevTools {
  64911. static WarnImport(name: string): string;
  64912. }
  64913. }
  64914. declare module BABYLON {
  64915. /**
  64916. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64917. */
  64918. export class WebRequest {
  64919. private _xhr;
  64920. /**
  64921. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64922. * i.e. when loading files, where the server/service expects an Authorization header
  64923. */
  64924. static CustomRequestHeaders: {
  64925. [key: string]: string;
  64926. };
  64927. /**
  64928. * Add callback functions in this array to update all the requests before they get sent to the network
  64929. */
  64930. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64931. private _injectCustomRequestHeaders;
  64932. /**
  64933. * Gets or sets a function to be called when loading progress changes
  64934. */
  64935. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64936. /**
  64937. * Returns client's state
  64938. */
  64939. readonly readyState: number;
  64940. /**
  64941. * Returns client's status
  64942. */
  64943. readonly status: number;
  64944. /**
  64945. * Returns client's status as a text
  64946. */
  64947. readonly statusText: string;
  64948. /**
  64949. * Returns client's response
  64950. */
  64951. readonly response: any;
  64952. /**
  64953. * Returns client's response url
  64954. */
  64955. readonly responseURL: string;
  64956. /**
  64957. * Returns client's response as text
  64958. */
  64959. readonly responseText: string;
  64960. /**
  64961. * Gets or sets the expected response type
  64962. */
  64963. responseType: XMLHttpRequestResponseType;
  64964. /** @hidden */
  64965. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64966. /** @hidden */
  64967. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64968. /**
  64969. * Cancels any network activity
  64970. */
  64971. abort(): void;
  64972. /**
  64973. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64974. * @param body defines an optional request body
  64975. */
  64976. send(body?: Document | BodyInit | null): void;
  64977. /**
  64978. * Sets the request method, request URL
  64979. * @param method defines the method to use (GET, POST, etc..)
  64980. * @param url defines the url to connect with
  64981. */
  64982. open(method: string, url: string): void;
  64983. }
  64984. }
  64985. declare module BABYLON {
  64986. /**
  64987. * Class used to evalaute queries containing `and` and `or` operators
  64988. */
  64989. export class AndOrNotEvaluator {
  64990. /**
  64991. * Evaluate a query
  64992. * @param query defines the query to evaluate
  64993. * @param evaluateCallback defines the callback used to filter result
  64994. * @returns true if the query matches
  64995. */
  64996. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64997. private static _HandleParenthesisContent;
  64998. private static _SimplifyNegation;
  64999. }
  65000. }
  65001. declare module BABYLON {
  65002. /**
  65003. * Class used to store custom tags
  65004. */
  65005. export class Tags {
  65006. /**
  65007. * Adds support for tags on the given object
  65008. * @param obj defines the object to use
  65009. */
  65010. static EnableFor(obj: any): void;
  65011. /**
  65012. * Removes tags support
  65013. * @param obj defines the object to use
  65014. */
  65015. static DisableFor(obj: any): void;
  65016. /**
  65017. * Gets a boolean indicating if the given object has tags
  65018. * @param obj defines the object to use
  65019. * @returns a boolean
  65020. */
  65021. static HasTags(obj: any): boolean;
  65022. /**
  65023. * Gets the tags available on a given object
  65024. * @param obj defines the object to use
  65025. * @param asString defines if the tags must be returned as a string instead of an array of strings
  65026. * @returns the tags
  65027. */
  65028. static GetTags(obj: any, asString?: boolean): any;
  65029. /**
  65030. * Adds tags to an object
  65031. * @param obj defines the object to use
  65032. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  65033. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  65034. */
  65035. static AddTagsTo(obj: any, tagsString: string): void;
  65036. /**
  65037. * @hidden
  65038. */
  65039. static _AddTagTo(obj: any, tag: string): void;
  65040. /**
  65041. * Removes specific tags from a specific object
  65042. * @param obj defines the object to use
  65043. * @param tagsString defines the tags to remove
  65044. */
  65045. static RemoveTagsFrom(obj: any, tagsString: string): void;
  65046. /**
  65047. * @hidden
  65048. */
  65049. static _RemoveTagFrom(obj: any, tag: string): void;
  65050. /**
  65051. * Defines if tags hosted on an object match a given query
  65052. * @param obj defines the object to use
  65053. * @param tagsQuery defines the tag query
  65054. * @returns a boolean
  65055. */
  65056. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  65057. }
  65058. }
  65059. declare module BABYLON {
  65060. /**
  65061. * Manages the defines for the Material
  65062. */
  65063. export class MaterialDefines {
  65064. private _keys;
  65065. private _isDirty;
  65066. /** @hidden */
  65067. _renderId: number;
  65068. /** @hidden */
  65069. _areLightsDirty: boolean;
  65070. /** @hidden */
  65071. _areAttributesDirty: boolean;
  65072. /** @hidden */
  65073. _areTexturesDirty: boolean;
  65074. /** @hidden */
  65075. _areFresnelDirty: boolean;
  65076. /** @hidden */
  65077. _areMiscDirty: boolean;
  65078. /** @hidden */
  65079. _areImageProcessingDirty: boolean;
  65080. /** @hidden */
  65081. _normals: boolean;
  65082. /** @hidden */
  65083. _uvs: boolean;
  65084. /** @hidden */
  65085. _needNormals: boolean;
  65086. /** @hidden */
  65087. _needUVs: boolean;
  65088. /**
  65089. * Specifies if the material needs to be re-calculated
  65090. */
  65091. readonly isDirty: boolean;
  65092. /**
  65093. * Marks the material to indicate that it has been re-calculated
  65094. */
  65095. markAsProcessed(): void;
  65096. /**
  65097. * Marks the material to indicate that it needs to be re-calculated
  65098. */
  65099. markAsUnprocessed(): void;
  65100. /**
  65101. * Marks the material to indicate all of its defines need to be re-calculated
  65102. */
  65103. markAllAsDirty(): void;
  65104. /**
  65105. * Marks the material to indicate that image processing needs to be re-calculated
  65106. */
  65107. markAsImageProcessingDirty(): void;
  65108. /**
  65109. * Marks the material to indicate the lights need to be re-calculated
  65110. */
  65111. markAsLightDirty(): void;
  65112. /**
  65113. * Marks the attribute state as changed
  65114. */
  65115. markAsAttributesDirty(): void;
  65116. /**
  65117. * Marks the texture state as changed
  65118. */
  65119. markAsTexturesDirty(): void;
  65120. /**
  65121. * Marks the fresnel state as changed
  65122. */
  65123. markAsFresnelDirty(): void;
  65124. /**
  65125. * Marks the misc state as changed
  65126. */
  65127. markAsMiscDirty(): void;
  65128. /**
  65129. * Rebuilds the material defines
  65130. */
  65131. rebuild(): void;
  65132. /**
  65133. * Specifies if two material defines are equal
  65134. * @param other - A material define instance to compare to
  65135. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  65136. */
  65137. isEqual(other: MaterialDefines): boolean;
  65138. /**
  65139. * Clones this instance's defines to another instance
  65140. * @param other - material defines to clone values to
  65141. */
  65142. cloneTo(other: MaterialDefines): void;
  65143. /**
  65144. * Resets the material define values
  65145. */
  65146. reset(): void;
  65147. /**
  65148. * Converts the material define values to a string
  65149. * @returns - String of material define information
  65150. */
  65151. toString(): string;
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /**
  65156. * Class used to store and describe the pipeline context associated with an effect
  65157. */
  65158. export interface IPipelineContext {
  65159. /**
  65160. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  65161. */
  65162. isAsync: boolean;
  65163. /**
  65164. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  65165. */
  65166. isReady: boolean;
  65167. /** @hidden */
  65168. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  65169. }
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * Class used to store gfx data (like WebGLBuffer)
  65174. */
  65175. export class DataBuffer {
  65176. /**
  65177. * Gets or sets the number of objects referencing this buffer
  65178. */
  65179. references: number;
  65180. /** Gets or sets the size of the underlying buffer */
  65181. capacity: number;
  65182. /**
  65183. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  65184. */
  65185. is32Bits: boolean;
  65186. /**
  65187. * Gets the underlying buffer
  65188. */
  65189. readonly underlyingResource: any;
  65190. }
  65191. }
  65192. declare module BABYLON {
  65193. /**
  65194. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  65195. */
  65196. export class PerformanceMonitor {
  65197. private _enabled;
  65198. private _rollingFrameTime;
  65199. private _lastFrameTimeMs;
  65200. /**
  65201. * constructor
  65202. * @param frameSampleSize The number of samples required to saturate the sliding window
  65203. */
  65204. constructor(frameSampleSize?: number);
  65205. /**
  65206. * Samples current frame
  65207. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  65208. */
  65209. sampleFrame(timeMs?: number): void;
  65210. /**
  65211. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65212. */
  65213. readonly averageFrameTime: number;
  65214. /**
  65215. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  65216. */
  65217. readonly averageFrameTimeVariance: number;
  65218. /**
  65219. * Returns the frame time of the most recent frame
  65220. */
  65221. readonly instantaneousFrameTime: number;
  65222. /**
  65223. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  65224. */
  65225. readonly averageFPS: number;
  65226. /**
  65227. * Returns the average framerate in frames per second using the most recent frame time
  65228. */
  65229. readonly instantaneousFPS: number;
  65230. /**
  65231. * Returns true if enough samples have been taken to completely fill the sliding window
  65232. */
  65233. readonly isSaturated: boolean;
  65234. /**
  65235. * Enables contributions to the sliding window sample set
  65236. */
  65237. enable(): void;
  65238. /**
  65239. * Disables contributions to the sliding window sample set
  65240. * Samples will not be interpolated over the disabled period
  65241. */
  65242. disable(): void;
  65243. /**
  65244. * Returns true if sampling is enabled
  65245. */
  65246. readonly isEnabled: boolean;
  65247. /**
  65248. * Resets performance monitor
  65249. */
  65250. reset(): void;
  65251. }
  65252. /**
  65253. * RollingAverage
  65254. *
  65255. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  65256. */
  65257. export class RollingAverage {
  65258. /**
  65259. * Current average
  65260. */
  65261. average: number;
  65262. /**
  65263. * Current variance
  65264. */
  65265. variance: number;
  65266. protected _samples: Array<number>;
  65267. protected _sampleCount: number;
  65268. protected _pos: number;
  65269. protected _m2: number;
  65270. /**
  65271. * constructor
  65272. * @param length The number of samples required to saturate the sliding window
  65273. */
  65274. constructor(length: number);
  65275. /**
  65276. * Adds a sample to the sample set
  65277. * @param v The sample value
  65278. */
  65279. add(v: number): void;
  65280. /**
  65281. * Returns previously added values or null if outside of history or outside the sliding window domain
  65282. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  65283. * @return Value previously recorded with add() or null if outside of range
  65284. */
  65285. history(i: number): number;
  65286. /**
  65287. * Returns true if enough samples have been taken to completely fill the sliding window
  65288. * @return true if sample-set saturated
  65289. */
  65290. isSaturated(): boolean;
  65291. /**
  65292. * Resets the rolling average (equivalent to 0 samples taken so far)
  65293. */
  65294. reset(): void;
  65295. /**
  65296. * Wraps a value around the sample range boundaries
  65297. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  65298. * @return Wrapped position in sample range
  65299. */
  65300. protected _wrapPosition(i: number): number;
  65301. }
  65302. }
  65303. declare module BABYLON {
  65304. /**
  65305. * This class implement a typical dictionary using a string as key and the generic type T as value.
  65306. * The underlying implementation relies on an associative array to ensure the best performances.
  65307. * The value can be anything including 'null' but except 'undefined'
  65308. */
  65309. export class StringDictionary<T> {
  65310. /**
  65311. * This will clear this dictionary and copy the content from the 'source' one.
  65312. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  65313. * @param source the dictionary to take the content from and copy to this dictionary
  65314. */
  65315. copyFrom(source: StringDictionary<T>): void;
  65316. /**
  65317. * Get a value based from its key
  65318. * @param key the given key to get the matching value from
  65319. * @return the value if found, otherwise undefined is returned
  65320. */
  65321. get(key: string): T | undefined;
  65322. /**
  65323. * Get a value from its key or add it if it doesn't exist.
  65324. * This method will ensure you that a given key/data will be present in the dictionary.
  65325. * @param key the given key to get the matching value from
  65326. * @param factory the factory that will create the value if the key is not present in the dictionary.
  65327. * The factory will only be invoked if there's no data for the given key.
  65328. * @return the value corresponding to the key.
  65329. */
  65330. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  65331. /**
  65332. * Get a value from its key if present in the dictionary otherwise add it
  65333. * @param key the key to get the value from
  65334. * @param val if there's no such key/value pair in the dictionary add it with this value
  65335. * @return the value corresponding to the key
  65336. */
  65337. getOrAdd(key: string, val: T): T;
  65338. /**
  65339. * Check if there's a given key in the dictionary
  65340. * @param key the key to check for
  65341. * @return true if the key is present, false otherwise
  65342. */
  65343. contains(key: string): boolean;
  65344. /**
  65345. * Add a new key and its corresponding value
  65346. * @param key the key to add
  65347. * @param value the value corresponding to the key
  65348. * @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
  65349. */
  65350. add(key: string, value: T): boolean;
  65351. /**
  65352. * Update a specific value associated to a key
  65353. * @param key defines the key to use
  65354. * @param value defines the value to store
  65355. * @returns true if the value was updated (or false if the key was not found)
  65356. */
  65357. set(key: string, value: T): boolean;
  65358. /**
  65359. * Get the element of the given key and remove it from the dictionary
  65360. * @param key defines the key to search
  65361. * @returns the value associated with the key or null if not found
  65362. */
  65363. getAndRemove(key: string): Nullable<T>;
  65364. /**
  65365. * Remove a key/value from the dictionary.
  65366. * @param key the key to remove
  65367. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  65368. */
  65369. remove(key: string): boolean;
  65370. /**
  65371. * Clear the whole content of the dictionary
  65372. */
  65373. clear(): void;
  65374. /**
  65375. * Gets the current count
  65376. */
  65377. readonly count: number;
  65378. /**
  65379. * Execute a callback on each key/val of the dictionary.
  65380. * Note that you can remove any element in this dictionary in the callback implementation
  65381. * @param callback the callback to execute on a given key/value pair
  65382. */
  65383. forEach(callback: (key: string, val: T) => void): void;
  65384. /**
  65385. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  65386. * If the callback returns null or undefined the method will iterate to the next key/value pair
  65387. * Note that you can remove any element in this dictionary in the callback implementation
  65388. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  65389. * @returns the first item
  65390. */
  65391. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  65392. private _count;
  65393. private _data;
  65394. }
  65395. }
  65396. declare module BABYLON {
  65397. /**
  65398. * Helper class that provides a small promise polyfill
  65399. */
  65400. export class PromisePolyfill {
  65401. /**
  65402. * Static function used to check if the polyfill is required
  65403. * If this is the case then the function will inject the polyfill to window.Promise
  65404. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65405. */
  65406. static Apply(force?: boolean): void;
  65407. }
  65408. }
  65409. declare module BABYLON {
  65410. /**
  65411. * Class used to store data that will be store in GPU memory
  65412. */
  65413. export class Buffer {
  65414. private _engine;
  65415. private _buffer;
  65416. /** @hidden */
  65417. _data: Nullable<DataArray>;
  65418. private _updatable;
  65419. private _instanced;
  65420. /**
  65421. * Gets the byte stride.
  65422. */
  65423. readonly byteStride: number;
  65424. /**
  65425. * Constructor
  65426. * @param engine the engine
  65427. * @param data the data to use for this buffer
  65428. * @param updatable whether the data is updatable
  65429. * @param stride the stride (optional)
  65430. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65431. * @param instanced whether the buffer is instanced (optional)
  65432. * @param useBytes set to true if the stride in in bytes (optional)
  65433. */
  65434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65435. /**
  65436. * Create a new VertexBuffer based on the current buffer
  65437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65438. * @param offset defines offset in the buffer (0 by default)
  65439. * @param size defines the size in floats of attributes (position is 3 for instance)
  65440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65441. * @param instanced defines if the vertex buffer contains indexed data
  65442. * @param useBytes defines if the offset and stride are in bytes
  65443. * @returns the new vertex buffer
  65444. */
  65445. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65446. /**
  65447. * Gets a boolean indicating if the Buffer is updatable?
  65448. * @returns true if the buffer is updatable
  65449. */
  65450. isUpdatable(): boolean;
  65451. /**
  65452. * Gets current buffer's data
  65453. * @returns a DataArray or null
  65454. */
  65455. getData(): Nullable<DataArray>;
  65456. /**
  65457. * Gets underlying native buffer
  65458. * @returns underlying native buffer
  65459. */
  65460. getBuffer(): Nullable<DataBuffer>;
  65461. /**
  65462. * Gets the stride in float32 units (i.e. byte stride / 4).
  65463. * May not be an integer if the byte stride is not divisible by 4.
  65464. * DEPRECATED. Use byteStride instead.
  65465. * @returns the stride in float32 units
  65466. */
  65467. getStrideSize(): number;
  65468. /**
  65469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65470. * @param data defines the data to store
  65471. */
  65472. create(data?: Nullable<DataArray>): void;
  65473. /** @hidden */
  65474. _rebuild(): void;
  65475. /**
  65476. * Update current buffer data
  65477. * @param data defines the data to store
  65478. */
  65479. update(data: DataArray): void;
  65480. /**
  65481. * Updates the data directly.
  65482. * @param data the new data
  65483. * @param offset the new offset
  65484. * @param vertexCount the vertex count (optional)
  65485. * @param useBytes set to true if the offset is in bytes
  65486. */
  65487. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65488. /**
  65489. * Release all resources
  65490. */
  65491. dispose(): void;
  65492. }
  65493. /**
  65494. * Specialized buffer used to store vertex data
  65495. */
  65496. export class VertexBuffer {
  65497. /** @hidden */
  65498. _buffer: Buffer;
  65499. private _kind;
  65500. private _size;
  65501. private _ownsBuffer;
  65502. private _instanced;
  65503. private _instanceDivisor;
  65504. /**
  65505. * The byte type.
  65506. */
  65507. static readonly BYTE: number;
  65508. /**
  65509. * The unsigned byte type.
  65510. */
  65511. static readonly UNSIGNED_BYTE: number;
  65512. /**
  65513. * The short type.
  65514. */
  65515. static readonly SHORT: number;
  65516. /**
  65517. * The unsigned short type.
  65518. */
  65519. static readonly UNSIGNED_SHORT: number;
  65520. /**
  65521. * The integer type.
  65522. */
  65523. static readonly INT: number;
  65524. /**
  65525. * The unsigned integer type.
  65526. */
  65527. static readonly UNSIGNED_INT: number;
  65528. /**
  65529. * The float type.
  65530. */
  65531. static readonly FLOAT: number;
  65532. /**
  65533. * Gets or sets the instance divisor when in instanced mode
  65534. */
  65535. instanceDivisor: number;
  65536. /**
  65537. * Gets the byte stride.
  65538. */
  65539. readonly byteStride: number;
  65540. /**
  65541. * Gets the byte offset.
  65542. */
  65543. readonly byteOffset: number;
  65544. /**
  65545. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65546. */
  65547. readonly normalized: boolean;
  65548. /**
  65549. * Gets the data type of each component in the array.
  65550. */
  65551. readonly type: number;
  65552. /**
  65553. * Constructor
  65554. * @param engine the engine
  65555. * @param data the data to use for this vertex buffer
  65556. * @param kind the vertex buffer kind
  65557. * @param updatable whether the data is updatable
  65558. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65559. * @param stride the stride (optional)
  65560. * @param instanced whether the buffer is instanced (optional)
  65561. * @param offset the offset of the data (optional)
  65562. * @param size the number of components (optional)
  65563. * @param type the type of the component (optional)
  65564. * @param normalized whether the data contains normalized data (optional)
  65565. * @param useBytes set to true if stride and offset are in bytes (optional)
  65566. */
  65567. 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);
  65568. /** @hidden */
  65569. _rebuild(): void;
  65570. /**
  65571. * Returns the kind of the VertexBuffer (string)
  65572. * @returns a string
  65573. */
  65574. getKind(): string;
  65575. /**
  65576. * Gets a boolean indicating if the VertexBuffer is updatable?
  65577. * @returns true if the buffer is updatable
  65578. */
  65579. isUpdatable(): boolean;
  65580. /**
  65581. * Gets current buffer's data
  65582. * @returns a DataArray or null
  65583. */
  65584. getData(): Nullable<DataArray>;
  65585. /**
  65586. * Gets underlying native buffer
  65587. * @returns underlying native buffer
  65588. */
  65589. getBuffer(): Nullable<DataBuffer>;
  65590. /**
  65591. * Gets the stride in float32 units (i.e. byte stride / 4).
  65592. * May not be an integer if the byte stride is not divisible by 4.
  65593. * DEPRECATED. Use byteStride instead.
  65594. * @returns the stride in float32 units
  65595. */
  65596. getStrideSize(): number;
  65597. /**
  65598. * Returns the offset as a multiple of the type byte length.
  65599. * DEPRECATED. Use byteOffset instead.
  65600. * @returns the offset in bytes
  65601. */
  65602. getOffset(): number;
  65603. /**
  65604. * Returns the number of components per vertex attribute (integer)
  65605. * @returns the size in float
  65606. */
  65607. getSize(): number;
  65608. /**
  65609. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65610. * @returns true if this buffer is instanced
  65611. */
  65612. getIsInstanced(): boolean;
  65613. /**
  65614. * Returns the instancing divisor, zero for non-instanced (integer).
  65615. * @returns a number
  65616. */
  65617. getInstanceDivisor(): number;
  65618. /**
  65619. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65620. * @param data defines the data to store
  65621. */
  65622. create(data?: DataArray): void;
  65623. /**
  65624. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65625. * This function will create a new buffer if the current one is not updatable
  65626. * @param data defines the data to store
  65627. */
  65628. update(data: DataArray): void;
  65629. /**
  65630. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65631. * Returns the directly updated WebGLBuffer.
  65632. * @param data the new data
  65633. * @param offset the new offset
  65634. * @param useBytes set to true if the offset is in bytes
  65635. */
  65636. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65637. /**
  65638. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65639. */
  65640. dispose(): void;
  65641. /**
  65642. * Enumerates each value of this vertex buffer as numbers.
  65643. * @param count the number of values to enumerate
  65644. * @param callback the callback function called for each value
  65645. */
  65646. forEach(count: number, callback: (value: number, index: number) => void): void;
  65647. /**
  65648. * Positions
  65649. */
  65650. static readonly PositionKind: string;
  65651. /**
  65652. * Normals
  65653. */
  65654. static readonly NormalKind: string;
  65655. /**
  65656. * Tangents
  65657. */
  65658. static readonly TangentKind: string;
  65659. /**
  65660. * Texture coordinates
  65661. */
  65662. static readonly UVKind: string;
  65663. /**
  65664. * Texture coordinates 2
  65665. */
  65666. static readonly UV2Kind: string;
  65667. /**
  65668. * Texture coordinates 3
  65669. */
  65670. static readonly UV3Kind: string;
  65671. /**
  65672. * Texture coordinates 4
  65673. */
  65674. static readonly UV4Kind: string;
  65675. /**
  65676. * Texture coordinates 5
  65677. */
  65678. static readonly UV5Kind: string;
  65679. /**
  65680. * Texture coordinates 6
  65681. */
  65682. static readonly UV6Kind: string;
  65683. /**
  65684. * Colors
  65685. */
  65686. static readonly ColorKind: string;
  65687. /**
  65688. * Matrix indices (for bones)
  65689. */
  65690. static readonly MatricesIndicesKind: string;
  65691. /**
  65692. * Matrix weights (for bones)
  65693. */
  65694. static readonly MatricesWeightsKind: string;
  65695. /**
  65696. * Additional matrix indices (for bones)
  65697. */
  65698. static readonly MatricesIndicesExtraKind: string;
  65699. /**
  65700. * Additional matrix weights (for bones)
  65701. */
  65702. static readonly MatricesWeightsExtraKind: string;
  65703. /**
  65704. * Deduces the stride given a kind.
  65705. * @param kind The kind string to deduce
  65706. * @returns The deduced stride
  65707. */
  65708. static DeduceStride(kind: string): number;
  65709. /**
  65710. * Gets the byte length of the given type.
  65711. * @param type the type
  65712. * @returns the number of bytes
  65713. */
  65714. static GetTypeByteLength(type: number): number;
  65715. /**
  65716. * Enumerates each value of the given parameters as numbers.
  65717. * @param data the data to enumerate
  65718. * @param byteOffset the byte offset of the data
  65719. * @param byteStride the byte stride of the data
  65720. * @param componentCount the number of components per element
  65721. * @param componentType the type of the component
  65722. * @param count the total number of components
  65723. * @param normalized whether the data is normalized
  65724. * @param callback the callback function called for each value
  65725. */
  65726. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65727. private static _GetFloatValue;
  65728. }
  65729. }
  65730. declare module BABYLON {
  65731. /**
  65732. * Class representing spherical harmonics coefficients to the 3rd degree
  65733. */
  65734. export class SphericalHarmonics {
  65735. /**
  65736. * Defines whether or not the harmonics have been prescaled for rendering.
  65737. */
  65738. preScaled: boolean;
  65739. /**
  65740. * The l0,0 coefficients of the spherical harmonics
  65741. */
  65742. l00: Vector3;
  65743. /**
  65744. * The l1,-1 coefficients of the spherical harmonics
  65745. */
  65746. l1_1: Vector3;
  65747. /**
  65748. * The l1,0 coefficients of the spherical harmonics
  65749. */
  65750. l10: Vector3;
  65751. /**
  65752. * The l1,1 coefficients of the spherical harmonics
  65753. */
  65754. l11: Vector3;
  65755. /**
  65756. * The l2,-2 coefficients of the spherical harmonics
  65757. */
  65758. l2_2: Vector3;
  65759. /**
  65760. * The l2,-1 coefficients of the spherical harmonics
  65761. */
  65762. l2_1: Vector3;
  65763. /**
  65764. * The l2,0 coefficients of the spherical harmonics
  65765. */
  65766. l20: Vector3;
  65767. /**
  65768. * The l2,1 coefficients of the spherical harmonics
  65769. */
  65770. l21: Vector3;
  65771. /**
  65772. * The l2,2 coefficients of the spherical harmonics
  65773. */
  65774. l22: Vector3;
  65775. /**
  65776. * Adds a light to the spherical harmonics
  65777. * @param direction the direction of the light
  65778. * @param color the color of the light
  65779. * @param deltaSolidAngle the delta solid angle of the light
  65780. */
  65781. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65782. /**
  65783. * Scales the spherical harmonics by the given amount
  65784. * @param scale the amount to scale
  65785. */
  65786. scaleInPlace(scale: number): void;
  65787. /**
  65788. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65789. *
  65790. * ```
  65791. * E_lm = A_l * L_lm
  65792. * ```
  65793. *
  65794. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65795. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65796. * the scaling factors are given in equation 9.
  65797. */
  65798. convertIncidentRadianceToIrradiance(): void;
  65799. /**
  65800. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65801. *
  65802. * ```
  65803. * L = (1/pi) * E * rho
  65804. * ```
  65805. *
  65806. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65807. */
  65808. convertIrradianceToLambertianRadiance(): void;
  65809. /**
  65810. * Integrates the reconstruction coefficients directly in to the SH preventing further
  65811. * required operations at run time.
  65812. *
  65813. * This is simply done by scaling back the SH with Ylm constants parameter.
  65814. * The trigonometric part being applied by the shader at run time.
  65815. */
  65816. preScaleForRendering(): void;
  65817. /**
  65818. * Constructs a spherical harmonics from an array.
  65819. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65820. * @returns the spherical harmonics
  65821. */
  65822. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65823. /**
  65824. * Gets the spherical harmonics from polynomial
  65825. * @param polynomial the spherical polynomial
  65826. * @returns the spherical harmonics
  65827. */
  65828. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65829. }
  65830. /**
  65831. * Class representing spherical polynomial coefficients to the 3rd degree
  65832. */
  65833. export class SphericalPolynomial {
  65834. private _harmonics;
  65835. /**
  65836. * The spherical harmonics used to create the polynomials.
  65837. */
  65838. readonly preScaledHarmonics: SphericalHarmonics;
  65839. /**
  65840. * The x coefficients of the spherical polynomial
  65841. */
  65842. x: Vector3;
  65843. /**
  65844. * The y coefficients of the spherical polynomial
  65845. */
  65846. y: Vector3;
  65847. /**
  65848. * The z coefficients of the spherical polynomial
  65849. */
  65850. z: Vector3;
  65851. /**
  65852. * The xx coefficients of the spherical polynomial
  65853. */
  65854. xx: Vector3;
  65855. /**
  65856. * The yy coefficients of the spherical polynomial
  65857. */
  65858. yy: Vector3;
  65859. /**
  65860. * The zz coefficients of the spherical polynomial
  65861. */
  65862. zz: Vector3;
  65863. /**
  65864. * The xy coefficients of the spherical polynomial
  65865. */
  65866. xy: Vector3;
  65867. /**
  65868. * The yz coefficients of the spherical polynomial
  65869. */
  65870. yz: Vector3;
  65871. /**
  65872. * The zx coefficients of the spherical polynomial
  65873. */
  65874. zx: Vector3;
  65875. /**
  65876. * Adds an ambient color to the spherical polynomial
  65877. * @param color the color to add
  65878. */
  65879. addAmbient(color: Color3): void;
  65880. /**
  65881. * Scales the spherical polynomial by the given amount
  65882. * @param scale the amount to scale
  65883. */
  65884. scaleInPlace(scale: number): void;
  65885. /**
  65886. * Gets the spherical polynomial from harmonics
  65887. * @param harmonics the spherical harmonics
  65888. * @returns the spherical polynomial
  65889. */
  65890. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65891. /**
  65892. * Constructs a spherical polynomial from an array.
  65893. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65894. * @returns the spherical polynomial
  65895. */
  65896. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65897. }
  65898. }
  65899. declare module BABYLON {
  65900. /**
  65901. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65902. */
  65903. export interface CubeMapInfo {
  65904. /**
  65905. * The pixel array for the front face.
  65906. * This is stored in format, left to right, up to down format.
  65907. */
  65908. front: Nullable<ArrayBufferView>;
  65909. /**
  65910. * The pixel array for the back face.
  65911. * This is stored in format, left to right, up to down format.
  65912. */
  65913. back: Nullable<ArrayBufferView>;
  65914. /**
  65915. * The pixel array for the left face.
  65916. * This is stored in format, left to right, up to down format.
  65917. */
  65918. left: Nullable<ArrayBufferView>;
  65919. /**
  65920. * The pixel array for the right face.
  65921. * This is stored in format, left to right, up to down format.
  65922. */
  65923. right: Nullable<ArrayBufferView>;
  65924. /**
  65925. * The pixel array for the up face.
  65926. * This is stored in format, left to right, up to down format.
  65927. */
  65928. up: Nullable<ArrayBufferView>;
  65929. /**
  65930. * The pixel array for the down face.
  65931. * This is stored in format, left to right, up to down format.
  65932. */
  65933. down: Nullable<ArrayBufferView>;
  65934. /**
  65935. * The size of the cubemap stored.
  65936. *
  65937. * Each faces will be size * size pixels.
  65938. */
  65939. size: number;
  65940. /**
  65941. * The format of the texture.
  65942. *
  65943. * RGBA, RGB.
  65944. */
  65945. format: number;
  65946. /**
  65947. * The type of the texture data.
  65948. *
  65949. * UNSIGNED_INT, FLOAT.
  65950. */
  65951. type: number;
  65952. /**
  65953. * Specifies whether the texture is in gamma space.
  65954. */
  65955. gammaSpace: boolean;
  65956. }
  65957. /**
  65958. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65959. */
  65960. export class PanoramaToCubeMapTools {
  65961. private static FACE_FRONT;
  65962. private static FACE_BACK;
  65963. private static FACE_RIGHT;
  65964. private static FACE_LEFT;
  65965. private static FACE_DOWN;
  65966. private static FACE_UP;
  65967. /**
  65968. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65969. *
  65970. * @param float32Array The source data.
  65971. * @param inputWidth The width of the input panorama.
  65972. * @param inputHeight The height of the input panorama.
  65973. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65974. * @return The cubemap data
  65975. */
  65976. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65977. private static CreateCubemapTexture;
  65978. private static CalcProjectionSpherical;
  65979. }
  65980. }
  65981. declare module BABYLON {
  65982. /**
  65983. * Helper class dealing with the extraction of spherical polynomial dataArray
  65984. * from a cube map.
  65985. */
  65986. export class CubeMapToSphericalPolynomialTools {
  65987. private static FileFaces;
  65988. /**
  65989. * Converts a texture to the according Spherical Polynomial data.
  65990. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65991. *
  65992. * @param texture The texture to extract the information from.
  65993. * @return The Spherical Polynomial data.
  65994. */
  65995. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65996. /**
  65997. * Converts a cubemap to the according Spherical Polynomial data.
  65998. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65999. *
  66000. * @param cubeInfo The Cube map to extract the information from.
  66001. * @return The Spherical Polynomial data.
  66002. */
  66003. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  66004. }
  66005. }
  66006. declare module BABYLON {
  66007. /**
  66008. * The engine store class is responsible to hold all the instances of Engine and Scene created
  66009. * during the life time of the application.
  66010. */
  66011. export class EngineStore {
  66012. /** Gets the list of created engines */
  66013. static Instances: Engine[];
  66014. /**
  66015. * Gets the latest created engine
  66016. */
  66017. static readonly LastCreatedEngine: Nullable<Engine>;
  66018. /**
  66019. * Gets the latest created scene
  66020. */
  66021. static readonly LastCreatedScene: Nullable<Scene>;
  66022. }
  66023. }
  66024. declare module BABYLON {
  66025. /**
  66026. * Define options used to create a render target texture
  66027. */
  66028. export class RenderTargetCreationOptions {
  66029. /**
  66030. * Specifies is mipmaps must be generated
  66031. */
  66032. generateMipMaps?: boolean;
  66033. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  66034. generateDepthBuffer?: boolean;
  66035. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  66036. generateStencilBuffer?: boolean;
  66037. /** Defines texture type (int by default) */
  66038. type?: number;
  66039. /** Defines sampling mode (trilinear by default) */
  66040. samplingMode?: number;
  66041. /** Defines format (RGBA by default) */
  66042. format?: number;
  66043. }
  66044. }
  66045. declare module BABYLON {
  66046. /**
  66047. * @hidden
  66048. **/
  66049. export class _AlphaState {
  66050. private _isAlphaBlendDirty;
  66051. private _isBlendFunctionParametersDirty;
  66052. private _isBlendEquationParametersDirty;
  66053. private _isBlendConstantsDirty;
  66054. private _alphaBlend;
  66055. private _blendFunctionParameters;
  66056. private _blendEquationParameters;
  66057. private _blendConstants;
  66058. /**
  66059. * Initializes the state.
  66060. */
  66061. constructor();
  66062. readonly isDirty: boolean;
  66063. alphaBlend: boolean;
  66064. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  66065. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  66066. setAlphaEquationParameters(rgb: number, alpha: number): void;
  66067. reset(): void;
  66068. apply(gl: WebGLRenderingContext): void;
  66069. }
  66070. }
  66071. declare module BABYLON {
  66072. /**
  66073. * @hidden
  66074. **/
  66075. export class _DepthCullingState {
  66076. private _isDepthTestDirty;
  66077. private _isDepthMaskDirty;
  66078. private _isDepthFuncDirty;
  66079. private _isCullFaceDirty;
  66080. private _isCullDirty;
  66081. private _isZOffsetDirty;
  66082. private _isFrontFaceDirty;
  66083. private _depthTest;
  66084. private _depthMask;
  66085. private _depthFunc;
  66086. private _cull;
  66087. private _cullFace;
  66088. private _zOffset;
  66089. private _frontFace;
  66090. /**
  66091. * Initializes the state.
  66092. */
  66093. constructor();
  66094. readonly isDirty: boolean;
  66095. zOffset: number;
  66096. cullFace: Nullable<number>;
  66097. cull: Nullable<boolean>;
  66098. depthFunc: Nullable<number>;
  66099. depthMask: boolean;
  66100. depthTest: boolean;
  66101. frontFace: Nullable<number>;
  66102. reset(): void;
  66103. apply(gl: WebGLRenderingContext): void;
  66104. }
  66105. }
  66106. declare module BABYLON {
  66107. /**
  66108. * @hidden
  66109. **/
  66110. export class _StencilState {
  66111. /** 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 */
  66112. static readonly ALWAYS: number;
  66113. /** Passed to stencilOperation to specify that stencil value must be kept */
  66114. static readonly KEEP: number;
  66115. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66116. static readonly REPLACE: number;
  66117. private _isStencilTestDirty;
  66118. private _isStencilMaskDirty;
  66119. private _isStencilFuncDirty;
  66120. private _isStencilOpDirty;
  66121. private _stencilTest;
  66122. private _stencilMask;
  66123. private _stencilFunc;
  66124. private _stencilFuncRef;
  66125. private _stencilFuncMask;
  66126. private _stencilOpStencilFail;
  66127. private _stencilOpDepthFail;
  66128. private _stencilOpStencilDepthPass;
  66129. readonly isDirty: boolean;
  66130. stencilFunc: number;
  66131. stencilFuncRef: number;
  66132. stencilFuncMask: number;
  66133. stencilOpStencilFail: number;
  66134. stencilOpDepthFail: number;
  66135. stencilOpStencilDepthPass: number;
  66136. stencilMask: number;
  66137. stencilTest: boolean;
  66138. constructor();
  66139. reset(): void;
  66140. apply(gl: WebGLRenderingContext): void;
  66141. }
  66142. }
  66143. declare module BABYLON {
  66144. /**
  66145. * @hidden
  66146. **/
  66147. export class _TimeToken {
  66148. _startTimeQuery: Nullable<WebGLQuery>;
  66149. _endTimeQuery: Nullable<WebGLQuery>;
  66150. _timeElapsedQuery: Nullable<WebGLQuery>;
  66151. _timeElapsedQueryEnded: boolean;
  66152. }
  66153. }
  66154. declare module BABYLON {
  66155. /**
  66156. * Class used to store data associated with WebGL texture data for the engine
  66157. * This class should not be used directly
  66158. */
  66159. export class InternalTexture {
  66160. /** hidden */
  66161. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  66162. /**
  66163. * The source of the texture data is unknown
  66164. */
  66165. static DATASOURCE_UNKNOWN: number;
  66166. /**
  66167. * Texture data comes from an URL
  66168. */
  66169. static DATASOURCE_URL: number;
  66170. /**
  66171. * Texture data is only used for temporary storage
  66172. */
  66173. static DATASOURCE_TEMP: number;
  66174. /**
  66175. * Texture data comes from raw data (ArrayBuffer)
  66176. */
  66177. static DATASOURCE_RAW: number;
  66178. /**
  66179. * Texture content is dynamic (video or dynamic texture)
  66180. */
  66181. static DATASOURCE_DYNAMIC: number;
  66182. /**
  66183. * Texture content is generated by rendering to it
  66184. */
  66185. static DATASOURCE_RENDERTARGET: number;
  66186. /**
  66187. * Texture content is part of a multi render target process
  66188. */
  66189. static DATASOURCE_MULTIRENDERTARGET: number;
  66190. /**
  66191. * Texture data comes from a cube data file
  66192. */
  66193. static DATASOURCE_CUBE: number;
  66194. /**
  66195. * Texture data comes from a raw cube data
  66196. */
  66197. static DATASOURCE_CUBERAW: number;
  66198. /**
  66199. * Texture data come from a prefiltered cube data file
  66200. */
  66201. static DATASOURCE_CUBEPREFILTERED: number;
  66202. /**
  66203. * Texture content is raw 3D data
  66204. */
  66205. static DATASOURCE_RAW3D: number;
  66206. /**
  66207. * Texture content is a depth texture
  66208. */
  66209. static DATASOURCE_DEPTHTEXTURE: number;
  66210. /**
  66211. * Texture data comes from a raw cube data encoded with RGBD
  66212. */
  66213. static DATASOURCE_CUBERAW_RGBD: number;
  66214. /**
  66215. * Defines if the texture is ready
  66216. */
  66217. isReady: boolean;
  66218. /**
  66219. * Defines if the texture is a cube texture
  66220. */
  66221. isCube: boolean;
  66222. /**
  66223. * Defines if the texture contains 3D data
  66224. */
  66225. is3D: boolean;
  66226. /**
  66227. * Defines if the texture contains multiview data
  66228. */
  66229. isMultiview: boolean;
  66230. /**
  66231. * Gets the URL used to load this texture
  66232. */
  66233. url: string;
  66234. /**
  66235. * Gets the sampling mode of the texture
  66236. */
  66237. samplingMode: number;
  66238. /**
  66239. * Gets a boolean indicating if the texture needs mipmaps generation
  66240. */
  66241. generateMipMaps: boolean;
  66242. /**
  66243. * Gets the number of samples used by the texture (WebGL2+ only)
  66244. */
  66245. samples: number;
  66246. /**
  66247. * Gets the type of the texture (int, float...)
  66248. */
  66249. type: number;
  66250. /**
  66251. * Gets the format of the texture (RGB, RGBA...)
  66252. */
  66253. format: number;
  66254. /**
  66255. * Observable called when the texture is loaded
  66256. */
  66257. onLoadedObservable: Observable<InternalTexture>;
  66258. /**
  66259. * Gets the width of the texture
  66260. */
  66261. width: number;
  66262. /**
  66263. * Gets the height of the texture
  66264. */
  66265. height: number;
  66266. /**
  66267. * Gets the depth of the texture
  66268. */
  66269. depth: number;
  66270. /**
  66271. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  66272. */
  66273. baseWidth: number;
  66274. /**
  66275. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  66276. */
  66277. baseHeight: number;
  66278. /**
  66279. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  66280. */
  66281. baseDepth: number;
  66282. /**
  66283. * Gets a boolean indicating if the texture is inverted on Y axis
  66284. */
  66285. invertY: boolean;
  66286. /** @hidden */
  66287. _invertVScale: boolean;
  66288. /** @hidden */
  66289. _associatedChannel: number;
  66290. /** @hidden */
  66291. _dataSource: number;
  66292. /** @hidden */
  66293. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  66294. /** @hidden */
  66295. _bufferView: Nullable<ArrayBufferView>;
  66296. /** @hidden */
  66297. _bufferViewArray: Nullable<ArrayBufferView[]>;
  66298. /** @hidden */
  66299. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  66300. /** @hidden */
  66301. _size: number;
  66302. /** @hidden */
  66303. _extension: string;
  66304. /** @hidden */
  66305. _files: Nullable<string[]>;
  66306. /** @hidden */
  66307. _workingCanvas: Nullable<HTMLCanvasElement>;
  66308. /** @hidden */
  66309. _workingContext: Nullable<CanvasRenderingContext2D>;
  66310. /** @hidden */
  66311. _framebuffer: Nullable<WebGLFramebuffer>;
  66312. /** @hidden */
  66313. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  66314. /** @hidden */
  66315. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  66316. /** @hidden */
  66317. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  66318. /** @hidden */
  66319. _attachments: Nullable<number[]>;
  66320. /** @hidden */
  66321. _cachedCoordinatesMode: Nullable<number>;
  66322. /** @hidden */
  66323. _cachedWrapU: Nullable<number>;
  66324. /** @hidden */
  66325. _cachedWrapV: Nullable<number>;
  66326. /** @hidden */
  66327. _cachedWrapR: Nullable<number>;
  66328. /** @hidden */
  66329. _cachedAnisotropicFilteringLevel: Nullable<number>;
  66330. /** @hidden */
  66331. _isDisabled: boolean;
  66332. /** @hidden */
  66333. _compression: Nullable<string>;
  66334. /** @hidden */
  66335. _generateStencilBuffer: boolean;
  66336. /** @hidden */
  66337. _generateDepthBuffer: boolean;
  66338. /** @hidden */
  66339. _comparisonFunction: number;
  66340. /** @hidden */
  66341. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  66342. /** @hidden */
  66343. _lodGenerationScale: number;
  66344. /** @hidden */
  66345. _lodGenerationOffset: number;
  66346. /** @hidden */
  66347. _colorTextureArray: Nullable<WebGLTexture>;
  66348. /** @hidden */
  66349. _depthStencilTextureArray: Nullable<WebGLTexture>;
  66350. /** @hidden */
  66351. _lodTextureHigh: Nullable<BaseTexture>;
  66352. /** @hidden */
  66353. _lodTextureMid: Nullable<BaseTexture>;
  66354. /** @hidden */
  66355. _lodTextureLow: Nullable<BaseTexture>;
  66356. /** @hidden */
  66357. _isRGBD: boolean;
  66358. /** @hidden */
  66359. _webGLTexture: Nullable<WebGLTexture>;
  66360. /** @hidden */
  66361. _references: number;
  66362. private _engine;
  66363. /**
  66364. * Gets the Engine the texture belongs to.
  66365. * @returns The babylon engine
  66366. */
  66367. getEngine(): Engine;
  66368. /**
  66369. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  66370. */
  66371. readonly dataSource: number;
  66372. /**
  66373. * Creates a new InternalTexture
  66374. * @param engine defines the engine to use
  66375. * @param dataSource defines the type of data that will be used
  66376. * @param delayAllocation if the texture allocation should be delayed (default: false)
  66377. */
  66378. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  66379. /**
  66380. * Increments the number of references (ie. the number of Texture that point to it)
  66381. */
  66382. incrementReferences(): void;
  66383. /**
  66384. * Change the size of the texture (not the size of the content)
  66385. * @param width defines the new width
  66386. * @param height defines the new height
  66387. * @param depth defines the new depth (1 by default)
  66388. */
  66389. updateSize(width: int, height: int, depth?: int): void;
  66390. /** @hidden */
  66391. _rebuild(): void;
  66392. /** @hidden */
  66393. _swapAndDie(target: InternalTexture): void;
  66394. /**
  66395. * Dispose the current allocated resources
  66396. */
  66397. dispose(): void;
  66398. }
  66399. }
  66400. declare module BABYLON {
  66401. /**
  66402. * This represents the main contract an easing function should follow.
  66403. * Easing functions are used throughout the animation system.
  66404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66405. */
  66406. export interface IEasingFunction {
  66407. /**
  66408. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66409. * of the easing function.
  66410. * The link below provides some of the most common examples of easing functions.
  66411. * @see https://easings.net/
  66412. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66413. * @returns the corresponding value on the curve defined by the easing function
  66414. */
  66415. ease(gradient: number): number;
  66416. }
  66417. /**
  66418. * Base class used for every default easing function.
  66419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66420. */
  66421. export class EasingFunction implements IEasingFunction {
  66422. /**
  66423. * Interpolation follows the mathematical formula associated with the easing function.
  66424. */
  66425. static readonly EASINGMODE_EASEIN: number;
  66426. /**
  66427. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66428. */
  66429. static readonly EASINGMODE_EASEOUT: number;
  66430. /**
  66431. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66432. */
  66433. static readonly EASINGMODE_EASEINOUT: number;
  66434. private _easingMode;
  66435. /**
  66436. * Sets the easing mode of the current function.
  66437. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66438. */
  66439. setEasingMode(easingMode: number): void;
  66440. /**
  66441. * Gets the current easing mode.
  66442. * @returns the easing mode
  66443. */
  66444. getEasingMode(): number;
  66445. /**
  66446. * @hidden
  66447. */
  66448. easeInCore(gradient: number): number;
  66449. /**
  66450. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66451. * of the easing function.
  66452. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66453. * @returns the corresponding value on the curve defined by the easing function
  66454. */
  66455. ease(gradient: number): number;
  66456. }
  66457. /**
  66458. * Easing function with a circle shape (see link below).
  66459. * @see https://easings.net/#easeInCirc
  66460. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66461. */
  66462. export class CircleEase extends EasingFunction implements IEasingFunction {
  66463. /** @hidden */
  66464. easeInCore(gradient: number): number;
  66465. }
  66466. /**
  66467. * Easing function with a ease back shape (see link below).
  66468. * @see https://easings.net/#easeInBack
  66469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66470. */
  66471. export class BackEase extends EasingFunction implements IEasingFunction {
  66472. /** Defines the amplitude of the function */
  66473. amplitude: number;
  66474. /**
  66475. * Instantiates a back ease easing
  66476. * @see https://easings.net/#easeInBack
  66477. * @param amplitude Defines the amplitude of the function
  66478. */
  66479. constructor(
  66480. /** Defines the amplitude of the function */
  66481. amplitude?: number);
  66482. /** @hidden */
  66483. easeInCore(gradient: number): number;
  66484. }
  66485. /**
  66486. * Easing function with a bouncing shape (see link below).
  66487. * @see https://easings.net/#easeInBounce
  66488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66489. */
  66490. export class BounceEase extends EasingFunction implements IEasingFunction {
  66491. /** Defines the number of bounces */
  66492. bounces: number;
  66493. /** Defines the amplitude of the bounce */
  66494. bounciness: number;
  66495. /**
  66496. * Instantiates a bounce easing
  66497. * @see https://easings.net/#easeInBounce
  66498. * @param bounces Defines the number of bounces
  66499. * @param bounciness Defines the amplitude of the bounce
  66500. */
  66501. constructor(
  66502. /** Defines the number of bounces */
  66503. bounces?: number,
  66504. /** Defines the amplitude of the bounce */
  66505. bounciness?: number);
  66506. /** @hidden */
  66507. easeInCore(gradient: number): number;
  66508. }
  66509. /**
  66510. * Easing function with a power of 3 shape (see link below).
  66511. * @see https://easings.net/#easeInCubic
  66512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66513. */
  66514. export class CubicEase extends EasingFunction implements IEasingFunction {
  66515. /** @hidden */
  66516. easeInCore(gradient: number): number;
  66517. }
  66518. /**
  66519. * Easing function with an elastic shape (see link below).
  66520. * @see https://easings.net/#easeInElastic
  66521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66522. */
  66523. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66524. /** Defines the number of oscillations*/
  66525. oscillations: number;
  66526. /** Defines the amplitude of the oscillations*/
  66527. springiness: number;
  66528. /**
  66529. * Instantiates an elastic easing function
  66530. * @see https://easings.net/#easeInElastic
  66531. * @param oscillations Defines the number of oscillations
  66532. * @param springiness Defines the amplitude of the oscillations
  66533. */
  66534. constructor(
  66535. /** Defines the number of oscillations*/
  66536. oscillations?: number,
  66537. /** Defines the amplitude of the oscillations*/
  66538. springiness?: number);
  66539. /** @hidden */
  66540. easeInCore(gradient: number): number;
  66541. }
  66542. /**
  66543. * Easing function with an exponential shape (see link below).
  66544. * @see https://easings.net/#easeInExpo
  66545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66546. */
  66547. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66548. /** Defines the exponent of the function */
  66549. exponent: number;
  66550. /**
  66551. * Instantiates an exponential easing function
  66552. * @see https://easings.net/#easeInExpo
  66553. * @param exponent Defines the exponent of the function
  66554. */
  66555. constructor(
  66556. /** Defines the exponent of the function */
  66557. exponent?: number);
  66558. /** @hidden */
  66559. easeInCore(gradient: number): number;
  66560. }
  66561. /**
  66562. * Easing function with a power shape (see link below).
  66563. * @see https://easings.net/#easeInQuad
  66564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66565. */
  66566. export class PowerEase extends EasingFunction implements IEasingFunction {
  66567. /** Defines the power of the function */
  66568. power: number;
  66569. /**
  66570. * Instantiates an power base easing function
  66571. * @see https://easings.net/#easeInQuad
  66572. * @param power Defines the power of the function
  66573. */
  66574. constructor(
  66575. /** Defines the power of the function */
  66576. power?: number);
  66577. /** @hidden */
  66578. easeInCore(gradient: number): number;
  66579. }
  66580. /**
  66581. * Easing function with a power of 2 shape (see link below).
  66582. * @see https://easings.net/#easeInQuad
  66583. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66584. */
  66585. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66586. /** @hidden */
  66587. easeInCore(gradient: number): number;
  66588. }
  66589. /**
  66590. * Easing function with a power of 4 shape (see link below).
  66591. * @see https://easings.net/#easeInQuart
  66592. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66593. */
  66594. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66595. /** @hidden */
  66596. easeInCore(gradient: number): number;
  66597. }
  66598. /**
  66599. * Easing function with a power of 5 shape (see link below).
  66600. * @see https://easings.net/#easeInQuint
  66601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66602. */
  66603. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66604. /** @hidden */
  66605. easeInCore(gradient: number): number;
  66606. }
  66607. /**
  66608. * Easing function with a sin shape (see link below).
  66609. * @see https://easings.net/#easeInSine
  66610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66611. */
  66612. export class SineEase extends EasingFunction implements IEasingFunction {
  66613. /** @hidden */
  66614. easeInCore(gradient: number): number;
  66615. }
  66616. /**
  66617. * Easing function with a bezier shape (see link below).
  66618. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66620. */
  66621. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66622. /** Defines the x component of the start tangent in the bezier curve */
  66623. x1: number;
  66624. /** Defines the y component of the start tangent in the bezier curve */
  66625. y1: number;
  66626. /** Defines the x component of the end tangent in the bezier curve */
  66627. x2: number;
  66628. /** Defines the y component of the end tangent in the bezier curve */
  66629. y2: number;
  66630. /**
  66631. * Instantiates a bezier function
  66632. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66633. * @param x1 Defines the x component of the start tangent in the bezier curve
  66634. * @param y1 Defines the y component of the start tangent in the bezier curve
  66635. * @param x2 Defines the x component of the end tangent in the bezier curve
  66636. * @param y2 Defines the y component of the end tangent in the bezier curve
  66637. */
  66638. constructor(
  66639. /** Defines the x component of the start tangent in the bezier curve */
  66640. x1?: number,
  66641. /** Defines the y component of the start tangent in the bezier curve */
  66642. y1?: number,
  66643. /** Defines the x component of the end tangent in the bezier curve */
  66644. x2?: number,
  66645. /** Defines the y component of the end tangent in the bezier curve */
  66646. y2?: number);
  66647. /** @hidden */
  66648. easeInCore(gradient: number): number;
  66649. }
  66650. }
  66651. declare module BABYLON {
  66652. /**
  66653. * Defines an interface which represents an animation key frame
  66654. */
  66655. export interface IAnimationKey {
  66656. /**
  66657. * Frame of the key frame
  66658. */
  66659. frame: number;
  66660. /**
  66661. * Value at the specifies key frame
  66662. */
  66663. value: any;
  66664. /**
  66665. * The input tangent for the cubic hermite spline
  66666. */
  66667. inTangent?: any;
  66668. /**
  66669. * The output tangent for the cubic hermite spline
  66670. */
  66671. outTangent?: any;
  66672. /**
  66673. * The animation interpolation type
  66674. */
  66675. interpolation?: AnimationKeyInterpolation;
  66676. }
  66677. /**
  66678. * Enum for the animation key frame interpolation type
  66679. */
  66680. export enum AnimationKeyInterpolation {
  66681. /**
  66682. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66683. */
  66684. STEP = 1
  66685. }
  66686. }
  66687. declare module BABYLON {
  66688. /**
  66689. * Represents the range of an animation
  66690. */
  66691. export class AnimationRange {
  66692. /**The name of the animation range**/
  66693. name: string;
  66694. /**The starting frame of the animation */
  66695. from: number;
  66696. /**The ending frame of the animation*/
  66697. to: number;
  66698. /**
  66699. * Initializes the range of an animation
  66700. * @param name The name of the animation range
  66701. * @param from The starting frame of the animation
  66702. * @param to The ending frame of the animation
  66703. */
  66704. constructor(
  66705. /**The name of the animation range**/
  66706. name: string,
  66707. /**The starting frame of the animation */
  66708. from: number,
  66709. /**The ending frame of the animation*/
  66710. to: number);
  66711. /**
  66712. * Makes a copy of the animation range
  66713. * @returns A copy of the animation range
  66714. */
  66715. clone(): AnimationRange;
  66716. }
  66717. }
  66718. declare module BABYLON {
  66719. /**
  66720. * Composed of a frame, and an action function
  66721. */
  66722. export class AnimationEvent {
  66723. /** The frame for which the event is triggered **/
  66724. frame: number;
  66725. /** The event to perform when triggered **/
  66726. action: (currentFrame: number) => void;
  66727. /** Specifies if the event should be triggered only once**/
  66728. onlyOnce?: boolean | undefined;
  66729. /**
  66730. * Specifies if the animation event is done
  66731. */
  66732. isDone: boolean;
  66733. /**
  66734. * Initializes the animation event
  66735. * @param frame The frame for which the event is triggered
  66736. * @param action The event to perform when triggered
  66737. * @param onlyOnce Specifies if the event should be triggered only once
  66738. */
  66739. constructor(
  66740. /** The frame for which the event is triggered **/
  66741. frame: number,
  66742. /** The event to perform when triggered **/
  66743. action: (currentFrame: number) => void,
  66744. /** Specifies if the event should be triggered only once**/
  66745. onlyOnce?: boolean | undefined);
  66746. /** @hidden */
  66747. _clone(): AnimationEvent;
  66748. }
  66749. }
  66750. declare module BABYLON {
  66751. /**
  66752. * Interface used to define a behavior
  66753. */
  66754. export interface Behavior<T> {
  66755. /** gets or sets behavior's name */
  66756. name: string;
  66757. /**
  66758. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66759. */
  66760. init(): void;
  66761. /**
  66762. * Called when the behavior is attached to a target
  66763. * @param target defines the target where the behavior is attached to
  66764. */
  66765. attach(target: T): void;
  66766. /**
  66767. * Called when the behavior is detached from its target
  66768. */
  66769. detach(): void;
  66770. }
  66771. /**
  66772. * Interface implemented by classes supporting behaviors
  66773. */
  66774. export interface IBehaviorAware<T> {
  66775. /**
  66776. * Attach a behavior
  66777. * @param behavior defines the behavior to attach
  66778. * @returns the current host
  66779. */
  66780. addBehavior(behavior: Behavior<T>): T;
  66781. /**
  66782. * Remove a behavior from the current object
  66783. * @param behavior defines the behavior to detach
  66784. * @returns the current host
  66785. */
  66786. removeBehavior(behavior: Behavior<T>): T;
  66787. /**
  66788. * Gets a behavior using its name to search
  66789. * @param name defines the name to search
  66790. * @returns the behavior or null if not found
  66791. */
  66792. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66793. }
  66794. }
  66795. declare module BABYLON {
  66796. /**
  66797. * @hidden
  66798. */
  66799. export class IntersectionInfo {
  66800. bu: Nullable<number>;
  66801. bv: Nullable<number>;
  66802. distance: number;
  66803. faceId: number;
  66804. subMeshId: number;
  66805. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66806. }
  66807. }
  66808. declare module BABYLON {
  66809. /**
  66810. * Class used to store bounding sphere information
  66811. */
  66812. export class BoundingSphere {
  66813. /**
  66814. * Gets the center of the bounding sphere in local space
  66815. */
  66816. readonly center: Vector3;
  66817. /**
  66818. * Radius of the bounding sphere in local space
  66819. */
  66820. radius: number;
  66821. /**
  66822. * Gets the center of the bounding sphere in world space
  66823. */
  66824. readonly centerWorld: Vector3;
  66825. /**
  66826. * Radius of the bounding sphere in world space
  66827. */
  66828. radiusWorld: number;
  66829. /**
  66830. * Gets the minimum vector in local space
  66831. */
  66832. readonly minimum: Vector3;
  66833. /**
  66834. * Gets the maximum vector in local space
  66835. */
  66836. readonly maximum: Vector3;
  66837. private _worldMatrix;
  66838. private static readonly TmpVector3;
  66839. /**
  66840. * Creates a new bounding sphere
  66841. * @param min defines the minimum vector (in local space)
  66842. * @param max defines the maximum vector (in local space)
  66843. * @param worldMatrix defines the new world matrix
  66844. */
  66845. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66846. /**
  66847. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66848. * @param min defines the new minimum vector (in local space)
  66849. * @param max defines the new maximum vector (in local space)
  66850. * @param worldMatrix defines the new world matrix
  66851. */
  66852. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66853. /**
  66854. * Scale the current bounding sphere by applying a scale factor
  66855. * @param factor defines the scale factor to apply
  66856. * @returns the current bounding box
  66857. */
  66858. scale(factor: number): BoundingSphere;
  66859. /**
  66860. * Gets the world matrix of the bounding box
  66861. * @returns a matrix
  66862. */
  66863. getWorldMatrix(): DeepImmutable<Matrix>;
  66864. /** @hidden */
  66865. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66866. /**
  66867. * Tests if the bounding sphere is intersecting the frustum planes
  66868. * @param frustumPlanes defines the frustum planes to test
  66869. * @returns true if there is an intersection
  66870. */
  66871. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66872. /**
  66873. * Tests if the bounding sphere center is in between the frustum planes.
  66874. * Used for optimistic fast inclusion.
  66875. * @param frustumPlanes defines the frustum planes to test
  66876. * @returns true if the sphere center is in between the frustum planes
  66877. */
  66878. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66879. /**
  66880. * Tests if a point is inside the bounding sphere
  66881. * @param point defines the point to test
  66882. * @returns true if the point is inside the bounding sphere
  66883. */
  66884. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66885. /**
  66886. * Checks if two sphere intersct
  66887. * @param sphere0 sphere 0
  66888. * @param sphere1 sphere 1
  66889. * @returns true if the speres intersect
  66890. */
  66891. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66892. }
  66893. }
  66894. declare module BABYLON {
  66895. /**
  66896. * Class used to store bounding box information
  66897. */
  66898. export class BoundingBox implements ICullable {
  66899. /**
  66900. * Gets the 8 vectors representing the bounding box in local space
  66901. */
  66902. readonly vectors: Vector3[];
  66903. /**
  66904. * Gets the center of the bounding box in local space
  66905. */
  66906. readonly center: Vector3;
  66907. /**
  66908. * Gets the center of the bounding box in world space
  66909. */
  66910. readonly centerWorld: Vector3;
  66911. /**
  66912. * Gets the extend size in local space
  66913. */
  66914. readonly extendSize: Vector3;
  66915. /**
  66916. * Gets the extend size in world space
  66917. */
  66918. readonly extendSizeWorld: Vector3;
  66919. /**
  66920. * Gets the OBB (object bounding box) directions
  66921. */
  66922. readonly directions: Vector3[];
  66923. /**
  66924. * Gets the 8 vectors representing the bounding box in world space
  66925. */
  66926. readonly vectorsWorld: Vector3[];
  66927. /**
  66928. * Gets the minimum vector in world space
  66929. */
  66930. readonly minimumWorld: Vector3;
  66931. /**
  66932. * Gets the maximum vector in world space
  66933. */
  66934. readonly maximumWorld: Vector3;
  66935. /**
  66936. * Gets the minimum vector in local space
  66937. */
  66938. readonly minimum: Vector3;
  66939. /**
  66940. * Gets the maximum vector in local space
  66941. */
  66942. readonly maximum: Vector3;
  66943. private _worldMatrix;
  66944. private static readonly TmpVector3;
  66945. /**
  66946. * @hidden
  66947. */
  66948. _tag: number;
  66949. /**
  66950. * Creates a new bounding box
  66951. * @param min defines the minimum vector (in local space)
  66952. * @param max defines the maximum vector (in local space)
  66953. * @param worldMatrix defines the new world matrix
  66954. */
  66955. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66956. /**
  66957. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66958. * @param min defines the new minimum vector (in local space)
  66959. * @param max defines the new maximum vector (in local space)
  66960. * @param worldMatrix defines the new world matrix
  66961. */
  66962. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66963. /**
  66964. * Scale the current bounding box by applying a scale factor
  66965. * @param factor defines the scale factor to apply
  66966. * @returns the current bounding box
  66967. */
  66968. scale(factor: number): BoundingBox;
  66969. /**
  66970. * Gets the world matrix of the bounding box
  66971. * @returns a matrix
  66972. */
  66973. getWorldMatrix(): DeepImmutable<Matrix>;
  66974. /** @hidden */
  66975. _update(world: DeepImmutable<Matrix>): void;
  66976. /**
  66977. * Tests if the bounding box is intersecting the frustum planes
  66978. * @param frustumPlanes defines the frustum planes to test
  66979. * @returns true if there is an intersection
  66980. */
  66981. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66982. /**
  66983. * Tests if the bounding box is entirely inside the frustum planes
  66984. * @param frustumPlanes defines the frustum planes to test
  66985. * @returns true if there is an inclusion
  66986. */
  66987. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66988. /**
  66989. * Tests if a point is inside the bounding box
  66990. * @param point defines the point to test
  66991. * @returns true if the point is inside the bounding box
  66992. */
  66993. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66994. /**
  66995. * Tests if the bounding box intersects with a bounding sphere
  66996. * @param sphere defines the sphere to test
  66997. * @returns true if there is an intersection
  66998. */
  66999. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  67000. /**
  67001. * Tests if the bounding box intersects with a box defined by a min and max vectors
  67002. * @param min defines the min vector to use
  67003. * @param max defines the max vector to use
  67004. * @returns true if there is an intersection
  67005. */
  67006. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  67007. /**
  67008. * Tests if two bounding boxes are intersections
  67009. * @param box0 defines the first box to test
  67010. * @param box1 defines the second box to test
  67011. * @returns true if there is an intersection
  67012. */
  67013. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  67014. /**
  67015. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  67016. * @param minPoint defines the minimum vector of the bounding box
  67017. * @param maxPoint defines the maximum vector of the bounding box
  67018. * @param sphereCenter defines the sphere center
  67019. * @param sphereRadius defines the sphere radius
  67020. * @returns true if there is an intersection
  67021. */
  67022. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  67023. /**
  67024. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  67025. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67026. * @param frustumPlanes defines the frustum planes to test
  67027. * @return true if there is an inclusion
  67028. */
  67029. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67030. /**
  67031. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  67032. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  67033. * @param frustumPlanes defines the frustum planes to test
  67034. * @return true if there is an intersection
  67035. */
  67036. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67037. }
  67038. }
  67039. declare module BABYLON {
  67040. /** @hidden */
  67041. export class Collider {
  67042. /** Define if a collision was found */
  67043. collisionFound: boolean;
  67044. /**
  67045. * Define last intersection point in local space
  67046. */
  67047. intersectionPoint: Vector3;
  67048. /**
  67049. * Define last collided mesh
  67050. */
  67051. collidedMesh: Nullable<AbstractMesh>;
  67052. private _collisionPoint;
  67053. private _planeIntersectionPoint;
  67054. private _tempVector;
  67055. private _tempVector2;
  67056. private _tempVector3;
  67057. private _tempVector4;
  67058. private _edge;
  67059. private _baseToVertex;
  67060. private _destinationPoint;
  67061. private _slidePlaneNormal;
  67062. private _displacementVector;
  67063. /** @hidden */
  67064. _radius: Vector3;
  67065. /** @hidden */
  67066. _retry: number;
  67067. private _velocity;
  67068. private _basePoint;
  67069. private _epsilon;
  67070. /** @hidden */
  67071. _velocityWorldLength: number;
  67072. /** @hidden */
  67073. _basePointWorld: Vector3;
  67074. private _velocityWorld;
  67075. private _normalizedVelocity;
  67076. /** @hidden */
  67077. _initialVelocity: Vector3;
  67078. /** @hidden */
  67079. _initialPosition: Vector3;
  67080. private _nearestDistance;
  67081. private _collisionMask;
  67082. collisionMask: number;
  67083. /**
  67084. * Gets the plane normal used to compute the sliding response (in local space)
  67085. */
  67086. readonly slidePlaneNormal: Vector3;
  67087. /** @hidden */
  67088. _initialize(source: Vector3, dir: Vector3, e: number): void;
  67089. /** @hidden */
  67090. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  67091. /** @hidden */
  67092. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  67093. /** @hidden */
  67094. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  67095. /** @hidden */
  67096. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  67097. /** @hidden */
  67098. _getResponse(pos: Vector3, vel: Vector3): void;
  67099. }
  67100. }
  67101. declare module BABYLON {
  67102. /**
  67103. * Interface for cullable objects
  67104. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  67105. */
  67106. export interface ICullable {
  67107. /**
  67108. * Checks if the object or part of the object is in the frustum
  67109. * @param frustumPlanes Camera near/planes
  67110. * @returns true if the object is in frustum otherwise false
  67111. */
  67112. isInFrustum(frustumPlanes: Plane[]): boolean;
  67113. /**
  67114. * Checks if a cullable object (mesh...) is in the camera frustum
  67115. * Unlike isInFrustum this cheks the full bounding box
  67116. * @param frustumPlanes Camera near/planes
  67117. * @returns true if the object is in frustum otherwise false
  67118. */
  67119. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  67120. }
  67121. /**
  67122. * Info for a bounding data of a mesh
  67123. */
  67124. export class BoundingInfo implements ICullable {
  67125. /**
  67126. * Bounding box for the mesh
  67127. */
  67128. readonly boundingBox: BoundingBox;
  67129. /**
  67130. * Bounding sphere for the mesh
  67131. */
  67132. readonly boundingSphere: BoundingSphere;
  67133. private _isLocked;
  67134. private static readonly TmpVector3;
  67135. /**
  67136. * Constructs bounding info
  67137. * @param minimum min vector of the bounding box/sphere
  67138. * @param maximum max vector of the bounding box/sphere
  67139. * @param worldMatrix defines the new world matrix
  67140. */
  67141. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  67142. /**
  67143. * Recreates the entire bounding info from scratch as if we call the constructor in place
  67144. * @param min defines the new minimum vector (in local space)
  67145. * @param max defines the new maximum vector (in local space)
  67146. * @param worldMatrix defines the new world matrix
  67147. */
  67148. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  67149. /**
  67150. * min vector of the bounding box/sphere
  67151. */
  67152. readonly minimum: Vector3;
  67153. /**
  67154. * max vector of the bounding box/sphere
  67155. */
  67156. readonly maximum: Vector3;
  67157. /**
  67158. * If the info is locked and won't be updated to avoid perf overhead
  67159. */
  67160. isLocked: boolean;
  67161. /**
  67162. * Updates the bounding sphere and box
  67163. * @param world world matrix to be used to update
  67164. */
  67165. update(world: DeepImmutable<Matrix>): void;
  67166. /**
  67167. * Recreate the bounding info to be centered around a specific point given a specific extend.
  67168. * @param center New center of the bounding info
  67169. * @param extend New extend of the bounding info
  67170. * @returns the current bounding info
  67171. */
  67172. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  67173. /**
  67174. * Scale the current bounding info by applying a scale factor
  67175. * @param factor defines the scale factor to apply
  67176. * @returns the current bounding info
  67177. */
  67178. scale(factor: number): BoundingInfo;
  67179. /**
  67180. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  67181. * @param frustumPlanes defines the frustum to test
  67182. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  67183. * @returns true if the bounding info is in the frustum planes
  67184. */
  67185. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  67186. /**
  67187. * Gets the world distance between the min and max points of the bounding box
  67188. */
  67189. readonly diagonalLength: number;
  67190. /**
  67191. * Checks if a cullable object (mesh...) is in the camera frustum
  67192. * Unlike isInFrustum this cheks the full bounding box
  67193. * @param frustumPlanes Camera near/planes
  67194. * @returns true if the object is in frustum otherwise false
  67195. */
  67196. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  67197. /** @hidden */
  67198. _checkCollision(collider: Collider): boolean;
  67199. /**
  67200. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  67201. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67202. * @param point the point to check intersection with
  67203. * @returns if the point intersects
  67204. */
  67205. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  67206. /**
  67207. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  67208. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  67209. * @param boundingInfo the bounding info to check intersection with
  67210. * @param precise if the intersection should be done using OBB
  67211. * @returns if the bounding info intersects
  67212. */
  67213. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  67214. }
  67215. }
  67216. declare module BABYLON {
  67217. /**
  67218. * Defines an array and its length.
  67219. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  67220. */
  67221. export interface ISmartArrayLike<T> {
  67222. /**
  67223. * The data of the array.
  67224. */
  67225. data: Array<T>;
  67226. /**
  67227. * The active length of the array.
  67228. */
  67229. length: number;
  67230. }
  67231. /**
  67232. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67233. */
  67234. export class SmartArray<T> implements ISmartArrayLike<T> {
  67235. /**
  67236. * The full set of data from the array.
  67237. */
  67238. data: Array<T>;
  67239. /**
  67240. * The active length of the array.
  67241. */
  67242. length: number;
  67243. protected _id: number;
  67244. /**
  67245. * Instantiates a Smart Array.
  67246. * @param capacity defines the default capacity of the array.
  67247. */
  67248. constructor(capacity: number);
  67249. /**
  67250. * Pushes a value at the end of the active data.
  67251. * @param value defines the object to push in the array.
  67252. */
  67253. push(value: T): void;
  67254. /**
  67255. * Iterates over the active data and apply the lambda to them.
  67256. * @param func defines the action to apply on each value.
  67257. */
  67258. forEach(func: (content: T) => void): void;
  67259. /**
  67260. * Sorts the full sets of data.
  67261. * @param compareFn defines the comparison function to apply.
  67262. */
  67263. sort(compareFn: (a: T, b: T) => number): void;
  67264. /**
  67265. * Resets the active data to an empty array.
  67266. */
  67267. reset(): void;
  67268. /**
  67269. * Releases all the data from the array as well as the array.
  67270. */
  67271. dispose(): void;
  67272. /**
  67273. * Concats the active data with a given array.
  67274. * @param array defines the data to concatenate with.
  67275. */
  67276. concat(array: any): void;
  67277. /**
  67278. * Returns the position of a value in the active data.
  67279. * @param value defines the value to find the index for
  67280. * @returns the index if found in the active data otherwise -1
  67281. */
  67282. indexOf(value: T): number;
  67283. /**
  67284. * Returns whether an element is part of the active data.
  67285. * @param value defines the value to look for
  67286. * @returns true if found in the active data otherwise false
  67287. */
  67288. contains(value: T): boolean;
  67289. private static _GlobalId;
  67290. }
  67291. /**
  67292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  67293. * The data in this array can only be present once
  67294. */
  67295. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  67296. private _duplicateId;
  67297. /**
  67298. * Pushes a value at the end of the active data.
  67299. * THIS DOES NOT PREVENT DUPPLICATE DATA
  67300. * @param value defines the object to push in the array.
  67301. */
  67302. push(value: T): void;
  67303. /**
  67304. * Pushes a value at the end of the active data.
  67305. * If the data is already present, it won t be added again
  67306. * @param value defines the object to push in the array.
  67307. * @returns true if added false if it was already present
  67308. */
  67309. pushNoDuplicate(value: T): boolean;
  67310. /**
  67311. * Resets the active data to an empty array.
  67312. */
  67313. reset(): void;
  67314. /**
  67315. * Concats the active data with a given array.
  67316. * This ensures no dupplicate will be present in the result.
  67317. * @param array defines the data to concatenate with.
  67318. */
  67319. concatWithNoDuplicate(array: any): void;
  67320. }
  67321. }
  67322. declare module BABYLON {
  67323. /**
  67324. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67325. * separate meshes. This can be use to improve performances.
  67326. * @see http://doc.babylonjs.com/how_to/multi_materials
  67327. */
  67328. export class MultiMaterial extends Material {
  67329. private _subMaterials;
  67330. /**
  67331. * Gets or Sets the list of Materials used within the multi material.
  67332. * They need to be ordered according to the submeshes order in the associated mesh
  67333. */
  67334. subMaterials: Nullable<Material>[];
  67335. /**
  67336. * Function used to align with Node.getChildren()
  67337. * @returns the list of Materials used within the multi material
  67338. */
  67339. getChildren(): Nullable<Material>[];
  67340. /**
  67341. * Instantiates a new Multi Material
  67342. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67343. * separate meshes. This can be use to improve performances.
  67344. * @see http://doc.babylonjs.com/how_to/multi_materials
  67345. * @param name Define the name in the scene
  67346. * @param scene Define the scene the material belongs to
  67347. */
  67348. constructor(name: string, scene: Scene);
  67349. private _hookArray;
  67350. /**
  67351. * Get one of the submaterial by its index in the submaterials array
  67352. * @param index The index to look the sub material at
  67353. * @returns The Material if the index has been defined
  67354. */
  67355. getSubMaterial(index: number): Nullable<Material>;
  67356. /**
  67357. * Get the list of active textures for the whole sub materials list.
  67358. * @returns All the textures that will be used during the rendering
  67359. */
  67360. getActiveTextures(): BaseTexture[];
  67361. /**
  67362. * Gets the current class name of the material e.g. "MultiMaterial"
  67363. * Mainly use in serialization.
  67364. * @returns the class name
  67365. */
  67366. getClassName(): string;
  67367. /**
  67368. * Checks if the material is ready to render the requested sub mesh
  67369. * @param mesh Define the mesh the submesh belongs to
  67370. * @param subMesh Define the sub mesh to look readyness for
  67371. * @param useInstances Define whether or not the material is used with instances
  67372. * @returns true if ready, otherwise false
  67373. */
  67374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  67375. /**
  67376. * Clones the current material and its related sub materials
  67377. * @param name Define the name of the newly cloned material
  67378. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67379. * @returns the cloned material
  67380. */
  67381. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  67382. /**
  67383. * Serializes the materials into a JSON representation.
  67384. * @returns the JSON representation
  67385. */
  67386. serialize(): any;
  67387. /**
  67388. * Dispose the material and release its associated resources
  67389. * @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)
  67390. * @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)
  67391. * @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)
  67392. */
  67393. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  67394. /**
  67395. * Creates a MultiMaterial from parsed MultiMaterial data.
  67396. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67397. * @param scene defines the hosting scene
  67398. * @returns a new MultiMaterial
  67399. */
  67400. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  67401. }
  67402. }
  67403. declare module BABYLON {
  67404. /**
  67405. * Class used to represent data loading progression
  67406. */
  67407. export class SceneLoaderFlags {
  67408. private static _ForceFullSceneLoadingForIncremental;
  67409. private static _ShowLoadingScreen;
  67410. private static _CleanBoneMatrixWeights;
  67411. private static _loggingLevel;
  67412. /**
  67413. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  67414. */
  67415. static ForceFullSceneLoadingForIncremental: boolean;
  67416. /**
  67417. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  67418. */
  67419. static ShowLoadingScreen: boolean;
  67420. /**
  67421. * Defines the current logging level (while loading the scene)
  67422. * @ignorenaming
  67423. */
  67424. static loggingLevel: number;
  67425. /**
  67426. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67427. */
  67428. static CleanBoneMatrixWeights: boolean;
  67429. }
  67430. }
  67431. declare module BABYLON {
  67432. /**
  67433. * 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.
  67434. * @see https://doc.babylonjs.com/how_to/transformnode
  67435. */
  67436. export class TransformNode extends Node {
  67437. /**
  67438. * Object will not rotate to face the camera
  67439. */
  67440. static BILLBOARDMODE_NONE: number;
  67441. /**
  67442. * Object will rotate to face the camera but only on the x axis
  67443. */
  67444. static BILLBOARDMODE_X: number;
  67445. /**
  67446. * Object will rotate to face the camera but only on the y axis
  67447. */
  67448. static BILLBOARDMODE_Y: number;
  67449. /**
  67450. * Object will rotate to face the camera but only on the z axis
  67451. */
  67452. static BILLBOARDMODE_Z: number;
  67453. /**
  67454. * Object will rotate to face the camera
  67455. */
  67456. static BILLBOARDMODE_ALL: number;
  67457. private _forward;
  67458. private _forwardInverted;
  67459. private _up;
  67460. private _right;
  67461. private _rightInverted;
  67462. private _position;
  67463. private _rotation;
  67464. private _rotationQuaternion;
  67465. protected _scaling: Vector3;
  67466. protected _isDirty: boolean;
  67467. private _transformToBoneReferal;
  67468. private _billboardMode;
  67469. /**
  67470. * Gets or sets the billboard mode. Default is 0.
  67471. *
  67472. * | Value | Type | Description |
  67473. * | --- | --- | --- |
  67474. * | 0 | BILLBOARDMODE_NONE | |
  67475. * | 1 | BILLBOARDMODE_X | |
  67476. * | 2 | BILLBOARDMODE_Y | |
  67477. * | 4 | BILLBOARDMODE_Z | |
  67478. * | 7 | BILLBOARDMODE_ALL | |
  67479. *
  67480. */
  67481. billboardMode: number;
  67482. private _preserveParentRotationForBillboard;
  67483. /**
  67484. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67485. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67486. */
  67487. preserveParentRotationForBillboard: boolean;
  67488. /**
  67489. * 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
  67490. */
  67491. scalingDeterminant: number;
  67492. private _infiniteDistance;
  67493. /**
  67494. * Gets or sets the distance of the object to max, often used by skybox
  67495. */
  67496. infiniteDistance: boolean;
  67497. /**
  67498. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67499. * By default the system will update normals to compensate
  67500. */
  67501. ignoreNonUniformScaling: boolean;
  67502. /**
  67503. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67504. */
  67505. reIntegrateRotationIntoRotationQuaternion: boolean;
  67506. /** @hidden */
  67507. _poseMatrix: Nullable<Matrix>;
  67508. /** @hidden */
  67509. _localMatrix: Matrix;
  67510. private _usePivotMatrix;
  67511. private _absolutePosition;
  67512. private _pivotMatrix;
  67513. private _pivotMatrixInverse;
  67514. protected _postMultiplyPivotMatrix: boolean;
  67515. protected _isWorldMatrixFrozen: boolean;
  67516. /** @hidden */
  67517. _indexInSceneTransformNodesArray: number;
  67518. /**
  67519. * An event triggered after the world matrix is updated
  67520. */
  67521. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67522. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67523. /**
  67524. * Gets a string identifying the name of the class
  67525. * @returns "TransformNode" string
  67526. */
  67527. getClassName(): string;
  67528. /**
  67529. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67530. */
  67531. position: Vector3;
  67532. /**
  67533. * 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)).
  67534. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67535. */
  67536. rotation: Vector3;
  67537. /**
  67538. * 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)).
  67539. */
  67540. scaling: Vector3;
  67541. /**
  67542. * 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).
  67543. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67544. */
  67545. rotationQuaternion: Nullable<Quaternion>;
  67546. /**
  67547. * The forward direction of that transform in world space.
  67548. */
  67549. readonly forward: Vector3;
  67550. /**
  67551. * The up direction of that transform in world space.
  67552. */
  67553. readonly up: Vector3;
  67554. /**
  67555. * The right direction of that transform in world space.
  67556. */
  67557. readonly right: Vector3;
  67558. /**
  67559. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67560. * @param matrix the matrix to copy the pose from
  67561. * @returns this TransformNode.
  67562. */
  67563. updatePoseMatrix(matrix: Matrix): TransformNode;
  67564. /**
  67565. * Returns the mesh Pose matrix.
  67566. * @returns the pose matrix
  67567. */
  67568. getPoseMatrix(): Matrix;
  67569. /** @hidden */
  67570. _isSynchronized(): boolean;
  67571. /** @hidden */
  67572. _initCache(): void;
  67573. /**
  67574. * Flag the transform node as dirty (Forcing it to update everything)
  67575. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67576. * @returns this transform node
  67577. */
  67578. markAsDirty(property: string): TransformNode;
  67579. /**
  67580. * Returns the current mesh absolute position.
  67581. * Returns a Vector3.
  67582. */
  67583. readonly absolutePosition: Vector3;
  67584. /**
  67585. * Sets a new matrix to apply before all other transformation
  67586. * @param matrix defines the transform matrix
  67587. * @returns the current TransformNode
  67588. */
  67589. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67590. /**
  67591. * Sets a new pivot matrix to the current node
  67592. * @param matrix defines the new pivot matrix to use
  67593. * @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
  67594. * @returns the current TransformNode
  67595. */
  67596. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67597. /**
  67598. * Returns the mesh pivot matrix.
  67599. * Default : Identity.
  67600. * @returns the matrix
  67601. */
  67602. getPivotMatrix(): Matrix;
  67603. /**
  67604. * Prevents the World matrix to be computed any longer.
  67605. * @returns the TransformNode.
  67606. */
  67607. freezeWorldMatrix(): TransformNode;
  67608. /**
  67609. * Allows back the World matrix computation.
  67610. * @returns the TransformNode.
  67611. */
  67612. unfreezeWorldMatrix(): this;
  67613. /**
  67614. * True if the World matrix has been frozen.
  67615. */
  67616. readonly isWorldMatrixFrozen: boolean;
  67617. /**
  67618. * Retuns the mesh absolute position in the World.
  67619. * @returns a Vector3.
  67620. */
  67621. getAbsolutePosition(): Vector3;
  67622. /**
  67623. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67624. * @param absolutePosition the absolute position to set
  67625. * @returns the TransformNode.
  67626. */
  67627. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67628. /**
  67629. * Sets the mesh position in its local space.
  67630. * @param vector3 the position to set in localspace
  67631. * @returns the TransformNode.
  67632. */
  67633. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67634. /**
  67635. * Returns the mesh position in the local space from the current World matrix values.
  67636. * @returns a new Vector3.
  67637. */
  67638. getPositionExpressedInLocalSpace(): Vector3;
  67639. /**
  67640. * Translates the mesh along the passed Vector3 in its local space.
  67641. * @param vector3 the distance to translate in localspace
  67642. * @returns the TransformNode.
  67643. */
  67644. locallyTranslate(vector3: Vector3): TransformNode;
  67645. private static _lookAtVectorCache;
  67646. /**
  67647. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67648. * @param targetPoint the position (must be in same space as current mesh) to look at
  67649. * @param yawCor optional yaw (y-axis) correction in radians
  67650. * @param pitchCor optional pitch (x-axis) correction in radians
  67651. * @param rollCor optional roll (z-axis) correction in radians
  67652. * @param space the choosen space of the target
  67653. * @returns the TransformNode.
  67654. */
  67655. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67656. /**
  67657. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67658. * This Vector3 is expressed in the World space.
  67659. * @param localAxis axis to rotate
  67660. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67661. */
  67662. getDirection(localAxis: Vector3): Vector3;
  67663. /**
  67664. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67665. * localAxis is expressed in the mesh local space.
  67666. * result is computed in the Wordl space from the mesh World matrix.
  67667. * @param localAxis axis to rotate
  67668. * @param result the resulting transformnode
  67669. * @returns this TransformNode.
  67670. */
  67671. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67672. /**
  67673. * Sets this transform node rotation to the given local axis.
  67674. * @param localAxis the axis in local space
  67675. * @param yawCor optional yaw (y-axis) correction in radians
  67676. * @param pitchCor optional pitch (x-axis) correction in radians
  67677. * @param rollCor optional roll (z-axis) correction in radians
  67678. * @returns this TransformNode
  67679. */
  67680. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67681. /**
  67682. * Sets a new pivot point to the current node
  67683. * @param point defines the new pivot point to use
  67684. * @param space defines if the point is in world or local space (local by default)
  67685. * @returns the current TransformNode
  67686. */
  67687. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67688. /**
  67689. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67690. * @returns the pivot point
  67691. */
  67692. getPivotPoint(): Vector3;
  67693. /**
  67694. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67695. * @param result the vector3 to store the result
  67696. * @returns this TransformNode.
  67697. */
  67698. getPivotPointToRef(result: Vector3): TransformNode;
  67699. /**
  67700. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67701. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67702. */
  67703. getAbsolutePivotPoint(): Vector3;
  67704. /**
  67705. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67706. * @param result vector3 to store the result
  67707. * @returns this TransformNode.
  67708. */
  67709. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67710. /**
  67711. * Defines the passed node as the parent of the current node.
  67712. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67713. * @see https://doc.babylonjs.com/how_to/parenting
  67714. * @param node the node ot set as the parent
  67715. * @returns this TransformNode.
  67716. */
  67717. setParent(node: Nullable<Node>): TransformNode;
  67718. private _nonUniformScaling;
  67719. /**
  67720. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67721. */
  67722. readonly nonUniformScaling: boolean;
  67723. /** @hidden */
  67724. _updateNonUniformScalingState(value: boolean): boolean;
  67725. /**
  67726. * Attach the current TransformNode to another TransformNode associated with a bone
  67727. * @param bone Bone affecting the TransformNode
  67728. * @param affectedTransformNode TransformNode associated with the bone
  67729. * @returns this object
  67730. */
  67731. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67732. /**
  67733. * Detach the transform node if its associated with a bone
  67734. * @returns this object
  67735. */
  67736. detachFromBone(): TransformNode;
  67737. private static _rotationAxisCache;
  67738. /**
  67739. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67740. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67741. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67742. * The passed axis is also normalized.
  67743. * @param axis the axis to rotate around
  67744. * @param amount the amount to rotate in radians
  67745. * @param space Space to rotate in (Default: local)
  67746. * @returns the TransformNode.
  67747. */
  67748. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67749. /**
  67750. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67751. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67752. * The passed axis is also normalized. .
  67753. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67754. * @param point the point to rotate around
  67755. * @param axis the axis to rotate around
  67756. * @param amount the amount to rotate in radians
  67757. * @returns the TransformNode
  67758. */
  67759. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67760. /**
  67761. * Translates the mesh along the axis vector for the passed distance in the given space.
  67762. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67763. * @param axis the axis to translate in
  67764. * @param distance the distance to translate
  67765. * @param space Space to rotate in (Default: local)
  67766. * @returns the TransformNode.
  67767. */
  67768. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67769. /**
  67770. * Adds a rotation step to the mesh current rotation.
  67771. * x, y, z are Euler angles expressed in radians.
  67772. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67773. * This means this rotation is made in the mesh local space only.
  67774. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67775. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67776. * ```javascript
  67777. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67778. * ```
  67779. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67780. * 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.
  67781. * @param x Rotation to add
  67782. * @param y Rotation to add
  67783. * @param z Rotation to add
  67784. * @returns the TransformNode.
  67785. */
  67786. addRotation(x: number, y: number, z: number): TransformNode;
  67787. /**
  67788. * @hidden
  67789. */
  67790. protected _getEffectiveParent(): Nullable<Node>;
  67791. /**
  67792. * Computes the world matrix of the node
  67793. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67794. * @returns the world matrix
  67795. */
  67796. computeWorldMatrix(force?: boolean): Matrix;
  67797. protected _afterComputeWorldMatrix(): void;
  67798. /**
  67799. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67800. * @param func callback function to add
  67801. *
  67802. * @returns the TransformNode.
  67803. */
  67804. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67805. /**
  67806. * Removes a registered callback function.
  67807. * @param func callback function to remove
  67808. * @returns the TransformNode.
  67809. */
  67810. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67811. /**
  67812. * Gets the position of the current mesh in camera space
  67813. * @param camera defines the camera to use
  67814. * @returns a position
  67815. */
  67816. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67817. /**
  67818. * Returns the distance from the mesh to the active camera
  67819. * @param camera defines the camera to use
  67820. * @returns the distance
  67821. */
  67822. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67823. /**
  67824. * Clone the current transform node
  67825. * @param name Name of the new clone
  67826. * @param newParent New parent for the clone
  67827. * @param doNotCloneChildren Do not clone children hierarchy
  67828. * @returns the new transform node
  67829. */
  67830. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67831. /**
  67832. * Serializes the objects information.
  67833. * @param currentSerializationObject defines the object to serialize in
  67834. * @returns the serialized object
  67835. */
  67836. serialize(currentSerializationObject?: any): any;
  67837. /**
  67838. * Returns a new TransformNode object parsed from the source provided.
  67839. * @param parsedTransformNode is the source.
  67840. * @param scene the scne the object belongs to
  67841. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67842. * @returns a new TransformNode object parsed from the source provided.
  67843. */
  67844. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67845. /**
  67846. * Get all child-transformNodes of this node
  67847. * @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
  67848. * @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
  67849. * @returns an array of TransformNode
  67850. */
  67851. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67852. /**
  67853. * Releases resources associated with this transform node.
  67854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67856. */
  67857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67858. }
  67859. }
  67860. declare module BABYLON {
  67861. /**
  67862. * Class used to override all child animations of a given target
  67863. */
  67864. export class AnimationPropertiesOverride {
  67865. /**
  67866. * Gets or sets a value indicating if animation blending must be used
  67867. */
  67868. enableBlending: boolean;
  67869. /**
  67870. * Gets or sets the blending speed to use when enableBlending is true
  67871. */
  67872. blendingSpeed: number;
  67873. /**
  67874. * Gets or sets the default loop mode to use
  67875. */
  67876. loopMode: number;
  67877. }
  67878. }
  67879. declare module BABYLON {
  67880. /**
  67881. * Class used to store bone information
  67882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67883. */
  67884. export class Bone extends Node {
  67885. /**
  67886. * defines the bone name
  67887. */
  67888. name: string;
  67889. private static _tmpVecs;
  67890. private static _tmpQuat;
  67891. private static _tmpMats;
  67892. /**
  67893. * Gets the list of child bones
  67894. */
  67895. children: Bone[];
  67896. /** Gets the animations associated with this bone */
  67897. animations: Animation[];
  67898. /**
  67899. * Gets or sets bone length
  67900. */
  67901. length: number;
  67902. /**
  67903. * @hidden Internal only
  67904. * Set this value to map this bone to a different index in the transform matrices
  67905. * Set this value to -1 to exclude the bone from the transform matrices
  67906. */
  67907. _index: Nullable<number>;
  67908. private _skeleton;
  67909. private _localMatrix;
  67910. private _restPose;
  67911. private _baseMatrix;
  67912. private _absoluteTransform;
  67913. private _invertedAbsoluteTransform;
  67914. private _parent;
  67915. private _scalingDeterminant;
  67916. private _worldTransform;
  67917. private _localScaling;
  67918. private _localRotation;
  67919. private _localPosition;
  67920. private _needToDecompose;
  67921. private _needToCompose;
  67922. /** @hidden */
  67923. _linkedTransformNode: Nullable<TransformNode>;
  67924. /** @hidden */
  67925. /** @hidden */
  67926. _matrix: Matrix;
  67927. /**
  67928. * Create a new bone
  67929. * @param name defines the bone name
  67930. * @param skeleton defines the parent skeleton
  67931. * @param parentBone defines the parent (can be null if the bone is the root)
  67932. * @param localMatrix defines the local matrix
  67933. * @param restPose defines the rest pose matrix
  67934. * @param baseMatrix defines the base matrix
  67935. * @param index defines index of the bone in the hiearchy
  67936. */
  67937. constructor(
  67938. /**
  67939. * defines the bone name
  67940. */
  67941. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67942. /**
  67943. * Gets the current object class name.
  67944. * @return the class name
  67945. */
  67946. getClassName(): string;
  67947. /**
  67948. * Gets the parent skeleton
  67949. * @returns a skeleton
  67950. */
  67951. getSkeleton(): Skeleton;
  67952. /**
  67953. * Gets parent bone
  67954. * @returns a bone or null if the bone is the root of the bone hierarchy
  67955. */
  67956. getParent(): Nullable<Bone>;
  67957. /**
  67958. * Returns an array containing the root bones
  67959. * @returns an array containing the root bones
  67960. */
  67961. getChildren(): Array<Bone>;
  67962. /**
  67963. * Sets the parent bone
  67964. * @param parent defines the parent (can be null if the bone is the root)
  67965. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67966. */
  67967. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67968. /**
  67969. * Gets the local matrix
  67970. * @returns a matrix
  67971. */
  67972. getLocalMatrix(): Matrix;
  67973. /**
  67974. * Gets the base matrix (initial matrix which remains unchanged)
  67975. * @returns a matrix
  67976. */
  67977. getBaseMatrix(): Matrix;
  67978. /**
  67979. * Gets the rest pose matrix
  67980. * @returns a matrix
  67981. */
  67982. getRestPose(): Matrix;
  67983. /**
  67984. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67985. */
  67986. getWorldMatrix(): Matrix;
  67987. /**
  67988. * Sets the local matrix to rest pose matrix
  67989. */
  67990. returnToRest(): void;
  67991. /**
  67992. * Gets the inverse of the absolute transform matrix.
  67993. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67994. * @returns a matrix
  67995. */
  67996. getInvertedAbsoluteTransform(): Matrix;
  67997. /**
  67998. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67999. * @returns a matrix
  68000. */
  68001. getAbsoluteTransform(): Matrix;
  68002. /**
  68003. * Links with the given transform node.
  68004. * The local matrix of this bone is copied from the transform node every frame.
  68005. * @param transformNode defines the transform node to link to
  68006. */
  68007. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  68008. /** Gets or sets current position (in local space) */
  68009. position: Vector3;
  68010. /** Gets or sets current rotation (in local space) */
  68011. rotation: Vector3;
  68012. /** Gets or sets current rotation quaternion (in local space) */
  68013. rotationQuaternion: Quaternion;
  68014. /** Gets or sets current scaling (in local space) */
  68015. scaling: Vector3;
  68016. /**
  68017. * Gets the animation properties override
  68018. */
  68019. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  68020. private _decompose;
  68021. private _compose;
  68022. /**
  68023. * Update the base and local matrices
  68024. * @param matrix defines the new base or local matrix
  68025. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  68026. * @param updateLocalMatrix defines if the local matrix should be updated
  68027. */
  68028. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  68029. /** @hidden */
  68030. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  68031. /**
  68032. * Flag the bone as dirty (Forcing it to update everything)
  68033. */
  68034. markAsDirty(): void;
  68035. private _markAsDirtyAndCompose;
  68036. private _markAsDirtyAndDecompose;
  68037. /**
  68038. * Translate the bone in local or world space
  68039. * @param vec The amount to translate the bone
  68040. * @param space The space that the translation is in
  68041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68042. */
  68043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68044. /**
  68045. * Set the postion of the bone in local or world space
  68046. * @param position The position to set the bone
  68047. * @param space The space that the position is in
  68048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68049. */
  68050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68051. /**
  68052. * Set the absolute position of the bone (world space)
  68053. * @param position The position to set the bone
  68054. * @param mesh The mesh that this bone is attached to
  68055. */
  68056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  68057. /**
  68058. * Scale the bone on the x, y and z axes (in local space)
  68059. * @param x The amount to scale the bone on the x axis
  68060. * @param y The amount to scale the bone on the y axis
  68061. * @param z The amount to scale the bone on the z axis
  68062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  68063. */
  68064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  68065. /**
  68066. * Set the bone scaling in local space
  68067. * @param scale defines the scaling vector
  68068. */
  68069. setScale(scale: Vector3): void;
  68070. /**
  68071. * Gets the current scaling in local space
  68072. * @returns the current scaling vector
  68073. */
  68074. getScale(): Vector3;
  68075. /**
  68076. * Gets the current scaling in local space and stores it in a target vector
  68077. * @param result defines the target vector
  68078. */
  68079. getScaleToRef(result: Vector3): void;
  68080. /**
  68081. * Set the yaw, pitch, and roll of the bone in local or world space
  68082. * @param yaw The rotation of the bone on the y axis
  68083. * @param pitch The rotation of the bone on the x axis
  68084. * @param roll The rotation of the bone on the z axis
  68085. * @param space The space that the axes of rotation are in
  68086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68087. */
  68088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  68089. /**
  68090. * Add a rotation to the bone on an axis in local or world space
  68091. * @param axis The axis to rotate the bone on
  68092. * @param amount The amount to rotate the bone
  68093. * @param space The space that the axis is in
  68094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68095. */
  68096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  68097. /**
  68098. * Set the rotation of the bone to a particular axis angle in local or world space
  68099. * @param axis The axis to rotate the bone on
  68100. * @param angle The angle that the bone should be rotated to
  68101. * @param space The space that the axis is in
  68102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68103. */
  68104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  68105. /**
  68106. * Set the euler rotation of the bone in local of world space
  68107. * @param rotation The euler rotation that the bone should be set to
  68108. * @param space The space that the rotation is in
  68109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68110. */
  68111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  68112. /**
  68113. * Set the quaternion rotation of the bone in local of world space
  68114. * @param quat The quaternion rotation that the bone should be set to
  68115. * @param space The space that the rotation is in
  68116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68117. */
  68118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  68119. /**
  68120. * Set the rotation matrix of the bone in local of world space
  68121. * @param rotMat The rotation matrix that the bone should be set to
  68122. * @param space The space that the rotation is in
  68123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68124. */
  68125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  68126. private _rotateWithMatrix;
  68127. private _getNegativeRotationToRef;
  68128. /**
  68129. * Get the position of the bone in local or world space
  68130. * @param space The space that the returned position is in
  68131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68132. * @returns The position of the bone
  68133. */
  68134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68135. /**
  68136. * Copy the position of the bone to a vector3 in local or world space
  68137. * @param space The space that the returned position is in
  68138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68139. * @param result The vector3 to copy the position to
  68140. */
  68141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  68142. /**
  68143. * Get the absolute position of the bone (world space)
  68144. * @param mesh The mesh that this bone is attached to
  68145. * @returns The absolute position of the bone
  68146. */
  68147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  68148. /**
  68149. * Copy the absolute position of the bone (world space) to the result param
  68150. * @param mesh The mesh that this bone is attached to
  68151. * @param result The vector3 to copy the absolute position to
  68152. */
  68153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  68154. /**
  68155. * Compute the absolute transforms of this bone and its children
  68156. */
  68157. computeAbsoluteTransforms(): void;
  68158. /**
  68159. * Get the world direction from an axis that is in the local space of the bone
  68160. * @param localAxis The local direction that is used to compute the world direction
  68161. * @param mesh The mesh that this bone is attached to
  68162. * @returns The world direction
  68163. */
  68164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68165. /**
  68166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  68167. * @param localAxis The local direction that is used to compute the world direction
  68168. * @param mesh The mesh that this bone is attached to
  68169. * @param result The vector3 that the world direction will be copied to
  68170. */
  68171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68172. /**
  68173. * Get the euler rotation of the bone in local or world space
  68174. * @param space The space that the rotation should be in
  68175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68176. * @returns The euler rotation
  68177. */
  68178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  68179. /**
  68180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  68181. * @param space The space that the rotation should be in
  68182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68183. * @param result The vector3 that the rotation should be copied to
  68184. */
  68185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68186. /**
  68187. * Get the quaternion rotation of the bone in either local or world space
  68188. * @param space The space that the rotation should be in
  68189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68190. * @returns The quaternion rotation
  68191. */
  68192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  68193. /**
  68194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  68195. * @param space The space that the rotation should be in
  68196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68197. * @param result The quaternion that the rotation should be copied to
  68198. */
  68199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  68200. /**
  68201. * Get the rotation matrix of the bone in local or world space
  68202. * @param space The space that the rotation should be in
  68203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68204. * @returns The rotation matrix
  68205. */
  68206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  68207. /**
  68208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  68209. * @param space The space that the rotation should be in
  68210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  68211. * @param result The quaternion that the rotation should be copied to
  68212. */
  68213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  68214. /**
  68215. * Get the world position of a point that is in the local space of the bone
  68216. * @param position The local position
  68217. * @param mesh The mesh that this bone is attached to
  68218. * @returns The world position
  68219. */
  68220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68221. /**
  68222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  68223. * @param position The local position
  68224. * @param mesh The mesh that this bone is attached to
  68225. * @param result The vector3 that the world position should be copied to
  68226. */
  68227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68228. /**
  68229. * Get the local position of a point that is in world space
  68230. * @param position The world position
  68231. * @param mesh The mesh that this bone is attached to
  68232. * @returns The local position
  68233. */
  68234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  68235. /**
  68236. * Get the local position of a point that is in world space and copy it to the result param
  68237. * @param position The world position
  68238. * @param mesh The mesh that this bone is attached to
  68239. * @param result The vector3 that the local position should be copied to
  68240. */
  68241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  68242. }
  68243. }
  68244. declare module BABYLON {
  68245. /**
  68246. * Enum that determines the text-wrapping mode to use.
  68247. */
  68248. export enum InspectableType {
  68249. /**
  68250. * Checkbox for booleans
  68251. */
  68252. Checkbox = 0,
  68253. /**
  68254. * Sliders for numbers
  68255. */
  68256. Slider = 1,
  68257. /**
  68258. * Vector3
  68259. */
  68260. Vector3 = 2,
  68261. /**
  68262. * Quaternions
  68263. */
  68264. Quaternion = 3,
  68265. /**
  68266. * Color3
  68267. */
  68268. Color3 = 4
  68269. }
  68270. /**
  68271. * Interface used to define custom inspectable properties.
  68272. * This interface is used by the inspector to display custom property grids
  68273. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68274. */
  68275. export interface IInspectable {
  68276. /**
  68277. * Gets the label to display
  68278. */
  68279. label: string;
  68280. /**
  68281. * Gets the name of the property to edit
  68282. */
  68283. propertyName: string;
  68284. /**
  68285. * Gets the type of the editor to use
  68286. */
  68287. type: InspectableType;
  68288. /**
  68289. * Gets the minimum value of the property when using in "slider" mode
  68290. */
  68291. min?: number;
  68292. /**
  68293. * Gets the maximum value of the property when using in "slider" mode
  68294. */
  68295. max?: number;
  68296. /**
  68297. * Gets the setp to use when using in "slider" mode
  68298. */
  68299. step?: number;
  68300. }
  68301. }
  68302. declare module BABYLON {
  68303. /**
  68304. * This represents the required contract to create a new type of texture loader.
  68305. */
  68306. export interface IInternalTextureLoader {
  68307. /**
  68308. * Defines wether the loader supports cascade loading the different faces.
  68309. */
  68310. supportCascades: boolean;
  68311. /**
  68312. * This returns if the loader support the current file information.
  68313. * @param extension defines the file extension of the file being loaded
  68314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68315. * @param fallback defines the fallback internal texture if any
  68316. * @param isBase64 defines whether the texture is encoded as a base64
  68317. * @param isBuffer defines whether the texture data are stored as a buffer
  68318. * @returns true if the loader can load the specified file
  68319. */
  68320. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68321. /**
  68322. * Transform the url before loading if required.
  68323. * @param rootUrl the url of the texture
  68324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68325. * @returns the transformed texture
  68326. */
  68327. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68328. /**
  68329. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68330. * @param rootUrl the url of the texture
  68331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68332. * @returns the fallback texture
  68333. */
  68334. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68335. /**
  68336. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68337. * @param data contains the texture data
  68338. * @param texture defines the BabylonJS internal texture
  68339. * @param createPolynomials will be true if polynomials have been requested
  68340. * @param onLoad defines the callback to trigger once the texture is ready
  68341. * @param onError defines the callback to trigger in case of error
  68342. */
  68343. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68344. /**
  68345. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68346. * @param data contains the texture data
  68347. * @param texture defines the BabylonJS internal texture
  68348. * @param callback defines the method to call once ready to upload
  68349. */
  68350. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. interface Engine {
  68355. /**
  68356. * Creates a depth stencil cube texture.
  68357. * This is only available in WebGL 2.
  68358. * @param size The size of face edge in the cube texture.
  68359. * @param options The options defining the cube texture.
  68360. * @returns The cube texture
  68361. */
  68362. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  68363. /**
  68364. * Creates a cube texture
  68365. * @param rootUrl defines the url where the files to load is located
  68366. * @param scene defines the current scene
  68367. * @param files defines the list of files to load (1 per face)
  68368. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68369. * @param onLoad defines an optional callback raised when the texture is loaded
  68370. * @param onError defines an optional callback raised if there is an issue to load the texture
  68371. * @param format defines the format of the data
  68372. * @param forcedExtension defines the extension to use to pick the right loader
  68373. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68374. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68375. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68376. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  68377. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  68378. * @returns the cube texture as an InternalTexture
  68379. */
  68380. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  68381. /**
  68382. * Creates a cube texture
  68383. * @param rootUrl defines the url where the files to load is located
  68384. * @param scene defines the current scene
  68385. * @param files defines the list of files to load (1 per face)
  68386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68387. * @param onLoad defines an optional callback raised when the texture is loaded
  68388. * @param onError defines an optional callback raised if there is an issue to load the texture
  68389. * @param format defines the format of the data
  68390. * @param forcedExtension defines the extension to use to pick the right loader
  68391. * @returns the cube texture as an InternalTexture
  68392. */
  68393. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  68394. /**
  68395. * Creates a cube texture
  68396. * @param rootUrl defines the url where the files to load is located
  68397. * @param scene defines the current scene
  68398. * @param files defines the list of files to load (1 per face)
  68399. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  68400. * @param onLoad defines an optional callback raised when the texture is loaded
  68401. * @param onError defines an optional callback raised if there is an issue to load the texture
  68402. * @param format defines the format of the data
  68403. * @param forcedExtension defines the extension to use to pick the right loader
  68404. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  68405. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68406. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68407. * @returns the cube texture as an InternalTexture
  68408. */
  68409. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  68410. /** @hidden */
  68411. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68412. /** @hidden */
  68413. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68414. /** @hidden */
  68415. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  68416. /** @hidden */
  68417. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  68418. }
  68419. }
  68420. declare module BABYLON {
  68421. /**
  68422. * Class for creating a cube texture
  68423. */
  68424. export class CubeTexture extends BaseTexture {
  68425. private _delayedOnLoad;
  68426. /**
  68427. * The url of the texture
  68428. */
  68429. url: string;
  68430. /**
  68431. * Gets or sets the center of the bounding box associated with the cube texture.
  68432. * It must define where the camera used to render the texture was set
  68433. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68434. */
  68435. boundingBoxPosition: Vector3;
  68436. private _boundingBoxSize;
  68437. /**
  68438. * Gets or sets the size of the bounding box associated with the cube texture
  68439. * When defined, the cubemap will switch to local mode
  68440. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  68441. * @example https://www.babylonjs-playground.com/#RNASML
  68442. */
  68443. /**
  68444. * Returns the bounding box size
  68445. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  68446. */
  68447. boundingBoxSize: Vector3;
  68448. protected _rotationY: number;
  68449. /**
  68450. * Sets texture matrix rotation angle around Y axis in radians.
  68451. */
  68452. /**
  68453. * Gets texture matrix rotation angle around Y axis radians.
  68454. */
  68455. rotationY: number;
  68456. /**
  68457. * Are mip maps generated for this texture or not.
  68458. */
  68459. readonly noMipmap: boolean;
  68460. private _noMipmap;
  68461. private _files;
  68462. private _extensions;
  68463. private _textureMatrix;
  68464. private _format;
  68465. private _createPolynomials;
  68466. /** @hidden */
  68467. _prefiltered: boolean;
  68468. /**
  68469. * Creates a cube texture from an array of image urls
  68470. * @param files defines an array of image urls
  68471. * @param scene defines the hosting scene
  68472. * @param noMipmap specifies if mip maps are not used
  68473. * @returns a cube texture
  68474. */
  68475. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  68476. /**
  68477. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  68478. * @param url defines the url of the prefiltered texture
  68479. * @param scene defines the scene the texture is attached to
  68480. * @param forcedExtension defines the extension of the file if different from the url
  68481. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68482. * @return the prefiltered texture
  68483. */
  68484. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  68485. /**
  68486. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  68487. * as prefiltered data.
  68488. * @param rootUrl defines the url of the texture or the root name of the six images
  68489. * @param scene defines the scene the texture is attached to
  68490. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  68491. * @param noMipmap defines if mipmaps should be created or not
  68492. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  68493. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  68494. * @param onError defines a callback triggered in case of error during load
  68495. * @param format defines the internal format to use for the texture once loaded
  68496. * @param prefiltered defines whether or not the texture is created from prefiltered data
  68497. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  68498. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  68499. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  68500. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  68501. * @return the cube texture
  68502. */
  68503. 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);
  68504. /**
  68505. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  68506. */
  68507. readonly isPrefiltered: boolean;
  68508. /**
  68509. * Get the current class name of the texture useful for serialization or dynamic coding.
  68510. * @returns "CubeTexture"
  68511. */
  68512. getClassName(): string;
  68513. /**
  68514. * Update the url (and optional buffer) of this texture if url was null during construction.
  68515. * @param url the url of the texture
  68516. * @param forcedExtension defines the extension to use
  68517. * @param onLoad callback called when the texture is loaded (defaults to null)
  68518. */
  68519. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  68520. /**
  68521. * Delays loading of the cube texture
  68522. * @param forcedExtension defines the extension to use
  68523. */
  68524. delayLoad(forcedExtension?: string): void;
  68525. /**
  68526. * Returns the reflection texture matrix
  68527. * @returns the reflection texture matrix
  68528. */
  68529. getReflectionTextureMatrix(): Matrix;
  68530. /**
  68531. * Sets the reflection texture matrix
  68532. * @param value Reflection texture matrix
  68533. */
  68534. setReflectionTextureMatrix(value: Matrix): void;
  68535. /**
  68536. * Parses text to create a cube texture
  68537. * @param parsedTexture define the serialized text to read from
  68538. * @param scene defines the hosting scene
  68539. * @param rootUrl defines the root url of the cube texture
  68540. * @returns a cube texture
  68541. */
  68542. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68543. /**
  68544. * Makes a clone, or deep copy, of the cube texture
  68545. * @returns a new cube texture
  68546. */
  68547. clone(): CubeTexture;
  68548. }
  68549. }
  68550. declare module BABYLON {
  68551. /** @hidden */
  68552. export var postprocessVertexShader: {
  68553. name: string;
  68554. shader: string;
  68555. };
  68556. }
  68557. declare module BABYLON {
  68558. /**
  68559. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68560. * This is the base of the follow, arc rotate cameras and Free camera
  68561. * @see http://doc.babylonjs.com/features/cameras
  68562. */
  68563. export class TargetCamera extends Camera {
  68564. private static _RigCamTransformMatrix;
  68565. private static _TargetTransformMatrix;
  68566. private static _TargetFocalPoint;
  68567. /**
  68568. * Define the current direction the camera is moving to
  68569. */
  68570. cameraDirection: Vector3;
  68571. /**
  68572. * Define the current rotation the camera is rotating to
  68573. */
  68574. cameraRotation: Vector2;
  68575. /**
  68576. * When set, the up vector of the camera will be updated by the rotation of the camera
  68577. */
  68578. updateUpVectorFromRotation: boolean;
  68579. private _tmpQuaternion;
  68580. /**
  68581. * Define the current rotation of the camera
  68582. */
  68583. rotation: Vector3;
  68584. /**
  68585. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68586. */
  68587. rotationQuaternion: Quaternion;
  68588. /**
  68589. * Define the current speed of the camera
  68590. */
  68591. speed: number;
  68592. /**
  68593. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68594. * around all axis.
  68595. */
  68596. noRotationConstraint: boolean;
  68597. /**
  68598. * Define the current target of the camera as an object or a position.
  68599. */
  68600. lockedTarget: any;
  68601. /** @hidden */
  68602. _currentTarget: Vector3;
  68603. /** @hidden */
  68604. _initialFocalDistance: number;
  68605. /** @hidden */
  68606. _viewMatrix: Matrix;
  68607. /** @hidden */
  68608. _camMatrix: Matrix;
  68609. /** @hidden */
  68610. _cameraTransformMatrix: Matrix;
  68611. /** @hidden */
  68612. _cameraRotationMatrix: Matrix;
  68613. /** @hidden */
  68614. _referencePoint: Vector3;
  68615. /** @hidden */
  68616. _transformedReferencePoint: Vector3;
  68617. protected _globalCurrentTarget: Vector3;
  68618. protected _globalCurrentUpVector: Vector3;
  68619. /** @hidden */
  68620. _reset: () => void;
  68621. private _defaultUp;
  68622. /**
  68623. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68624. * This is the base of the follow, arc rotate cameras and Free camera
  68625. * @see http://doc.babylonjs.com/features/cameras
  68626. * @param name Defines the name of the camera in the scene
  68627. * @param position Defines the start position of the camera in the scene
  68628. * @param scene Defines the scene the camera belongs to
  68629. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68630. */
  68631. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68632. /**
  68633. * Gets the position in front of the camera at a given distance.
  68634. * @param distance The distance from the camera we want the position to be
  68635. * @returns the position
  68636. */
  68637. getFrontPosition(distance: number): Vector3;
  68638. /** @hidden */
  68639. _getLockedTargetPosition(): Nullable<Vector3>;
  68640. private _storedPosition;
  68641. private _storedRotation;
  68642. private _storedRotationQuaternion;
  68643. /**
  68644. * Store current camera state of the camera (fov, position, rotation, etc..)
  68645. * @returns the camera
  68646. */
  68647. storeState(): Camera;
  68648. /**
  68649. * Restored camera state. You must call storeState() first
  68650. * @returns whether it was successful or not
  68651. * @hidden
  68652. */
  68653. _restoreStateValues(): boolean;
  68654. /** @hidden */
  68655. _initCache(): void;
  68656. /** @hidden */
  68657. _updateCache(ignoreParentClass?: boolean): void;
  68658. /** @hidden */
  68659. _isSynchronizedViewMatrix(): boolean;
  68660. /** @hidden */
  68661. _computeLocalCameraSpeed(): number;
  68662. /**
  68663. * Defines the target the camera should look at.
  68664. * This will automatically adapt alpha beta and radius to fit within the new target.
  68665. * @param target Defines the new target as a Vector or a mesh
  68666. */
  68667. setTarget(target: Vector3): void;
  68668. /**
  68669. * Return the current target position of the camera. This value is expressed in local space.
  68670. * @returns the target position
  68671. */
  68672. getTarget(): Vector3;
  68673. /** @hidden */
  68674. _decideIfNeedsToMove(): boolean;
  68675. /** @hidden */
  68676. _updatePosition(): void;
  68677. /** @hidden */
  68678. _checkInputs(): void;
  68679. protected _updateCameraRotationMatrix(): void;
  68680. /**
  68681. * 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)
  68682. * @returns the current camera
  68683. */
  68684. private _rotateUpVectorWithCameraRotationMatrix;
  68685. private _cachedRotationZ;
  68686. private _cachedQuaternionRotationZ;
  68687. /** @hidden */
  68688. _getViewMatrix(): Matrix;
  68689. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68690. /**
  68691. * @hidden
  68692. */
  68693. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68694. /**
  68695. * @hidden
  68696. */
  68697. _updateRigCameras(): void;
  68698. private _getRigCamPositionAndTarget;
  68699. /**
  68700. * Gets the current object class name.
  68701. * @return the class name
  68702. */
  68703. getClassName(): string;
  68704. }
  68705. }
  68706. declare module BABYLON {
  68707. /**
  68708. * @ignore
  68709. * This is a list of all the different input types that are available in the application.
  68710. * Fo instance: ArcRotateCameraGamepadInput...
  68711. */
  68712. export var CameraInputTypes: {};
  68713. /**
  68714. * This is the contract to implement in order to create a new input class.
  68715. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68716. */
  68717. export interface ICameraInput<TCamera extends Camera> {
  68718. /**
  68719. * Defines the camera the input is attached to.
  68720. */
  68721. camera: Nullable<TCamera>;
  68722. /**
  68723. * Gets the class name of the current intput.
  68724. * @returns the class name
  68725. */
  68726. getClassName(): string;
  68727. /**
  68728. * Get the friendly name associated with the input class.
  68729. * @returns the input friendly name
  68730. */
  68731. getSimpleName(): string;
  68732. /**
  68733. * Attach the input controls to a specific dom element to get the input from.
  68734. * @param element Defines the element the controls should be listened from
  68735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68736. */
  68737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68738. /**
  68739. * Detach the current controls from the specified dom element.
  68740. * @param element Defines the element to stop listening the inputs from
  68741. */
  68742. detachControl(element: Nullable<HTMLElement>): void;
  68743. /**
  68744. * Update the current camera state depending on the inputs that have been used this frame.
  68745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68746. */
  68747. checkInputs?: () => void;
  68748. }
  68749. /**
  68750. * Represents a map of input types to input instance or input index to input instance.
  68751. */
  68752. export interface CameraInputsMap<TCamera extends Camera> {
  68753. /**
  68754. * Accessor to the input by input type.
  68755. */
  68756. [name: string]: ICameraInput<TCamera>;
  68757. /**
  68758. * Accessor to the input by input index.
  68759. */
  68760. [idx: number]: ICameraInput<TCamera>;
  68761. }
  68762. /**
  68763. * This represents the input manager used within a camera.
  68764. * It helps dealing with all the different kind of input attached to a camera.
  68765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68766. */
  68767. export class CameraInputsManager<TCamera extends Camera> {
  68768. /**
  68769. * Defines the list of inputs attahed to the camera.
  68770. */
  68771. attached: CameraInputsMap<TCamera>;
  68772. /**
  68773. * Defines the dom element the camera is collecting inputs from.
  68774. * This is null if the controls have not been attached.
  68775. */
  68776. attachedElement: Nullable<HTMLElement>;
  68777. /**
  68778. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68779. */
  68780. noPreventDefault: boolean;
  68781. /**
  68782. * Defined the camera the input manager belongs to.
  68783. */
  68784. camera: TCamera;
  68785. /**
  68786. * Update the current camera state depending on the inputs that have been used this frame.
  68787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68788. */
  68789. checkInputs: () => void;
  68790. /**
  68791. * Instantiate a new Camera Input Manager.
  68792. * @param camera Defines the camera the input manager blongs to
  68793. */
  68794. constructor(camera: TCamera);
  68795. /**
  68796. * Add an input method to a camera
  68797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68798. * @param input camera input method
  68799. */
  68800. add(input: ICameraInput<TCamera>): void;
  68801. /**
  68802. * Remove a specific input method from a camera
  68803. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68804. * @param inputToRemove camera input method
  68805. */
  68806. remove(inputToRemove: ICameraInput<TCamera>): void;
  68807. /**
  68808. * Remove a specific input type from a camera
  68809. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68810. * @param inputType the type of the input to remove
  68811. */
  68812. removeByType(inputType: string): void;
  68813. private _addCheckInputs;
  68814. /**
  68815. * Attach the input controls to the currently attached dom element to listen the events from.
  68816. * @param input Defines the input to attach
  68817. */
  68818. attachInput(input: ICameraInput<TCamera>): void;
  68819. /**
  68820. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68821. * @param element Defines the dom element to collect the events from
  68822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68823. */
  68824. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68825. /**
  68826. * Detach the current manager inputs controls from a specific dom element.
  68827. * @param element Defines the dom element to collect the events from
  68828. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68829. */
  68830. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68831. /**
  68832. * Rebuild the dynamic inputCheck function from the current list of
  68833. * defined inputs in the manager.
  68834. */
  68835. rebuildInputCheck(): void;
  68836. /**
  68837. * Remove all attached input methods from a camera
  68838. */
  68839. clear(): void;
  68840. /**
  68841. * Serialize the current input manager attached to a camera.
  68842. * This ensures than once parsed,
  68843. * the input associated to the camera will be identical to the current ones
  68844. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68845. */
  68846. serialize(serializedCamera: any): void;
  68847. /**
  68848. * Parses an input manager serialized JSON to restore the previous list of inputs
  68849. * and states associated to a camera.
  68850. * @param parsedCamera Defines the JSON to parse
  68851. */
  68852. parse(parsedCamera: any): void;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * Gather the list of keyboard event types as constants.
  68858. */
  68859. export class KeyboardEventTypes {
  68860. /**
  68861. * The keydown event is fired when a key becomes active (pressed).
  68862. */
  68863. static readonly KEYDOWN: number;
  68864. /**
  68865. * The keyup event is fired when a key has been released.
  68866. */
  68867. static readonly KEYUP: number;
  68868. }
  68869. /**
  68870. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68871. */
  68872. export class KeyboardInfo {
  68873. /**
  68874. * Defines the type of event (KeyboardEventTypes)
  68875. */
  68876. type: number;
  68877. /**
  68878. * Defines the related dom event
  68879. */
  68880. event: KeyboardEvent;
  68881. /**
  68882. * Instantiates a new keyboard info.
  68883. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68884. * @param type Defines the type of event (KeyboardEventTypes)
  68885. * @param event Defines the related dom event
  68886. */
  68887. constructor(
  68888. /**
  68889. * Defines the type of event (KeyboardEventTypes)
  68890. */
  68891. type: number,
  68892. /**
  68893. * Defines the related dom event
  68894. */
  68895. event: KeyboardEvent);
  68896. }
  68897. /**
  68898. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68899. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68900. */
  68901. export class KeyboardInfoPre extends KeyboardInfo {
  68902. /**
  68903. * Defines the type of event (KeyboardEventTypes)
  68904. */
  68905. type: number;
  68906. /**
  68907. * Defines the related dom event
  68908. */
  68909. event: KeyboardEvent;
  68910. /**
  68911. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68912. */
  68913. skipOnPointerObservable: boolean;
  68914. /**
  68915. * Instantiates a new keyboard pre info.
  68916. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68917. * @param type Defines the type of event (KeyboardEventTypes)
  68918. * @param event Defines the related dom event
  68919. */
  68920. constructor(
  68921. /**
  68922. * Defines the type of event (KeyboardEventTypes)
  68923. */
  68924. type: number,
  68925. /**
  68926. * Defines the related dom event
  68927. */
  68928. event: KeyboardEvent);
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * Manage the keyboard inputs to control the movement of a free camera.
  68934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68935. */
  68936. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68937. /**
  68938. * Defines the camera the input is attached to.
  68939. */
  68940. camera: FreeCamera;
  68941. /**
  68942. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68943. */
  68944. keysUp: number[];
  68945. /**
  68946. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68947. */
  68948. keysDown: number[];
  68949. /**
  68950. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68951. */
  68952. keysLeft: number[];
  68953. /**
  68954. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68955. */
  68956. keysRight: number[];
  68957. private _keys;
  68958. private _onCanvasBlurObserver;
  68959. private _onKeyboardObserver;
  68960. private _engine;
  68961. private _scene;
  68962. /**
  68963. * Attach the input controls to a specific dom element to get the input from.
  68964. * @param element Defines the element the controls should be listened from
  68965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68966. */
  68967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68968. /**
  68969. * Detach the current controls from the specified dom element.
  68970. * @param element Defines the element to stop listening the inputs from
  68971. */
  68972. detachControl(element: Nullable<HTMLElement>): void;
  68973. /**
  68974. * Update the current camera state depending on the inputs that have been used this frame.
  68975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68976. */
  68977. checkInputs(): void;
  68978. /**
  68979. * Gets the class name of the current intput.
  68980. * @returns the class name
  68981. */
  68982. getClassName(): string;
  68983. /** @hidden */
  68984. _onLostFocus(): void;
  68985. /**
  68986. * Get the friendly name associated with the input class.
  68987. * @returns the input friendly name
  68988. */
  68989. getSimpleName(): string;
  68990. }
  68991. }
  68992. declare module BABYLON {
  68993. /**
  68994. * Interface describing all the common properties and methods a shadow light needs to implement.
  68995. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68996. * as well as binding the different shadow properties to the effects.
  68997. */
  68998. export interface IShadowLight extends Light {
  68999. /**
  69000. * The light id in the scene (used in scene.findLighById for instance)
  69001. */
  69002. id: string;
  69003. /**
  69004. * The position the shdow will be casted from.
  69005. */
  69006. position: Vector3;
  69007. /**
  69008. * In 2d mode (needCube being false), the direction used to cast the shadow.
  69009. */
  69010. direction: Vector3;
  69011. /**
  69012. * The transformed position. Position of the light in world space taking parenting in account.
  69013. */
  69014. transformedPosition: Vector3;
  69015. /**
  69016. * The transformed direction. Direction of the light in world space taking parenting in account.
  69017. */
  69018. transformedDirection: Vector3;
  69019. /**
  69020. * The friendly name of the light in the scene.
  69021. */
  69022. name: string;
  69023. /**
  69024. * Defines the shadow projection clipping minimum z value.
  69025. */
  69026. shadowMinZ: number;
  69027. /**
  69028. * Defines the shadow projection clipping maximum z value.
  69029. */
  69030. shadowMaxZ: number;
  69031. /**
  69032. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69033. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69034. */
  69035. computeTransformedInformation(): boolean;
  69036. /**
  69037. * Gets the scene the light belongs to.
  69038. * @returns The scene
  69039. */
  69040. getScene(): Scene;
  69041. /**
  69042. * Callback defining a custom Projection Matrix Builder.
  69043. * This can be used to override the default projection matrix computation.
  69044. */
  69045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69046. /**
  69047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69048. * @param matrix The materix to updated with the projection information
  69049. * @param viewMatrix The transform matrix of the light
  69050. * @param renderList The list of mesh to render in the map
  69051. * @returns The current light
  69052. */
  69053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69054. /**
  69055. * Gets the current depth scale used in ESM.
  69056. * @returns The scale
  69057. */
  69058. getDepthScale(): number;
  69059. /**
  69060. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69061. * @returns true if a cube texture needs to be use
  69062. */
  69063. needCube(): boolean;
  69064. /**
  69065. * Detects if the projection matrix requires to be recomputed this frame.
  69066. * @returns true if it requires to be recomputed otherwise, false.
  69067. */
  69068. needProjectionMatrixCompute(): boolean;
  69069. /**
  69070. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69071. */
  69072. forceProjectionMatrixCompute(): void;
  69073. /**
  69074. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69075. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69076. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69077. */
  69078. getShadowDirection(faceIndex?: number): Vector3;
  69079. /**
  69080. * Gets the minZ used for shadow according to both the scene and the light.
  69081. * @param activeCamera The camera we are returning the min for
  69082. * @returns the depth min z
  69083. */
  69084. getDepthMinZ(activeCamera: Camera): number;
  69085. /**
  69086. * Gets the maxZ used for shadow according to both the scene and the light.
  69087. * @param activeCamera The camera we are returning the max for
  69088. * @returns the depth max z
  69089. */
  69090. getDepthMaxZ(activeCamera: Camera): number;
  69091. }
  69092. /**
  69093. * Base implementation IShadowLight
  69094. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  69095. */
  69096. export abstract class ShadowLight extends Light implements IShadowLight {
  69097. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  69098. protected _position: Vector3;
  69099. protected _setPosition(value: Vector3): void;
  69100. /**
  69101. * Sets the position the shadow will be casted from. Also use as the light position for both
  69102. * point and spot lights.
  69103. */
  69104. /**
  69105. * Sets the position the shadow will be casted from. Also use as the light position for both
  69106. * point and spot lights.
  69107. */
  69108. position: Vector3;
  69109. protected _direction: Vector3;
  69110. protected _setDirection(value: Vector3): void;
  69111. /**
  69112. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  69113. * Also use as the light direction on spot and directional lights.
  69114. */
  69115. /**
  69116. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  69117. * Also use as the light direction on spot and directional lights.
  69118. */
  69119. direction: Vector3;
  69120. private _shadowMinZ;
  69121. /**
  69122. * Gets the shadow projection clipping minimum z value.
  69123. */
  69124. /**
  69125. * Sets the shadow projection clipping minimum z value.
  69126. */
  69127. shadowMinZ: number;
  69128. private _shadowMaxZ;
  69129. /**
  69130. * Sets the shadow projection clipping maximum z value.
  69131. */
  69132. /**
  69133. * Gets the shadow projection clipping maximum z value.
  69134. */
  69135. shadowMaxZ: number;
  69136. /**
  69137. * Callback defining a custom Projection Matrix Builder.
  69138. * This can be used to override the default projection matrix computation.
  69139. */
  69140. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  69141. /**
  69142. * The transformed position. Position of the light in world space taking parenting in account.
  69143. */
  69144. transformedPosition: Vector3;
  69145. /**
  69146. * The transformed direction. Direction of the light in world space taking parenting in account.
  69147. */
  69148. transformedDirection: Vector3;
  69149. private _needProjectionMatrixCompute;
  69150. /**
  69151. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  69152. * @returns true if the information has been computed, false if it does not need to (no parenting)
  69153. */
  69154. computeTransformedInformation(): boolean;
  69155. /**
  69156. * Return the depth scale used for the shadow map.
  69157. * @returns the depth scale.
  69158. */
  69159. getDepthScale(): number;
  69160. /**
  69161. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  69162. * @param faceIndex The index of the face we are computed the direction to generate shadow
  69163. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  69164. */
  69165. getShadowDirection(faceIndex?: number): Vector3;
  69166. /**
  69167. * Returns the ShadowLight absolute position in the World.
  69168. * @returns the position vector in world space
  69169. */
  69170. getAbsolutePosition(): Vector3;
  69171. /**
  69172. * Sets the ShadowLight direction toward the passed target.
  69173. * @param target The point to target in local space
  69174. * @returns the updated ShadowLight direction
  69175. */
  69176. setDirectionToTarget(target: Vector3): Vector3;
  69177. /**
  69178. * Returns the light rotation in euler definition.
  69179. * @returns the x y z rotation in local space.
  69180. */
  69181. getRotation(): Vector3;
  69182. /**
  69183. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  69184. * @returns true if a cube texture needs to be use
  69185. */
  69186. needCube(): boolean;
  69187. /**
  69188. * Detects if the projection matrix requires to be recomputed this frame.
  69189. * @returns true if it requires to be recomputed otherwise, false.
  69190. */
  69191. needProjectionMatrixCompute(): boolean;
  69192. /**
  69193. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  69194. */
  69195. forceProjectionMatrixCompute(): void;
  69196. /** @hidden */
  69197. _initCache(): void;
  69198. /** @hidden */
  69199. _isSynchronized(): boolean;
  69200. /**
  69201. * Computes the world matrix of the node
  69202. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69203. * @returns the world matrix
  69204. */
  69205. computeWorldMatrix(force?: boolean): Matrix;
  69206. /**
  69207. * Gets the minZ used for shadow according to both the scene and the light.
  69208. * @param activeCamera The camera we are returning the min for
  69209. * @returns the depth min z
  69210. */
  69211. getDepthMinZ(activeCamera: Camera): number;
  69212. /**
  69213. * Gets the maxZ used for shadow according to both the scene and the light.
  69214. * @param activeCamera The camera we are returning the max for
  69215. * @returns the depth max z
  69216. */
  69217. getDepthMaxZ(activeCamera: Camera): number;
  69218. /**
  69219. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  69220. * @param matrix The materix to updated with the projection information
  69221. * @param viewMatrix The transform matrix of the light
  69222. * @param renderList The list of mesh to render in the map
  69223. * @returns The current light
  69224. */
  69225. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  69226. }
  69227. }
  69228. declare module BABYLON {
  69229. /**
  69230. * "Static Class" containing the most commonly used helper while dealing with material for
  69231. * rendering purpose.
  69232. *
  69233. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  69234. *
  69235. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  69236. */
  69237. export class MaterialHelper {
  69238. /**
  69239. * Bind the current view position to an effect.
  69240. * @param effect The effect to be bound
  69241. * @param scene The scene the eyes position is used from
  69242. */
  69243. static BindEyePosition(effect: Effect, scene: Scene): void;
  69244. /**
  69245. * Helps preparing the defines values about the UVs in used in the effect.
  69246. * UVs are shared as much as we can accross channels in the shaders.
  69247. * @param texture The texture we are preparing the UVs for
  69248. * @param defines The defines to update
  69249. * @param key The channel key "diffuse", "specular"... used in the shader
  69250. */
  69251. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  69252. /**
  69253. * Binds a texture matrix value to its corrsponding uniform
  69254. * @param texture The texture to bind the matrix for
  69255. * @param uniformBuffer The uniform buffer receivin the data
  69256. * @param key The channel key "diffuse", "specular"... used in the shader
  69257. */
  69258. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  69259. /**
  69260. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  69261. * @param mesh defines the current mesh
  69262. * @param scene defines the current scene
  69263. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  69264. * @param pointsCloud defines if point cloud rendering has to be turned on
  69265. * @param fogEnabled defines if fog has to be turned on
  69266. * @param alphaTest defines if alpha testing has to be turned on
  69267. * @param defines defines the current list of defines
  69268. */
  69269. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  69270. /**
  69271. * Helper used to prepare the list of defines associated with frame values for shader compilation
  69272. * @param scene defines the current scene
  69273. * @param engine defines the current engine
  69274. * @param defines specifies the list of active defines
  69275. * @param useInstances defines if instances have to be turned on
  69276. * @param useClipPlane defines if clip plane have to be turned on
  69277. */
  69278. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  69279. /**
  69280. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  69281. * @param mesh The mesh containing the geometry data we will draw
  69282. * @param defines The defines to update
  69283. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  69284. * @param useBones Precise whether bones should be used or not (override mesh info)
  69285. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  69286. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  69287. * @returns false if defines are considered not dirty and have not been checked
  69288. */
  69289. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  69290. /**
  69291. * Prepares the defines related to multiview
  69292. * @param scene The scene we are intending to draw
  69293. * @param defines The defines to update
  69294. */
  69295. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  69296. /**
  69297. * Prepares the defines related to the light information passed in parameter
  69298. * @param scene The scene we are intending to draw
  69299. * @param mesh The mesh the effect is compiling for
  69300. * @param defines The defines to update
  69301. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  69302. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  69303. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  69304. * @returns true if normals will be required for the rest of the effect
  69305. */
  69306. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  69307. /**
  69308. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  69309. * that won t be acctive due to defines being turned off.
  69310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  69311. * @param samplersList The samplers list
  69312. * @param defines The defines helping in the list generation
  69313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  69314. */
  69315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  69316. /**
  69317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  69318. * @param defines The defines to update while falling back
  69319. * @param fallbacks The authorized effect fallbacks
  69320. * @param maxSimultaneousLights The maximum number of lights allowed
  69321. * @param rank the current rank of the Effect
  69322. * @returns The newly affected rank
  69323. */
  69324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  69325. /**
  69326. * Prepares the list of attributes required for morph targets according to the effect defines.
  69327. * @param attribs The current list of supported attribs
  69328. * @param mesh The mesh to prepare the morph targets attributes for
  69329. * @param defines The current Defines of the effect
  69330. */
  69331. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  69332. /**
  69333. * Prepares the list of attributes required for bones according to the effect defines.
  69334. * @param attribs The current list of supported attribs
  69335. * @param mesh The mesh to prepare the bones attributes for
  69336. * @param defines The current Defines of the effect
  69337. * @param fallbacks The current efffect fallback strategy
  69338. */
  69339. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  69340. /**
  69341. * Prepares the list of attributes required for instances according to the effect defines.
  69342. * @param attribs The current list of supported attribs
  69343. * @param defines The current Defines of the effect
  69344. */
  69345. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  69346. /**
  69347. * Binds the light shadow information to the effect for the given mesh.
  69348. * @param light The light containing the generator
  69349. * @param scene The scene the lights belongs to
  69350. * @param mesh The mesh we are binding the information to render
  69351. * @param lightIndex The light index in the effect used to render the mesh
  69352. * @param effect The effect we are binding the data to
  69353. */
  69354. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  69355. /**
  69356. * Binds the light information to the effect.
  69357. * @param light The light containing the generator
  69358. * @param effect The effect we are binding the data to
  69359. * @param lightIndex The light index in the effect used to render
  69360. */
  69361. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  69362. /**
  69363. * Binds the lights information from the scene to the effect for the given mesh.
  69364. * @param scene The scene the lights belongs to
  69365. * @param mesh The mesh we are binding the information to render
  69366. * @param effect The effect we are binding the data to
  69367. * @param defines The generated defines for the effect
  69368. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  69369. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  69370. */
  69371. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  69372. private static _tempFogColor;
  69373. /**
  69374. * Binds the fog information from the scene to the effect for the given mesh.
  69375. * @param scene The scene the lights belongs to
  69376. * @param mesh The mesh we are binding the information to render
  69377. * @param effect The effect we are binding the data to
  69378. * @param linearSpace Defines if the fog effect is applied in linear space
  69379. */
  69380. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  69381. /**
  69382. * Binds the bones information from the mesh to the effect.
  69383. * @param mesh The mesh we are binding the information to render
  69384. * @param effect The effect we are binding the data to
  69385. */
  69386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  69387. /**
  69388. * Binds the morph targets information from the mesh to the effect.
  69389. * @param abstractMesh The mesh we are binding the information to render
  69390. * @param effect The effect we are binding the data to
  69391. */
  69392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  69393. /**
  69394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  69395. * @param defines The generated defines used in the effect
  69396. * @param effect The effect we are binding the data to
  69397. * @param scene The scene we are willing to render with logarithmic scale for
  69398. */
  69399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  69400. /**
  69401. * Binds the clip plane information from the scene to the effect.
  69402. * @param scene The scene the clip plane information are extracted from
  69403. * @param effect The effect we are binding the data to
  69404. */
  69405. static BindClipPlane(effect: Effect, scene: Scene): void;
  69406. }
  69407. }
  69408. declare module BABYLON {
  69409. /** @hidden */
  69410. export var kernelBlurVaryingDeclaration: {
  69411. name: string;
  69412. shader: string;
  69413. };
  69414. }
  69415. declare module BABYLON {
  69416. /** @hidden */
  69417. export var kernelBlurFragment: {
  69418. name: string;
  69419. shader: string;
  69420. };
  69421. }
  69422. declare module BABYLON {
  69423. /** @hidden */
  69424. export var kernelBlurFragment2: {
  69425. name: string;
  69426. shader: string;
  69427. };
  69428. }
  69429. declare module BABYLON {
  69430. /** @hidden */
  69431. export var kernelBlurPixelShader: {
  69432. name: string;
  69433. shader: string;
  69434. };
  69435. }
  69436. declare module BABYLON {
  69437. /** @hidden */
  69438. export var kernelBlurVertex: {
  69439. name: string;
  69440. shader: string;
  69441. };
  69442. }
  69443. declare module BABYLON {
  69444. /** @hidden */
  69445. export var kernelBlurVertexShader: {
  69446. name: string;
  69447. shader: string;
  69448. };
  69449. }
  69450. declare module BABYLON {
  69451. /**
  69452. * The Blur Post Process which blurs an image based on a kernel and direction.
  69453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  69454. */
  69455. export class BlurPostProcess extends PostProcess {
  69456. /** The direction in which to blur the image. */
  69457. direction: Vector2;
  69458. private blockCompilation;
  69459. protected _kernel: number;
  69460. protected _idealKernel: number;
  69461. protected _packedFloat: boolean;
  69462. private _staticDefines;
  69463. /**
  69464. * Sets the length in pixels of the blur sample region
  69465. */
  69466. /**
  69467. * Gets the length in pixels of the blur sample region
  69468. */
  69469. kernel: number;
  69470. /**
  69471. * Sets wether or not the blur needs to unpack/repack floats
  69472. */
  69473. /**
  69474. * Gets wether or not the blur is unpacking/repacking floats
  69475. */
  69476. packedFloat: boolean;
  69477. /**
  69478. * Creates a new instance BlurPostProcess
  69479. * @param name The name of the effect.
  69480. * @param direction The direction in which to blur the image.
  69481. * @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.
  69482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  69483. * @param camera The camera to apply the render pass to.
  69484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69485. * @param engine The engine which the post process will be applied. (default: current engine)
  69486. * @param reusable If the post process can be reused on the same frame. (default: false)
  69487. * @param textureType Type of textures used when performing the post process. (default: 0)
  69488. * @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)
  69489. */
  69490. constructor(name: string,
  69491. /** The direction in which to blur the image. */
  69492. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  69493. /**
  69494. * Updates the effect with the current post process compile time values and recompiles the shader.
  69495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69498. * @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
  69499. * @param onCompiled Called when the shader has been compiled.
  69500. * @param onError Called if there is an error when compiling a shader.
  69501. */
  69502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69503. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69504. /**
  69505. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  69506. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  69507. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  69508. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  69509. * The gaps between physical kernels are compensated for in the weighting of the samples
  69510. * @param idealKernel Ideal blur kernel.
  69511. * @return Nearest best kernel.
  69512. */
  69513. protected _nearestBestKernel(idealKernel: number): number;
  69514. /**
  69515. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  69516. * @param x The point on the Gaussian distribution to sample.
  69517. * @return the value of the Gaussian function at x.
  69518. */
  69519. protected _gaussianWeight(x: number): number;
  69520. /**
  69521. * Generates a string that can be used as a floating point number in GLSL.
  69522. * @param x Value to print.
  69523. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  69524. * @return GLSL float string.
  69525. */
  69526. protected _glslFloat(x: number, decimalFigures?: number): string;
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /** @hidden */
  69531. export var shadowMapPixelShader: {
  69532. name: string;
  69533. shader: string;
  69534. };
  69535. }
  69536. declare module BABYLON {
  69537. /** @hidden */
  69538. export var bonesDeclaration: {
  69539. name: string;
  69540. shader: string;
  69541. };
  69542. }
  69543. declare module BABYLON {
  69544. /** @hidden */
  69545. export var morphTargetsVertexGlobalDeclaration: {
  69546. name: string;
  69547. shader: string;
  69548. };
  69549. }
  69550. declare module BABYLON {
  69551. /** @hidden */
  69552. export var morphTargetsVertexDeclaration: {
  69553. name: string;
  69554. shader: string;
  69555. };
  69556. }
  69557. declare module BABYLON {
  69558. /** @hidden */
  69559. export var instancesDeclaration: {
  69560. name: string;
  69561. shader: string;
  69562. };
  69563. }
  69564. declare module BABYLON {
  69565. /** @hidden */
  69566. export var helperFunctions: {
  69567. name: string;
  69568. shader: string;
  69569. };
  69570. }
  69571. declare module BABYLON {
  69572. /** @hidden */
  69573. export var morphTargetsVertex: {
  69574. name: string;
  69575. shader: string;
  69576. };
  69577. }
  69578. declare module BABYLON {
  69579. /** @hidden */
  69580. export var instancesVertex: {
  69581. name: string;
  69582. shader: string;
  69583. };
  69584. }
  69585. declare module BABYLON {
  69586. /** @hidden */
  69587. export var bonesVertex: {
  69588. name: string;
  69589. shader: string;
  69590. };
  69591. }
  69592. declare module BABYLON {
  69593. /** @hidden */
  69594. export var shadowMapVertexShader: {
  69595. name: string;
  69596. shader: string;
  69597. };
  69598. }
  69599. declare module BABYLON {
  69600. /** @hidden */
  69601. export var depthBoxBlurPixelShader: {
  69602. name: string;
  69603. shader: string;
  69604. };
  69605. }
  69606. declare module BABYLON {
  69607. /**
  69608. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69609. */
  69610. export interface ICustomShaderOptions {
  69611. /**
  69612. * Gets or sets the custom shader name to use
  69613. */
  69614. shaderName: string;
  69615. /**
  69616. * The list of attribute names used in the shader
  69617. */
  69618. attributes?: string[];
  69619. /**
  69620. * The list of unifrom names used in the shader
  69621. */
  69622. uniforms?: string[];
  69623. /**
  69624. * The list of sampler names used in the shader
  69625. */
  69626. samplers?: string[];
  69627. /**
  69628. * The list of defines used in the shader
  69629. */
  69630. defines?: string[];
  69631. }
  69632. /**
  69633. * Interface to implement to create a shadow generator compatible with BJS.
  69634. */
  69635. export interface IShadowGenerator {
  69636. /**
  69637. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69638. * @returns The render target texture if present otherwise, null
  69639. */
  69640. getShadowMap(): Nullable<RenderTargetTexture>;
  69641. /**
  69642. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69643. * @returns The render target texture if the shadow map is present otherwise, null
  69644. */
  69645. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69646. /**
  69647. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69648. * @param subMesh The submesh we want to render in the shadow map
  69649. * @param useInstances Defines wether will draw in the map using instances
  69650. * @returns true if ready otherwise, false
  69651. */
  69652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69653. /**
  69654. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69655. * @param defines Defines of the material we want to update
  69656. * @param lightIndex Index of the light in the enabled light list of the material
  69657. */
  69658. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69659. /**
  69660. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69661. * defined in the generator but impacting the effect).
  69662. * It implies the unifroms available on the materials are the standard BJS ones.
  69663. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69664. * @param effect The effect we are binfing the information for
  69665. */
  69666. bindShadowLight(lightIndex: string, effect: Effect): void;
  69667. /**
  69668. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69669. * (eq to shadow prjection matrix * light transform matrix)
  69670. * @returns The transform matrix used to create the shadow map
  69671. */
  69672. getTransformMatrix(): Matrix;
  69673. /**
  69674. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69675. * Cube and 2D textures for instance.
  69676. */
  69677. recreateShadowMap(): void;
  69678. /**
  69679. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69680. * @param onCompiled Callback triggered at the and of the effects compilation
  69681. * @param options Sets of optional options forcing the compilation with different modes
  69682. */
  69683. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69684. useInstances: boolean;
  69685. }>): void;
  69686. /**
  69687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69688. * @param options Sets of optional options forcing the compilation with different modes
  69689. * @returns A promise that resolves when the compilation completes
  69690. */
  69691. forceCompilationAsync(options?: Partial<{
  69692. useInstances: boolean;
  69693. }>): Promise<void>;
  69694. /**
  69695. * Serializes the shadow generator setup to a json object.
  69696. * @returns The serialized JSON object
  69697. */
  69698. serialize(): any;
  69699. /**
  69700. * Disposes the Shadow map and related Textures and effects.
  69701. */
  69702. dispose(): void;
  69703. }
  69704. /**
  69705. * Default implementation IShadowGenerator.
  69706. * This is the main object responsible of generating shadows in the framework.
  69707. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69708. */
  69709. export class ShadowGenerator implements IShadowGenerator {
  69710. /**
  69711. * Shadow generator mode None: no filtering applied.
  69712. */
  69713. static readonly FILTER_NONE: number;
  69714. /**
  69715. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69717. */
  69718. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69719. /**
  69720. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69721. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69722. */
  69723. static readonly FILTER_POISSONSAMPLING: number;
  69724. /**
  69725. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69727. */
  69728. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69729. /**
  69730. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69731. * edge artifacts on steep falloff.
  69732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69733. */
  69734. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69735. /**
  69736. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69737. * edge artifacts on steep falloff.
  69738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69739. */
  69740. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69741. /**
  69742. * Shadow generator mode PCF: Percentage Closer Filtering
  69743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69744. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69745. */
  69746. static readonly FILTER_PCF: number;
  69747. /**
  69748. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69749. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69750. * Contact Hardening
  69751. */
  69752. static readonly FILTER_PCSS: number;
  69753. /**
  69754. * Reserved for PCF and PCSS
  69755. * Highest Quality.
  69756. *
  69757. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69758. *
  69759. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69760. */
  69761. static readonly QUALITY_HIGH: number;
  69762. /**
  69763. * Reserved for PCF and PCSS
  69764. * Good tradeoff for quality/perf cross devices
  69765. *
  69766. * Execute PCF on a 3*3 kernel.
  69767. *
  69768. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69769. */
  69770. static readonly QUALITY_MEDIUM: number;
  69771. /**
  69772. * Reserved for PCF and PCSS
  69773. * The lowest quality but the fastest.
  69774. *
  69775. * Execute PCF on a 1*1 kernel.
  69776. *
  69777. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69778. */
  69779. static readonly QUALITY_LOW: number;
  69780. /** Gets or sets the custom shader name to use */
  69781. customShaderOptions: ICustomShaderOptions;
  69782. /**
  69783. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69784. */
  69785. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69786. /**
  69787. * Observable triggered before a mesh is rendered in the shadow map.
  69788. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69789. */
  69790. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69791. private _bias;
  69792. /**
  69793. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69794. */
  69795. /**
  69796. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69797. */
  69798. bias: number;
  69799. private _normalBias;
  69800. /**
  69801. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69802. */
  69803. /**
  69804. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69805. */
  69806. normalBias: number;
  69807. private _blurBoxOffset;
  69808. /**
  69809. * Gets the blur box offset: offset applied during the blur pass.
  69810. * Only useful if useKernelBlur = false
  69811. */
  69812. /**
  69813. * Sets the blur box offset: offset applied during the blur pass.
  69814. * Only useful if useKernelBlur = false
  69815. */
  69816. blurBoxOffset: number;
  69817. private _blurScale;
  69818. /**
  69819. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69820. * 2 means half of the size.
  69821. */
  69822. /**
  69823. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69824. * 2 means half of the size.
  69825. */
  69826. blurScale: number;
  69827. private _blurKernel;
  69828. /**
  69829. * Gets the blur kernel: kernel size of the blur pass.
  69830. * Only useful if useKernelBlur = true
  69831. */
  69832. /**
  69833. * Sets the blur kernel: kernel size of the blur pass.
  69834. * Only useful if useKernelBlur = true
  69835. */
  69836. blurKernel: number;
  69837. private _useKernelBlur;
  69838. /**
  69839. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69840. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69841. */
  69842. /**
  69843. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69844. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69845. */
  69846. useKernelBlur: boolean;
  69847. private _depthScale;
  69848. /**
  69849. * Gets the depth scale used in ESM mode.
  69850. */
  69851. /**
  69852. * Sets the depth scale used in ESM mode.
  69853. * This can override the scale stored on the light.
  69854. */
  69855. depthScale: number;
  69856. private _filter;
  69857. /**
  69858. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69859. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69860. */
  69861. /**
  69862. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69863. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69864. */
  69865. filter: number;
  69866. /**
  69867. * Gets if the current filter is set to Poisson Sampling.
  69868. */
  69869. /**
  69870. * Sets the current filter to Poisson Sampling.
  69871. */
  69872. usePoissonSampling: boolean;
  69873. /**
  69874. * Gets if the current filter is set to ESM.
  69875. */
  69876. /**
  69877. * Sets the current filter is to ESM.
  69878. */
  69879. useExponentialShadowMap: boolean;
  69880. /**
  69881. * Gets if the current filter is set to filtered ESM.
  69882. */
  69883. /**
  69884. * Gets if the current filter is set to filtered ESM.
  69885. */
  69886. useBlurExponentialShadowMap: boolean;
  69887. /**
  69888. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69889. * exponential to prevent steep falloff artifacts).
  69890. */
  69891. /**
  69892. * Sets the current filter to "close ESM" (using the inverse of the
  69893. * exponential to prevent steep falloff artifacts).
  69894. */
  69895. useCloseExponentialShadowMap: boolean;
  69896. /**
  69897. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69898. * exponential to prevent steep falloff artifacts).
  69899. */
  69900. /**
  69901. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69902. * exponential to prevent steep falloff artifacts).
  69903. */
  69904. useBlurCloseExponentialShadowMap: boolean;
  69905. /**
  69906. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69907. */
  69908. /**
  69909. * Sets the current filter to "PCF" (percentage closer filtering).
  69910. */
  69911. usePercentageCloserFiltering: boolean;
  69912. private _filteringQuality;
  69913. /**
  69914. * Gets the PCF or PCSS Quality.
  69915. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69916. */
  69917. /**
  69918. * Sets the PCF or PCSS Quality.
  69919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69920. */
  69921. filteringQuality: number;
  69922. /**
  69923. * Gets if the current filter is set to "PCSS" (contact hardening).
  69924. */
  69925. /**
  69926. * Sets the current filter to "PCSS" (contact hardening).
  69927. */
  69928. useContactHardeningShadow: boolean;
  69929. private _contactHardeningLightSizeUVRatio;
  69930. /**
  69931. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69932. * Using a ratio helps keeping shape stability independently of the map size.
  69933. *
  69934. * It does not account for the light projection as it was having too much
  69935. * instability during the light setup or during light position changes.
  69936. *
  69937. * Only valid if useContactHardeningShadow is true.
  69938. */
  69939. /**
  69940. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69941. * Using a ratio helps keeping shape stability independently of the map size.
  69942. *
  69943. * It does not account for the light projection as it was having too much
  69944. * instability during the light setup or during light position changes.
  69945. *
  69946. * Only valid if useContactHardeningShadow is true.
  69947. */
  69948. contactHardeningLightSizeUVRatio: number;
  69949. private _darkness;
  69950. /**
  69951. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69952. * 0 means strongest and 1 would means no shadow.
  69953. * @returns the darkness.
  69954. */
  69955. getDarkness(): number;
  69956. /**
  69957. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69958. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69959. * @returns the shadow generator allowing fluent coding.
  69960. */
  69961. setDarkness(darkness: number): ShadowGenerator;
  69962. private _transparencyShadow;
  69963. /**
  69964. * Sets the ability to have transparent shadow (boolean).
  69965. * @param transparent True if transparent else False
  69966. * @returns the shadow generator allowing fluent coding
  69967. */
  69968. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69969. private _shadowMap;
  69970. private _shadowMap2;
  69971. /**
  69972. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69973. * @returns The render target texture if present otherwise, null
  69974. */
  69975. getShadowMap(): Nullable<RenderTargetTexture>;
  69976. /**
  69977. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69978. * @returns The render target texture if the shadow map is present otherwise, null
  69979. */
  69980. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69981. /**
  69982. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69983. * @param mesh Mesh to add
  69984. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69985. * @returns the Shadow Generator itself
  69986. */
  69987. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69988. /**
  69989. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69990. * @param mesh Mesh to remove
  69991. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69992. * @returns the Shadow Generator itself
  69993. */
  69994. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69995. /**
  69996. * Controls the extent to which the shadows fade out at the edge of the frustum
  69997. * Used only by directionals and spots
  69998. */
  69999. frustumEdgeFalloff: number;
  70000. private _light;
  70001. /**
  70002. * Returns the associated light object.
  70003. * @returns the light generating the shadow
  70004. */
  70005. getLight(): IShadowLight;
  70006. /**
  70007. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  70008. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  70009. * It might on the other hand introduce peter panning.
  70010. */
  70011. forceBackFacesOnly: boolean;
  70012. private _scene;
  70013. private _lightDirection;
  70014. private _effect;
  70015. private _viewMatrix;
  70016. private _projectionMatrix;
  70017. private _transformMatrix;
  70018. private _cachedPosition;
  70019. private _cachedDirection;
  70020. private _cachedDefines;
  70021. private _currentRenderID;
  70022. private _boxBlurPostprocess;
  70023. private _kernelBlurXPostprocess;
  70024. private _kernelBlurYPostprocess;
  70025. private _blurPostProcesses;
  70026. private _mapSize;
  70027. private _currentFaceIndex;
  70028. private _currentFaceIndexCache;
  70029. private _textureType;
  70030. private _defaultTextureMatrix;
  70031. /** @hidden */
  70032. static _SceneComponentInitialization: (scene: Scene) => void;
  70033. /**
  70034. * Creates a ShadowGenerator object.
  70035. * A ShadowGenerator is the required tool to use the shadows.
  70036. * Each light casting shadows needs to use its own ShadowGenerator.
  70037. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  70038. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  70039. * @param light The light object generating the shadows.
  70040. * @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.
  70041. */
  70042. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  70043. private _initializeGenerator;
  70044. private _initializeShadowMap;
  70045. private _initializeBlurRTTAndPostProcesses;
  70046. private _renderForShadowMap;
  70047. private _renderSubMeshForShadowMap;
  70048. private _applyFilterValues;
  70049. /**
  70050. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70051. * @param onCompiled Callback triggered at the and of the effects compilation
  70052. * @param options Sets of optional options forcing the compilation with different modes
  70053. */
  70054. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  70055. useInstances: boolean;
  70056. }>): void;
  70057. /**
  70058. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  70059. * @param options Sets of optional options forcing the compilation with different modes
  70060. * @returns A promise that resolves when the compilation completes
  70061. */
  70062. forceCompilationAsync(options?: Partial<{
  70063. useInstances: boolean;
  70064. }>): Promise<void>;
  70065. /**
  70066. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  70067. * @param subMesh The submesh we want to render in the shadow map
  70068. * @param useInstances Defines wether will draw in the map using instances
  70069. * @returns true if ready otherwise, false
  70070. */
  70071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70072. /**
  70073. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  70074. * @param defines Defines of the material we want to update
  70075. * @param lightIndex Index of the light in the enabled light list of the material
  70076. */
  70077. prepareDefines(defines: any, lightIndex: number): void;
  70078. /**
  70079. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  70080. * defined in the generator but impacting the effect).
  70081. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  70082. * @param effect The effect we are binfing the information for
  70083. */
  70084. bindShadowLight(lightIndex: string, effect: Effect): void;
  70085. /**
  70086. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  70087. * (eq to shadow prjection matrix * light transform matrix)
  70088. * @returns The transform matrix used to create the shadow map
  70089. */
  70090. getTransformMatrix(): Matrix;
  70091. /**
  70092. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  70093. * Cube and 2D textures for instance.
  70094. */
  70095. recreateShadowMap(): void;
  70096. private _disposeBlurPostProcesses;
  70097. private _disposeRTTandPostProcesses;
  70098. /**
  70099. * Disposes the ShadowGenerator.
  70100. * Returns nothing.
  70101. */
  70102. dispose(): void;
  70103. /**
  70104. * Serializes the shadow generator setup to a json object.
  70105. * @returns The serialized JSON object
  70106. */
  70107. serialize(): any;
  70108. /**
  70109. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  70110. * @param parsedShadowGenerator The JSON object to parse
  70111. * @param scene The scene to create the shadow map for
  70112. * @returns The parsed shadow generator
  70113. */
  70114. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /**
  70119. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  70120. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  70121. * 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.
  70122. */
  70123. export abstract class Light extends Node {
  70124. /**
  70125. * Falloff Default: light is falling off following the material specification:
  70126. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  70127. */
  70128. static readonly FALLOFF_DEFAULT: number;
  70129. /**
  70130. * Falloff Physical: light is falling off following the inverse squared distance law.
  70131. */
  70132. static readonly FALLOFF_PHYSICAL: number;
  70133. /**
  70134. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  70135. * to enhance interoperability with other engines.
  70136. */
  70137. static readonly FALLOFF_GLTF: number;
  70138. /**
  70139. * Falloff Standard: light is falling off like in the standard material
  70140. * to enhance interoperability with other materials.
  70141. */
  70142. static readonly FALLOFF_STANDARD: number;
  70143. /**
  70144. * If every light affecting the material is in this lightmapMode,
  70145. * material.lightmapTexture adds or multiplies
  70146. * (depends on material.useLightmapAsShadowmap)
  70147. * after every other light calculations.
  70148. */
  70149. static readonly LIGHTMAP_DEFAULT: number;
  70150. /**
  70151. * material.lightmapTexture as only diffuse lighting from this light
  70152. * adds only specular lighting from this light
  70153. * adds dynamic shadows
  70154. */
  70155. static readonly LIGHTMAP_SPECULAR: number;
  70156. /**
  70157. * material.lightmapTexture as only lighting
  70158. * no light calculation from this light
  70159. * only adds dynamic shadows from this light
  70160. */
  70161. static readonly LIGHTMAP_SHADOWSONLY: number;
  70162. /**
  70163. * Each light type uses the default quantity according to its type:
  70164. * point/spot lights use luminous intensity
  70165. * directional lights use illuminance
  70166. */
  70167. static readonly INTENSITYMODE_AUTOMATIC: number;
  70168. /**
  70169. * lumen (lm)
  70170. */
  70171. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  70172. /**
  70173. * candela (lm/sr)
  70174. */
  70175. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  70176. /**
  70177. * lux (lm/m^2)
  70178. */
  70179. static readonly INTENSITYMODE_ILLUMINANCE: number;
  70180. /**
  70181. * nit (cd/m^2)
  70182. */
  70183. static readonly INTENSITYMODE_LUMINANCE: number;
  70184. /**
  70185. * Light type const id of the point light.
  70186. */
  70187. static readonly LIGHTTYPEID_POINTLIGHT: number;
  70188. /**
  70189. * Light type const id of the directional light.
  70190. */
  70191. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  70192. /**
  70193. * Light type const id of the spot light.
  70194. */
  70195. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  70196. /**
  70197. * Light type const id of the hemispheric light.
  70198. */
  70199. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  70200. /**
  70201. * Diffuse gives the basic color to an object.
  70202. */
  70203. diffuse: Color3;
  70204. /**
  70205. * Specular produces a highlight color on an object.
  70206. * Note: This is note affecting PBR materials.
  70207. */
  70208. specular: Color3;
  70209. /**
  70210. * Defines the falloff type for this light. This lets overrriding how punctual light are
  70211. * falling off base on range or angle.
  70212. * This can be set to any values in Light.FALLOFF_x.
  70213. *
  70214. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  70215. * other types of materials.
  70216. */
  70217. falloffType: number;
  70218. /**
  70219. * Strength of the light.
  70220. * Note: By default it is define in the framework own unit.
  70221. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  70222. */
  70223. intensity: number;
  70224. private _range;
  70225. protected _inverseSquaredRange: number;
  70226. /**
  70227. * Defines how far from the source the light is impacting in scene units.
  70228. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70229. */
  70230. /**
  70231. * Defines how far from the source the light is impacting in scene units.
  70232. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  70233. */
  70234. range: number;
  70235. /**
  70236. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  70237. * of light.
  70238. */
  70239. private _photometricScale;
  70240. private _intensityMode;
  70241. /**
  70242. * Gets the photometric scale used to interpret the intensity.
  70243. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70244. */
  70245. /**
  70246. * Sets the photometric scale used to interpret the intensity.
  70247. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  70248. */
  70249. intensityMode: number;
  70250. private _radius;
  70251. /**
  70252. * Gets the light radius used by PBR Materials to simulate soft area lights.
  70253. */
  70254. /**
  70255. * sets the light radius used by PBR Materials to simulate soft area lights.
  70256. */
  70257. radius: number;
  70258. private _renderPriority;
  70259. /**
  70260. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  70261. * exceeding the number allowed of the materials.
  70262. */
  70263. renderPriority: number;
  70264. private _shadowEnabled;
  70265. /**
  70266. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70267. * the current shadow generator.
  70268. */
  70269. /**
  70270. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  70271. * the current shadow generator.
  70272. */
  70273. shadowEnabled: boolean;
  70274. private _includedOnlyMeshes;
  70275. /**
  70276. * Gets the only meshes impacted by this light.
  70277. */
  70278. /**
  70279. * Sets the only meshes impacted by this light.
  70280. */
  70281. includedOnlyMeshes: AbstractMesh[];
  70282. private _excludedMeshes;
  70283. /**
  70284. * Gets the meshes not impacted by this light.
  70285. */
  70286. /**
  70287. * Sets the meshes not impacted by this light.
  70288. */
  70289. excludedMeshes: AbstractMesh[];
  70290. private _excludeWithLayerMask;
  70291. /**
  70292. * Gets the layer id use to find what meshes are not impacted by the light.
  70293. * Inactive if 0
  70294. */
  70295. /**
  70296. * Sets the layer id use to find what meshes are not impacted by the light.
  70297. * Inactive if 0
  70298. */
  70299. excludeWithLayerMask: number;
  70300. private _includeOnlyWithLayerMask;
  70301. /**
  70302. * Gets the layer id use to find what meshes are impacted by the light.
  70303. * Inactive if 0
  70304. */
  70305. /**
  70306. * Sets the layer id use to find what meshes are impacted by the light.
  70307. * Inactive if 0
  70308. */
  70309. includeOnlyWithLayerMask: number;
  70310. private _lightmapMode;
  70311. /**
  70312. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70313. */
  70314. /**
  70315. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  70316. */
  70317. lightmapMode: number;
  70318. /**
  70319. * Shadow generator associted to the light.
  70320. * @hidden Internal use only.
  70321. */
  70322. _shadowGenerator: Nullable<IShadowGenerator>;
  70323. /**
  70324. * @hidden Internal use only.
  70325. */
  70326. _excludedMeshesIds: string[];
  70327. /**
  70328. * @hidden Internal use only.
  70329. */
  70330. _includedOnlyMeshesIds: string[];
  70331. /**
  70332. * The current light unifom buffer.
  70333. * @hidden Internal use only.
  70334. */
  70335. _uniformBuffer: UniformBuffer;
  70336. /**
  70337. * Creates a Light object in the scene.
  70338. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70339. * @param name The firendly name of the light
  70340. * @param scene The scene the light belongs too
  70341. */
  70342. constructor(name: string, scene: Scene);
  70343. protected abstract _buildUniformLayout(): void;
  70344. /**
  70345. * Sets the passed Effect "effect" with the Light information.
  70346. * @param effect The effect to update
  70347. * @param lightIndex The index of the light in the effect to update
  70348. * @returns The light
  70349. */
  70350. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  70351. /**
  70352. * Returns the string "Light".
  70353. * @returns the class name
  70354. */
  70355. getClassName(): string;
  70356. /** @hidden */
  70357. readonly _isLight: boolean;
  70358. /**
  70359. * Converts the light information to a readable string for debug purpose.
  70360. * @param fullDetails Supports for multiple levels of logging within scene loading
  70361. * @returns the human readable light info
  70362. */
  70363. toString(fullDetails?: boolean): string;
  70364. /** @hidden */
  70365. protected _syncParentEnabledState(): void;
  70366. /**
  70367. * Set the enabled state of this node.
  70368. * @param value - the new enabled state
  70369. */
  70370. setEnabled(value: boolean): void;
  70371. /**
  70372. * Returns the Light associated shadow generator if any.
  70373. * @return the associated shadow generator.
  70374. */
  70375. getShadowGenerator(): Nullable<IShadowGenerator>;
  70376. /**
  70377. * Returns a Vector3, the absolute light position in the World.
  70378. * @returns the world space position of the light
  70379. */
  70380. getAbsolutePosition(): Vector3;
  70381. /**
  70382. * Specifies if the light will affect the passed mesh.
  70383. * @param mesh The mesh to test against the light
  70384. * @return true the mesh is affected otherwise, false.
  70385. */
  70386. canAffectMesh(mesh: AbstractMesh): boolean;
  70387. /**
  70388. * Sort function to order lights for rendering.
  70389. * @param a First Light object to compare to second.
  70390. * @param b Second Light object to compare first.
  70391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  70392. */
  70393. static CompareLightsPriority(a: Light, b: Light): number;
  70394. /**
  70395. * Releases resources associated with this node.
  70396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70398. */
  70399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70400. /**
  70401. * Returns the light type ID (integer).
  70402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70403. */
  70404. getTypeID(): number;
  70405. /**
  70406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  70407. * @returns the scaled intensity in intensity mode unit
  70408. */
  70409. getScaledIntensity(): number;
  70410. /**
  70411. * Returns a new Light object, named "name", from the current one.
  70412. * @param name The name of the cloned light
  70413. * @returns the new created light
  70414. */
  70415. clone(name: string): Nullable<Light>;
  70416. /**
  70417. * Serializes the current light into a Serialization object.
  70418. * @returns the serialized object.
  70419. */
  70420. serialize(): any;
  70421. /**
  70422. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  70423. * This new light is named "name" and added to the passed scene.
  70424. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  70425. * @param name The friendly name of the light
  70426. * @param scene The scene the new light will belong to
  70427. * @returns the constructor function
  70428. */
  70429. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  70430. /**
  70431. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  70432. * @param parsedLight The JSON representation of the light
  70433. * @param scene The scene to create the parsed light in
  70434. * @returns the created light after parsing
  70435. */
  70436. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  70437. private _hookArrayForExcluded;
  70438. private _hookArrayForIncludedOnly;
  70439. private _resyncMeshes;
  70440. /**
  70441. * Forces the meshes to update their light related information in their rendering used effects
  70442. * @hidden Internal Use Only
  70443. */
  70444. _markMeshesAsLightDirty(): void;
  70445. /**
  70446. * Recomputes the cached photometric scale if needed.
  70447. */
  70448. private _computePhotometricScale;
  70449. /**
  70450. * Returns the Photometric Scale according to the light type and intensity mode.
  70451. */
  70452. private _getPhotometricScale;
  70453. /**
  70454. * Reorder the light in the scene according to their defined priority.
  70455. * @hidden Internal Use Only
  70456. */
  70457. _reorderLightsInScene(): void;
  70458. /**
  70459. * Prepares the list of defines specific to the light type.
  70460. * @param defines the list of defines
  70461. * @param lightIndex defines the index of the light for the effect
  70462. */
  70463. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70464. }
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * Interface used to define Action
  70469. */
  70470. export interface IAction {
  70471. /**
  70472. * Trigger for the action
  70473. */
  70474. trigger: number;
  70475. /** Options of the trigger */
  70476. triggerOptions: any;
  70477. /**
  70478. * Gets the trigger parameters
  70479. * @returns the trigger parameters
  70480. */
  70481. getTriggerParameter(): any;
  70482. /**
  70483. * Internal only - executes current action event
  70484. * @hidden
  70485. */
  70486. _executeCurrent(evt?: ActionEvent): void;
  70487. /**
  70488. * Serialize placeholder for child classes
  70489. * @param parent of child
  70490. * @returns the serialized object
  70491. */
  70492. serialize(parent: any): any;
  70493. /**
  70494. * Internal only
  70495. * @hidden
  70496. */
  70497. _prepare(): void;
  70498. /**
  70499. * Internal only - manager for action
  70500. * @hidden
  70501. */
  70502. _actionManager: AbstractActionManager;
  70503. }
  70504. /**
  70505. * The action to be carried out following a trigger
  70506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  70507. */
  70508. export class Action implements IAction {
  70509. /** the trigger, with or without parameters, for the action */
  70510. triggerOptions: any;
  70511. /**
  70512. * Trigger for the action
  70513. */
  70514. trigger: number;
  70515. /**
  70516. * Internal only - manager for action
  70517. * @hidden
  70518. */
  70519. _actionManager: ActionManager;
  70520. private _nextActiveAction;
  70521. private _child;
  70522. private _condition?;
  70523. private _triggerParameter;
  70524. /**
  70525. * An event triggered prior to action being executed.
  70526. */
  70527. onBeforeExecuteObservable: Observable<Action>;
  70528. /**
  70529. * Creates a new Action
  70530. * @param triggerOptions the trigger, with or without parameters, for the action
  70531. * @param condition an optional determinant of action
  70532. */
  70533. constructor(
  70534. /** the trigger, with or without parameters, for the action */
  70535. triggerOptions: any, condition?: Condition);
  70536. /**
  70537. * Internal only
  70538. * @hidden
  70539. */
  70540. _prepare(): void;
  70541. /**
  70542. * Gets the trigger parameters
  70543. * @returns the trigger parameters
  70544. */
  70545. getTriggerParameter(): any;
  70546. /**
  70547. * Internal only - executes current action event
  70548. * @hidden
  70549. */
  70550. _executeCurrent(evt?: ActionEvent): void;
  70551. /**
  70552. * Execute placeholder for child classes
  70553. * @param evt optional action event
  70554. */
  70555. execute(evt?: ActionEvent): void;
  70556. /**
  70557. * Skips to next active action
  70558. */
  70559. skipToNextActiveAction(): void;
  70560. /**
  70561. * Adds action to chain of actions, may be a DoNothingAction
  70562. * @param action defines the next action to execute
  70563. * @returns The action passed in
  70564. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70565. */
  70566. then(action: Action): Action;
  70567. /**
  70568. * Internal only
  70569. * @hidden
  70570. */
  70571. _getProperty(propertyPath: string): string;
  70572. /**
  70573. * Internal only
  70574. * @hidden
  70575. */
  70576. _getEffectiveTarget(target: any, propertyPath: string): any;
  70577. /**
  70578. * Serialize placeholder for child classes
  70579. * @param parent of child
  70580. * @returns the serialized object
  70581. */
  70582. serialize(parent: any): any;
  70583. /**
  70584. * Internal only called by serialize
  70585. * @hidden
  70586. */
  70587. protected _serialize(serializedAction: any, parent?: any): any;
  70588. /**
  70589. * Internal only
  70590. * @hidden
  70591. */
  70592. static _SerializeValueAsString: (value: any) => string;
  70593. /**
  70594. * Internal only
  70595. * @hidden
  70596. */
  70597. static _GetTargetProperty: (target: Scene | Node) => {
  70598. name: string;
  70599. targetType: string;
  70600. value: string;
  70601. };
  70602. }
  70603. }
  70604. declare module BABYLON {
  70605. /**
  70606. * A Condition applied to an Action
  70607. */
  70608. export class Condition {
  70609. /**
  70610. * Internal only - manager for action
  70611. * @hidden
  70612. */
  70613. _actionManager: ActionManager;
  70614. /**
  70615. * Internal only
  70616. * @hidden
  70617. */
  70618. _evaluationId: number;
  70619. /**
  70620. * Internal only
  70621. * @hidden
  70622. */
  70623. _currentResult: boolean;
  70624. /**
  70625. * Creates a new Condition
  70626. * @param actionManager the manager of the action the condition is applied to
  70627. */
  70628. constructor(actionManager: ActionManager);
  70629. /**
  70630. * Check if the current condition is valid
  70631. * @returns a boolean
  70632. */
  70633. isValid(): boolean;
  70634. /**
  70635. * Internal only
  70636. * @hidden
  70637. */
  70638. _getProperty(propertyPath: string): string;
  70639. /**
  70640. * Internal only
  70641. * @hidden
  70642. */
  70643. _getEffectiveTarget(target: any, propertyPath: string): any;
  70644. /**
  70645. * Serialize placeholder for child classes
  70646. * @returns the serialized object
  70647. */
  70648. serialize(): any;
  70649. /**
  70650. * Internal only
  70651. * @hidden
  70652. */
  70653. protected _serialize(serializedCondition: any): any;
  70654. }
  70655. /**
  70656. * Defines specific conditional operators as extensions of Condition
  70657. */
  70658. export class ValueCondition extends Condition {
  70659. /** path to specify the property of the target the conditional operator uses */
  70660. propertyPath: string;
  70661. /** the value compared by the conditional operator against the current value of the property */
  70662. value: any;
  70663. /** the conditional operator, default ValueCondition.IsEqual */
  70664. operator: number;
  70665. /**
  70666. * Internal only
  70667. * @hidden
  70668. */
  70669. private static _IsEqual;
  70670. /**
  70671. * Internal only
  70672. * @hidden
  70673. */
  70674. private static _IsDifferent;
  70675. /**
  70676. * Internal only
  70677. * @hidden
  70678. */
  70679. private static _IsGreater;
  70680. /**
  70681. * Internal only
  70682. * @hidden
  70683. */
  70684. private static _IsLesser;
  70685. /**
  70686. * returns the number for IsEqual
  70687. */
  70688. static readonly IsEqual: number;
  70689. /**
  70690. * Returns the number for IsDifferent
  70691. */
  70692. static readonly IsDifferent: number;
  70693. /**
  70694. * Returns the number for IsGreater
  70695. */
  70696. static readonly IsGreater: number;
  70697. /**
  70698. * Returns the number for IsLesser
  70699. */
  70700. static readonly IsLesser: number;
  70701. /**
  70702. * Internal only The action manager for the condition
  70703. * @hidden
  70704. */
  70705. _actionManager: ActionManager;
  70706. /**
  70707. * Internal only
  70708. * @hidden
  70709. */
  70710. private _target;
  70711. /**
  70712. * Internal only
  70713. * @hidden
  70714. */
  70715. private _effectiveTarget;
  70716. /**
  70717. * Internal only
  70718. * @hidden
  70719. */
  70720. private _property;
  70721. /**
  70722. * Creates a new ValueCondition
  70723. * @param actionManager manager for the action the condition applies to
  70724. * @param target for the action
  70725. * @param propertyPath path to specify the property of the target the conditional operator uses
  70726. * @param value the value compared by the conditional operator against the current value of the property
  70727. * @param operator the conditional operator, default ValueCondition.IsEqual
  70728. */
  70729. constructor(actionManager: ActionManager, target: any,
  70730. /** path to specify the property of the target the conditional operator uses */
  70731. propertyPath: string,
  70732. /** the value compared by the conditional operator against the current value of the property */
  70733. value: any,
  70734. /** the conditional operator, default ValueCondition.IsEqual */
  70735. operator?: number);
  70736. /**
  70737. * Compares the given value with the property value for the specified conditional operator
  70738. * @returns the result of the comparison
  70739. */
  70740. isValid(): boolean;
  70741. /**
  70742. * Serialize the ValueCondition into a JSON compatible object
  70743. * @returns serialization object
  70744. */
  70745. serialize(): any;
  70746. /**
  70747. * Gets the name of the conditional operator for the ValueCondition
  70748. * @param operator the conditional operator
  70749. * @returns the name
  70750. */
  70751. static GetOperatorName(operator: number): string;
  70752. }
  70753. /**
  70754. * Defines a predicate condition as an extension of Condition
  70755. */
  70756. export class PredicateCondition extends Condition {
  70757. /** defines the predicate function used to validate the condition */
  70758. predicate: () => boolean;
  70759. /**
  70760. * Internal only - manager for action
  70761. * @hidden
  70762. */
  70763. _actionManager: ActionManager;
  70764. /**
  70765. * Creates a new PredicateCondition
  70766. * @param actionManager manager for the action the condition applies to
  70767. * @param predicate defines the predicate function used to validate the condition
  70768. */
  70769. constructor(actionManager: ActionManager,
  70770. /** defines the predicate function used to validate the condition */
  70771. predicate: () => boolean);
  70772. /**
  70773. * @returns the validity of the predicate condition
  70774. */
  70775. isValid(): boolean;
  70776. }
  70777. /**
  70778. * Defines a state condition as an extension of Condition
  70779. */
  70780. export class StateCondition extends Condition {
  70781. /** Value to compare with target state */
  70782. value: string;
  70783. /**
  70784. * Internal only - manager for action
  70785. * @hidden
  70786. */
  70787. _actionManager: ActionManager;
  70788. /**
  70789. * Internal only
  70790. * @hidden
  70791. */
  70792. private _target;
  70793. /**
  70794. * Creates a new StateCondition
  70795. * @param actionManager manager for the action the condition applies to
  70796. * @param target of the condition
  70797. * @param value to compare with target state
  70798. */
  70799. constructor(actionManager: ActionManager, target: any,
  70800. /** Value to compare with target state */
  70801. value: string);
  70802. /**
  70803. * Gets a boolean indicating if the current condition is met
  70804. * @returns the validity of the state
  70805. */
  70806. isValid(): boolean;
  70807. /**
  70808. * Serialize the StateCondition into a JSON compatible object
  70809. * @returns serialization object
  70810. */
  70811. serialize(): any;
  70812. }
  70813. }
  70814. declare module BABYLON {
  70815. /**
  70816. * This defines an action responsible to toggle a boolean once triggered.
  70817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70818. */
  70819. export class SwitchBooleanAction extends Action {
  70820. /**
  70821. * The path to the boolean property in the target object
  70822. */
  70823. propertyPath: string;
  70824. private _target;
  70825. private _effectiveTarget;
  70826. private _property;
  70827. /**
  70828. * Instantiate the action
  70829. * @param triggerOptions defines the trigger options
  70830. * @param target defines the object containing the boolean
  70831. * @param propertyPath defines the path to the boolean property in the target object
  70832. * @param condition defines the trigger related conditions
  70833. */
  70834. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70835. /** @hidden */
  70836. _prepare(): void;
  70837. /**
  70838. * Execute the action toggle the boolean value.
  70839. */
  70840. execute(): void;
  70841. /**
  70842. * Serializes the actions and its related information.
  70843. * @param parent defines the object to serialize in
  70844. * @returns the serialized object
  70845. */
  70846. serialize(parent: any): any;
  70847. }
  70848. /**
  70849. * This defines an action responsible to set a the state field of the target
  70850. * to a desired value once triggered.
  70851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70852. */
  70853. export class SetStateAction extends Action {
  70854. /**
  70855. * The value to store in the state field.
  70856. */
  70857. value: string;
  70858. private _target;
  70859. /**
  70860. * Instantiate the action
  70861. * @param triggerOptions defines the trigger options
  70862. * @param target defines the object containing the state property
  70863. * @param value defines the value to store in the state field
  70864. * @param condition defines the trigger related conditions
  70865. */
  70866. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70867. /**
  70868. * Execute the action and store the value on the target state property.
  70869. */
  70870. execute(): void;
  70871. /**
  70872. * Serializes the actions and its related information.
  70873. * @param parent defines the object to serialize in
  70874. * @returns the serialized object
  70875. */
  70876. serialize(parent: any): any;
  70877. }
  70878. /**
  70879. * This defines an action responsible to set a property of the target
  70880. * to a desired value once triggered.
  70881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70882. */
  70883. export class SetValueAction extends Action {
  70884. /**
  70885. * The path of the property to set in the target.
  70886. */
  70887. propertyPath: string;
  70888. /**
  70889. * The value to set in the property
  70890. */
  70891. value: any;
  70892. private _target;
  70893. private _effectiveTarget;
  70894. private _property;
  70895. /**
  70896. * Instantiate the action
  70897. * @param triggerOptions defines the trigger options
  70898. * @param target defines the object containing the property
  70899. * @param propertyPath defines the path of the property to set in the target
  70900. * @param value defines the value to set in the property
  70901. * @param condition defines the trigger related conditions
  70902. */
  70903. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70904. /** @hidden */
  70905. _prepare(): void;
  70906. /**
  70907. * Execute the action and set the targetted property to the desired value.
  70908. */
  70909. execute(): void;
  70910. /**
  70911. * Serializes the actions and its related information.
  70912. * @param parent defines the object to serialize in
  70913. * @returns the serialized object
  70914. */
  70915. serialize(parent: any): any;
  70916. }
  70917. /**
  70918. * This defines an action responsible to increment the target value
  70919. * to a desired value once triggered.
  70920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70921. */
  70922. export class IncrementValueAction extends Action {
  70923. /**
  70924. * The path of the property to increment in the target.
  70925. */
  70926. propertyPath: string;
  70927. /**
  70928. * The value we should increment the property by.
  70929. */
  70930. value: any;
  70931. private _target;
  70932. private _effectiveTarget;
  70933. private _property;
  70934. /**
  70935. * Instantiate the action
  70936. * @param triggerOptions defines the trigger options
  70937. * @param target defines the object containing the property
  70938. * @param propertyPath defines the path of the property to increment in the target
  70939. * @param value defines the value value we should increment the property by
  70940. * @param condition defines the trigger related conditions
  70941. */
  70942. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70943. /** @hidden */
  70944. _prepare(): void;
  70945. /**
  70946. * Execute the action and increment the target of the value amount.
  70947. */
  70948. execute(): void;
  70949. /**
  70950. * Serializes the actions and its related information.
  70951. * @param parent defines the object to serialize in
  70952. * @returns the serialized object
  70953. */
  70954. serialize(parent: any): any;
  70955. }
  70956. /**
  70957. * This defines an action responsible to start an animation once triggered.
  70958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70959. */
  70960. export class PlayAnimationAction extends Action {
  70961. /**
  70962. * Where the animation should start (animation frame)
  70963. */
  70964. from: number;
  70965. /**
  70966. * Where the animation should stop (animation frame)
  70967. */
  70968. to: number;
  70969. /**
  70970. * Define if the animation should loop or stop after the first play.
  70971. */
  70972. loop?: boolean;
  70973. private _target;
  70974. /**
  70975. * Instantiate the action
  70976. * @param triggerOptions defines the trigger options
  70977. * @param target defines the target animation or animation name
  70978. * @param from defines from where the animation should start (animation frame)
  70979. * @param end defines where the animation should stop (animation frame)
  70980. * @param loop defines if the animation should loop or stop after the first play
  70981. * @param condition defines the trigger related conditions
  70982. */
  70983. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70984. /** @hidden */
  70985. _prepare(): void;
  70986. /**
  70987. * Execute the action and play the animation.
  70988. */
  70989. execute(): void;
  70990. /**
  70991. * Serializes the actions and its related information.
  70992. * @param parent defines the object to serialize in
  70993. * @returns the serialized object
  70994. */
  70995. serialize(parent: any): any;
  70996. }
  70997. /**
  70998. * This defines an action responsible to stop an animation once triggered.
  70999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71000. */
  71001. export class StopAnimationAction extends Action {
  71002. private _target;
  71003. /**
  71004. * Instantiate the action
  71005. * @param triggerOptions defines the trigger options
  71006. * @param target defines the target animation or animation name
  71007. * @param condition defines the trigger related conditions
  71008. */
  71009. constructor(triggerOptions: any, target: any, condition?: Condition);
  71010. /** @hidden */
  71011. _prepare(): void;
  71012. /**
  71013. * Execute the action and stop the animation.
  71014. */
  71015. execute(): void;
  71016. /**
  71017. * Serializes the actions and its related information.
  71018. * @param parent defines the object to serialize in
  71019. * @returns the serialized object
  71020. */
  71021. serialize(parent: any): any;
  71022. }
  71023. /**
  71024. * This defines an action responsible that does nothing once triggered.
  71025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71026. */
  71027. export class DoNothingAction extends Action {
  71028. /**
  71029. * Instantiate the action
  71030. * @param triggerOptions defines the trigger options
  71031. * @param condition defines the trigger related conditions
  71032. */
  71033. constructor(triggerOptions?: any, condition?: Condition);
  71034. /**
  71035. * Execute the action and do nothing.
  71036. */
  71037. execute(): void;
  71038. /**
  71039. * Serializes the actions and its related information.
  71040. * @param parent defines the object to serialize in
  71041. * @returns the serialized object
  71042. */
  71043. serialize(parent: any): any;
  71044. }
  71045. /**
  71046. * This defines an action responsible to trigger several actions once triggered.
  71047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71048. */
  71049. export class CombineAction extends Action {
  71050. /**
  71051. * The list of aggregated animations to run.
  71052. */
  71053. children: Action[];
  71054. /**
  71055. * Instantiate the action
  71056. * @param triggerOptions defines the trigger options
  71057. * @param children defines the list of aggregated animations to run
  71058. * @param condition defines the trigger related conditions
  71059. */
  71060. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  71061. /** @hidden */
  71062. _prepare(): void;
  71063. /**
  71064. * Execute the action and executes all the aggregated actions.
  71065. */
  71066. execute(evt: ActionEvent): void;
  71067. /**
  71068. * Serializes the actions and its related information.
  71069. * @param parent defines the object to serialize in
  71070. * @returns the serialized object
  71071. */
  71072. serialize(parent: any): any;
  71073. }
  71074. /**
  71075. * This defines an action responsible to run code (external event) once triggered.
  71076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71077. */
  71078. export class ExecuteCodeAction extends Action {
  71079. /**
  71080. * The callback function to run.
  71081. */
  71082. func: (evt: ActionEvent) => void;
  71083. /**
  71084. * Instantiate the action
  71085. * @param triggerOptions defines the trigger options
  71086. * @param func defines the callback function to run
  71087. * @param condition defines the trigger related conditions
  71088. */
  71089. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  71090. /**
  71091. * Execute the action and run the attached code.
  71092. */
  71093. execute(evt: ActionEvent): void;
  71094. }
  71095. /**
  71096. * This defines an action responsible to set the parent property of the target once triggered.
  71097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71098. */
  71099. export class SetParentAction extends Action {
  71100. private _parent;
  71101. private _target;
  71102. /**
  71103. * Instantiate the action
  71104. * @param triggerOptions defines the trigger options
  71105. * @param target defines the target containing the parent property
  71106. * @param parent defines from where the animation should start (animation frame)
  71107. * @param condition defines the trigger related conditions
  71108. */
  71109. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  71110. /** @hidden */
  71111. _prepare(): void;
  71112. /**
  71113. * Execute the action and set the parent property.
  71114. */
  71115. execute(): void;
  71116. /**
  71117. * Serializes the actions and its related information.
  71118. * @param parent defines the object to serialize in
  71119. * @returns the serialized object
  71120. */
  71121. serialize(parent: any): any;
  71122. }
  71123. }
  71124. declare module BABYLON {
  71125. /**
  71126. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  71127. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  71128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  71129. */
  71130. export class ActionManager extends AbstractActionManager {
  71131. /**
  71132. * Nothing
  71133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71134. */
  71135. static readonly NothingTrigger: number;
  71136. /**
  71137. * On pick
  71138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71139. */
  71140. static readonly OnPickTrigger: number;
  71141. /**
  71142. * On left pick
  71143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71144. */
  71145. static readonly OnLeftPickTrigger: number;
  71146. /**
  71147. * On right pick
  71148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71149. */
  71150. static readonly OnRightPickTrigger: number;
  71151. /**
  71152. * On center pick
  71153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71154. */
  71155. static readonly OnCenterPickTrigger: number;
  71156. /**
  71157. * On pick down
  71158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71159. */
  71160. static readonly OnPickDownTrigger: number;
  71161. /**
  71162. * On double pick
  71163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71164. */
  71165. static readonly OnDoublePickTrigger: number;
  71166. /**
  71167. * On pick up
  71168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71169. */
  71170. static readonly OnPickUpTrigger: number;
  71171. /**
  71172. * On pick out.
  71173. * This trigger will only be raised if you also declared a OnPickDown
  71174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71175. */
  71176. static readonly OnPickOutTrigger: number;
  71177. /**
  71178. * On long press
  71179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71180. */
  71181. static readonly OnLongPressTrigger: number;
  71182. /**
  71183. * On pointer over
  71184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71185. */
  71186. static readonly OnPointerOverTrigger: number;
  71187. /**
  71188. * On pointer out
  71189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71190. */
  71191. static readonly OnPointerOutTrigger: number;
  71192. /**
  71193. * On every frame
  71194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71195. */
  71196. static readonly OnEveryFrameTrigger: number;
  71197. /**
  71198. * On intersection enter
  71199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71200. */
  71201. static readonly OnIntersectionEnterTrigger: number;
  71202. /**
  71203. * On intersection exit
  71204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71205. */
  71206. static readonly OnIntersectionExitTrigger: number;
  71207. /**
  71208. * On key down
  71209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71210. */
  71211. static readonly OnKeyDownTrigger: number;
  71212. /**
  71213. * On key up
  71214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71215. */
  71216. static readonly OnKeyUpTrigger: number;
  71217. private _scene;
  71218. /**
  71219. * Creates a new action manager
  71220. * @param scene defines the hosting scene
  71221. */
  71222. constructor(scene: Scene);
  71223. /**
  71224. * Releases all associated resources
  71225. */
  71226. dispose(): void;
  71227. /**
  71228. * Gets hosting scene
  71229. * @returns the hosting scene
  71230. */
  71231. getScene(): Scene;
  71232. /**
  71233. * Does this action manager handles actions of any of the given triggers
  71234. * @param triggers defines the triggers to be tested
  71235. * @return a boolean indicating whether one (or more) of the triggers is handled
  71236. */
  71237. hasSpecificTriggers(triggers: number[]): boolean;
  71238. /**
  71239. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  71240. * speed.
  71241. * @param triggerA defines the trigger to be tested
  71242. * @param triggerB defines the trigger to be tested
  71243. * @return a boolean indicating whether one (or more) of the triggers is handled
  71244. */
  71245. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  71246. /**
  71247. * Does this action manager handles actions of a given trigger
  71248. * @param trigger defines the trigger to be tested
  71249. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  71250. * @return whether the trigger is handled
  71251. */
  71252. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  71253. /**
  71254. * Does this action manager has pointer triggers
  71255. */
  71256. readonly hasPointerTriggers: boolean;
  71257. /**
  71258. * Does this action manager has pick triggers
  71259. */
  71260. readonly hasPickTriggers: boolean;
  71261. /**
  71262. * Registers an action to this action manager
  71263. * @param action defines the action to be registered
  71264. * @return the action amended (prepared) after registration
  71265. */
  71266. registerAction(action: IAction): Nullable<IAction>;
  71267. /**
  71268. * Unregisters an action to this action manager
  71269. * @param action defines the action to be unregistered
  71270. * @return a boolean indicating whether the action has been unregistered
  71271. */
  71272. unregisterAction(action: IAction): Boolean;
  71273. /**
  71274. * Process a specific trigger
  71275. * @param trigger defines the trigger to process
  71276. * @param evt defines the event details to be processed
  71277. */
  71278. processTrigger(trigger: number, evt?: IActionEvent): void;
  71279. /** @hidden */
  71280. _getEffectiveTarget(target: any, propertyPath: string): any;
  71281. /** @hidden */
  71282. _getProperty(propertyPath: string): string;
  71283. /**
  71284. * Serialize this manager to a JSON object
  71285. * @param name defines the property name to store this manager
  71286. * @returns a JSON representation of this manager
  71287. */
  71288. serialize(name: string): any;
  71289. /**
  71290. * Creates a new ActionManager from a JSON data
  71291. * @param parsedActions defines the JSON data to read from
  71292. * @param object defines the hosting mesh
  71293. * @param scene defines the hosting scene
  71294. */
  71295. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  71296. /**
  71297. * Get a trigger name by index
  71298. * @param trigger defines the trigger index
  71299. * @returns a trigger name
  71300. */
  71301. static GetTriggerName(trigger: number): string;
  71302. }
  71303. }
  71304. declare module BABYLON {
  71305. /**
  71306. * Class representing a ray with position and direction
  71307. */
  71308. export class Ray {
  71309. /** origin point */
  71310. origin: Vector3;
  71311. /** direction */
  71312. direction: Vector3;
  71313. /** length of the ray */
  71314. length: number;
  71315. private static readonly TmpVector3;
  71316. private _tmpRay;
  71317. /**
  71318. * Creates a new ray
  71319. * @param origin origin point
  71320. * @param direction direction
  71321. * @param length length of the ray
  71322. */
  71323. constructor(
  71324. /** origin point */
  71325. origin: Vector3,
  71326. /** direction */
  71327. direction: Vector3,
  71328. /** length of the ray */
  71329. length?: number);
  71330. /**
  71331. * Checks if the ray intersects a box
  71332. * @param minimum bound of the box
  71333. * @param maximum bound of the box
  71334. * @param intersectionTreshold extra extend to be added to the box in all direction
  71335. * @returns if the box was hit
  71336. */
  71337. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  71338. /**
  71339. * Checks if the ray intersects a box
  71340. * @param box the bounding box to check
  71341. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  71342. * @returns if the box was hit
  71343. */
  71344. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  71345. /**
  71346. * If the ray hits a sphere
  71347. * @param sphere the bounding sphere to check
  71348. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  71349. * @returns true if it hits the sphere
  71350. */
  71351. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  71352. /**
  71353. * If the ray hits a triange
  71354. * @param vertex0 triangle vertex
  71355. * @param vertex1 triangle vertex
  71356. * @param vertex2 triangle vertex
  71357. * @returns intersection information if hit
  71358. */
  71359. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  71360. /**
  71361. * Checks if ray intersects a plane
  71362. * @param plane the plane to check
  71363. * @returns the distance away it was hit
  71364. */
  71365. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  71366. /**
  71367. * Checks if ray intersects a mesh
  71368. * @param mesh the mesh to check
  71369. * @param fastCheck if only the bounding box should checked
  71370. * @returns picking info of the intersecton
  71371. */
  71372. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  71373. /**
  71374. * Checks if ray intersects a mesh
  71375. * @param meshes the meshes to check
  71376. * @param fastCheck if only the bounding box should checked
  71377. * @param results array to store result in
  71378. * @returns Array of picking infos
  71379. */
  71380. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  71381. private _comparePickingInfo;
  71382. private static smallnum;
  71383. private static rayl;
  71384. /**
  71385. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  71386. * @param sega the first point of the segment to test the intersection against
  71387. * @param segb the second point of the segment to test the intersection against
  71388. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  71389. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  71390. */
  71391. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  71392. /**
  71393. * Update the ray from viewport position
  71394. * @param x position
  71395. * @param y y position
  71396. * @param viewportWidth viewport width
  71397. * @param viewportHeight viewport height
  71398. * @param world world matrix
  71399. * @param view view matrix
  71400. * @param projection projection matrix
  71401. * @returns this ray updated
  71402. */
  71403. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71404. /**
  71405. * Creates a ray with origin and direction of 0,0,0
  71406. * @returns the new ray
  71407. */
  71408. static Zero(): Ray;
  71409. /**
  71410. * Creates a new ray from screen space and viewport
  71411. * @param x position
  71412. * @param y y position
  71413. * @param viewportWidth viewport width
  71414. * @param viewportHeight viewport height
  71415. * @param world world matrix
  71416. * @param view view matrix
  71417. * @param projection projection matrix
  71418. * @returns new ray
  71419. */
  71420. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  71421. /**
  71422. * 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
  71423. * transformed to the given world matrix.
  71424. * @param origin The origin point
  71425. * @param end The end point
  71426. * @param world a matrix to transform the ray to. Default is the identity matrix.
  71427. * @returns the new ray
  71428. */
  71429. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  71430. /**
  71431. * Transforms a ray by a matrix
  71432. * @param ray ray to transform
  71433. * @param matrix matrix to apply
  71434. * @returns the resulting new ray
  71435. */
  71436. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  71437. /**
  71438. * Transforms a ray by a matrix
  71439. * @param ray ray to transform
  71440. * @param matrix matrix to apply
  71441. * @param result ray to store result in
  71442. */
  71443. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  71444. /**
  71445. * Unproject a ray from screen space to object space
  71446. * @param sourceX defines the screen space x coordinate to use
  71447. * @param sourceY defines the screen space y coordinate to use
  71448. * @param viewportWidth defines the current width of the viewport
  71449. * @param viewportHeight defines the current height of the viewport
  71450. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71451. * @param view defines the view matrix to use
  71452. * @param projection defines the projection matrix to use
  71453. */
  71454. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  71455. }
  71456. /**
  71457. * Type used to define predicate used to select faces when a mesh intersection is detected
  71458. */
  71459. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  71460. interface Scene {
  71461. /** @hidden */
  71462. _tempPickingRay: Nullable<Ray>;
  71463. /** @hidden */
  71464. _cachedRayForTransform: Ray;
  71465. /** @hidden */
  71466. _pickWithRayInverseMatrix: Matrix;
  71467. /** @hidden */
  71468. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  71469. /** @hidden */
  71470. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  71471. }
  71472. }
  71473. declare module BABYLON {
  71474. /**
  71475. * Groups all the scene component constants in one place to ease maintenance.
  71476. * @hidden
  71477. */
  71478. export class SceneComponentConstants {
  71479. static readonly NAME_EFFECTLAYER: string;
  71480. static readonly NAME_LAYER: string;
  71481. static readonly NAME_LENSFLARESYSTEM: string;
  71482. static readonly NAME_BOUNDINGBOXRENDERER: string;
  71483. static readonly NAME_PARTICLESYSTEM: string;
  71484. static readonly NAME_GAMEPAD: string;
  71485. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  71486. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  71487. static readonly NAME_DEPTHRENDERER: string;
  71488. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  71489. static readonly NAME_SPRITE: string;
  71490. static readonly NAME_OUTLINERENDERER: string;
  71491. static readonly NAME_PROCEDURALTEXTURE: string;
  71492. static readonly NAME_SHADOWGENERATOR: string;
  71493. static readonly NAME_OCTREE: string;
  71494. static readonly NAME_PHYSICSENGINE: string;
  71495. static readonly NAME_AUDIO: string;
  71496. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  71497. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71498. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  71499. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  71500. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  71501. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  71502. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  71503. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  71504. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  71505. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  71506. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  71507. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  71508. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  71509. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  71510. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  71511. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  71512. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  71513. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  71514. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  71515. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  71516. static readonly STEP_AFTERRENDER_AUDIO: number;
  71517. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  71518. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  71519. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  71520. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  71521. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  71522. static readonly STEP_POINTERMOVE_SPRITE: number;
  71523. static readonly STEP_POINTERDOWN_SPRITE: number;
  71524. static readonly STEP_POINTERUP_SPRITE: number;
  71525. }
  71526. /**
  71527. * This represents a scene component.
  71528. *
  71529. * This is used to decouple the dependency the scene is having on the different workloads like
  71530. * layers, post processes...
  71531. */
  71532. export interface ISceneComponent {
  71533. /**
  71534. * The name of the component. Each component must have a unique name.
  71535. */
  71536. name: string;
  71537. /**
  71538. * The scene the component belongs to.
  71539. */
  71540. scene: Scene;
  71541. /**
  71542. * Register the component to one instance of a scene.
  71543. */
  71544. register(): void;
  71545. /**
  71546. * Rebuilds the elements related to this component in case of
  71547. * context lost for instance.
  71548. */
  71549. rebuild(): void;
  71550. /**
  71551. * Disposes the component and the associated ressources.
  71552. */
  71553. dispose(): void;
  71554. }
  71555. /**
  71556. * This represents a SERIALIZABLE scene component.
  71557. *
  71558. * This extends Scene Component to add Serialization methods on top.
  71559. */
  71560. export interface ISceneSerializableComponent extends ISceneComponent {
  71561. /**
  71562. * Adds all the element from the container to the scene
  71563. * @param container the container holding the elements
  71564. */
  71565. addFromContainer(container: AbstractScene): void;
  71566. /**
  71567. * Removes all the elements in the container from the scene
  71568. * @param container contains the elements to remove
  71569. * @param dispose if the removed element should be disposed (default: false)
  71570. */
  71571. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71572. /**
  71573. * Serializes the component data to the specified json object
  71574. * @param serializationObject The object to serialize to
  71575. */
  71576. serialize(serializationObject: any): void;
  71577. }
  71578. /**
  71579. * Strong typing of a Mesh related stage step action
  71580. */
  71581. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71582. /**
  71583. * Strong typing of a Evaluate Sub Mesh related stage step action
  71584. */
  71585. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71586. /**
  71587. * Strong typing of a Active Mesh related stage step action
  71588. */
  71589. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71590. /**
  71591. * Strong typing of a Camera related stage step action
  71592. */
  71593. export type CameraStageAction = (camera: Camera) => void;
  71594. /**
  71595. * Strong typing of a Camera Frame buffer related stage step action
  71596. */
  71597. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71598. /**
  71599. * Strong typing of a Render Target related stage step action
  71600. */
  71601. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71602. /**
  71603. * Strong typing of a RenderingGroup related stage step action
  71604. */
  71605. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71606. /**
  71607. * Strong typing of a Mesh Render related stage step action
  71608. */
  71609. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71610. /**
  71611. * Strong typing of a simple stage step action
  71612. */
  71613. export type SimpleStageAction = () => void;
  71614. /**
  71615. * Strong typing of a render target action.
  71616. */
  71617. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71618. /**
  71619. * Strong typing of a pointer move action.
  71620. */
  71621. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71622. /**
  71623. * Strong typing of a pointer up/down action.
  71624. */
  71625. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71626. /**
  71627. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71628. * @hidden
  71629. */
  71630. export class Stage<T extends Function> extends Array<{
  71631. index: number;
  71632. component: ISceneComponent;
  71633. action: T;
  71634. }> {
  71635. /**
  71636. * Hide ctor from the rest of the world.
  71637. * @param items The items to add.
  71638. */
  71639. private constructor();
  71640. /**
  71641. * Creates a new Stage.
  71642. * @returns A new instance of a Stage
  71643. */
  71644. static Create<T extends Function>(): Stage<T>;
  71645. /**
  71646. * Registers a step in an ordered way in the targeted stage.
  71647. * @param index Defines the position to register the step in
  71648. * @param component Defines the component attached to the step
  71649. * @param action Defines the action to launch during the step
  71650. */
  71651. registerStep(index: number, component: ISceneComponent, action: T): void;
  71652. /**
  71653. * Clears all the steps from the stage.
  71654. */
  71655. clear(): void;
  71656. }
  71657. }
  71658. declare module BABYLON {
  71659. interface Scene {
  71660. /** @hidden */
  71661. _pointerOverSprite: Nullable<Sprite>;
  71662. /** @hidden */
  71663. _pickedDownSprite: Nullable<Sprite>;
  71664. /** @hidden */
  71665. _tempSpritePickingRay: Nullable<Ray>;
  71666. /**
  71667. * All of the sprite managers added to this scene
  71668. * @see http://doc.babylonjs.com/babylon101/sprites
  71669. */
  71670. spriteManagers: Array<ISpriteManager>;
  71671. /**
  71672. * An event triggered when sprites rendering is about to start
  71673. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71674. */
  71675. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71676. /**
  71677. * An event triggered when sprites rendering is done
  71678. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71679. */
  71680. onAfterSpritesRenderingObservable: Observable<Scene>;
  71681. /** @hidden */
  71682. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71683. /** Launch a ray to try to pick a sprite in the scene
  71684. * @param x position on screen
  71685. * @param y position on screen
  71686. * @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
  71687. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71688. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71689. * @returns a PickingInfo
  71690. */
  71691. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71692. /** Use the given ray to pick a sprite in the scene
  71693. * @param ray The ray (in world space) to use to pick meshes
  71694. * @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
  71695. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71696. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71697. * @returns a PickingInfo
  71698. */
  71699. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71700. /**
  71701. * Force the sprite under the pointer
  71702. * @param sprite defines the sprite to use
  71703. */
  71704. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71705. /**
  71706. * Gets the sprite under the pointer
  71707. * @returns a Sprite or null if no sprite is under the pointer
  71708. */
  71709. getPointerOverSprite(): Nullable<Sprite>;
  71710. }
  71711. /**
  71712. * Defines the sprite scene component responsible to manage sprites
  71713. * in a given scene.
  71714. */
  71715. export class SpriteSceneComponent implements ISceneComponent {
  71716. /**
  71717. * The component name helpfull to identify the component in the list of scene components.
  71718. */
  71719. readonly name: string;
  71720. /**
  71721. * The scene the component belongs to.
  71722. */
  71723. scene: Scene;
  71724. /** @hidden */
  71725. private _spritePredicate;
  71726. /**
  71727. * Creates a new instance of the component for the given scene
  71728. * @param scene Defines the scene to register the component in
  71729. */
  71730. constructor(scene: Scene);
  71731. /**
  71732. * Registers the component in a given scene
  71733. */
  71734. register(): void;
  71735. /**
  71736. * Rebuilds the elements related to this component in case of
  71737. * context lost for instance.
  71738. */
  71739. rebuild(): void;
  71740. /**
  71741. * Disposes the component and the associated ressources.
  71742. */
  71743. dispose(): void;
  71744. private _pickSpriteButKeepRay;
  71745. private _pointerMove;
  71746. private _pointerDown;
  71747. private _pointerUp;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /** @hidden */
  71752. export var fogFragmentDeclaration: {
  71753. name: string;
  71754. shader: string;
  71755. };
  71756. }
  71757. declare module BABYLON {
  71758. /** @hidden */
  71759. export var fogFragment: {
  71760. name: string;
  71761. shader: string;
  71762. };
  71763. }
  71764. declare module BABYLON {
  71765. /** @hidden */
  71766. export var spritesPixelShader: {
  71767. name: string;
  71768. shader: string;
  71769. };
  71770. }
  71771. declare module BABYLON {
  71772. /** @hidden */
  71773. export var fogVertexDeclaration: {
  71774. name: string;
  71775. shader: string;
  71776. };
  71777. }
  71778. declare module BABYLON {
  71779. /** @hidden */
  71780. export var spritesVertexShader: {
  71781. name: string;
  71782. shader: string;
  71783. };
  71784. }
  71785. declare module BABYLON {
  71786. /**
  71787. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71788. */
  71789. export interface ISpriteManager extends IDisposable {
  71790. /**
  71791. * Restricts the camera to viewing objects with the same layerMask.
  71792. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71793. */
  71794. layerMask: number;
  71795. /**
  71796. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71797. */
  71798. isPickable: boolean;
  71799. /**
  71800. * Specifies the rendering group id for this mesh (0 by default)
  71801. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71802. */
  71803. renderingGroupId: number;
  71804. /**
  71805. * Defines the list of sprites managed by the manager.
  71806. */
  71807. sprites: Array<Sprite>;
  71808. /**
  71809. * Tests the intersection of a sprite with a specific ray.
  71810. * @param ray The ray we are sending to test the collision
  71811. * @param camera The camera space we are sending rays in
  71812. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71813. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71814. * @returns picking info or null.
  71815. */
  71816. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71817. /**
  71818. * Renders the list of sprites on screen.
  71819. */
  71820. render(): void;
  71821. }
  71822. /**
  71823. * Class used to manage multiple sprites on the same spritesheet
  71824. * @see http://doc.babylonjs.com/babylon101/sprites
  71825. */
  71826. export class SpriteManager implements ISpriteManager {
  71827. /** defines the manager's name */
  71828. name: string;
  71829. /** Gets the list of sprites */
  71830. sprites: Sprite[];
  71831. /** Gets or sets the rendering group id (0 by default) */
  71832. renderingGroupId: number;
  71833. /** Gets or sets camera layer mask */
  71834. layerMask: number;
  71835. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71836. fogEnabled: boolean;
  71837. /** Gets or sets a boolean indicating if the sprites are pickable */
  71838. isPickable: boolean;
  71839. /** Defines the default width of a cell in the spritesheet */
  71840. cellWidth: number;
  71841. /** Defines the default height of a cell in the spritesheet */
  71842. cellHeight: number;
  71843. /**
  71844. * An event triggered when the manager is disposed.
  71845. */
  71846. onDisposeObservable: Observable<SpriteManager>;
  71847. private _onDisposeObserver;
  71848. /**
  71849. * Callback called when the manager is disposed
  71850. */
  71851. onDispose: () => void;
  71852. private _capacity;
  71853. private _spriteTexture;
  71854. private _epsilon;
  71855. private _scene;
  71856. private _vertexData;
  71857. private _buffer;
  71858. private _vertexBuffers;
  71859. private _indexBuffer;
  71860. private _effectBase;
  71861. private _effectFog;
  71862. /**
  71863. * Gets or sets the spritesheet texture
  71864. */
  71865. texture: Texture;
  71866. /**
  71867. * Creates a new sprite manager
  71868. * @param name defines the manager's name
  71869. * @param imgUrl defines the sprite sheet url
  71870. * @param capacity defines the maximum allowed number of sprites
  71871. * @param cellSize defines the size of a sprite cell
  71872. * @param scene defines the hosting scene
  71873. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71874. * @param samplingMode defines the smapling mode to use with spritesheet
  71875. */
  71876. constructor(
  71877. /** defines the manager's name */
  71878. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71879. private _appendSpriteVertex;
  71880. /**
  71881. * Intersects the sprites with a ray
  71882. * @param ray defines the ray to intersect with
  71883. * @param camera defines the current active camera
  71884. * @param predicate defines a predicate used to select candidate sprites
  71885. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71886. * @returns null if no hit or a PickingInfo
  71887. */
  71888. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71889. /**
  71890. * Render all child sprites
  71891. */
  71892. render(): void;
  71893. /**
  71894. * Release associated resources
  71895. */
  71896. dispose(): void;
  71897. }
  71898. }
  71899. declare module BABYLON {
  71900. /**
  71901. * Class used to represent a sprite
  71902. * @see http://doc.babylonjs.com/babylon101/sprites
  71903. */
  71904. export class Sprite {
  71905. /** defines the name */
  71906. name: string;
  71907. /** Gets or sets the current world position */
  71908. position: Vector3;
  71909. /** Gets or sets the main color */
  71910. color: Color4;
  71911. /** Gets or sets the width */
  71912. width: number;
  71913. /** Gets or sets the height */
  71914. height: number;
  71915. /** Gets or sets rotation angle */
  71916. angle: number;
  71917. /** Gets or sets the cell index in the sprite sheet */
  71918. cellIndex: number;
  71919. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71920. invertU: number;
  71921. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71922. invertV: number;
  71923. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71924. disposeWhenFinishedAnimating: boolean;
  71925. /** Gets the list of attached animations */
  71926. animations: Animation[];
  71927. /** Gets or sets a boolean indicating if the sprite can be picked */
  71928. isPickable: boolean;
  71929. /**
  71930. * Gets or sets the associated action manager
  71931. */
  71932. actionManager: Nullable<ActionManager>;
  71933. private _animationStarted;
  71934. private _loopAnimation;
  71935. private _fromIndex;
  71936. private _toIndex;
  71937. private _delay;
  71938. private _direction;
  71939. private _manager;
  71940. private _time;
  71941. private _onAnimationEnd;
  71942. /**
  71943. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71944. */
  71945. isVisible: boolean;
  71946. /**
  71947. * Gets or sets the sprite size
  71948. */
  71949. size: number;
  71950. /**
  71951. * Creates a new Sprite
  71952. * @param name defines the name
  71953. * @param manager defines the manager
  71954. */
  71955. constructor(
  71956. /** defines the name */
  71957. name: string, manager: ISpriteManager);
  71958. /**
  71959. * Starts an animation
  71960. * @param from defines the initial key
  71961. * @param to defines the end key
  71962. * @param loop defines if the animation must loop
  71963. * @param delay defines the start delay (in ms)
  71964. * @param onAnimationEnd defines a callback to call when animation ends
  71965. */
  71966. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71967. /** Stops current animation (if any) */
  71968. stopAnimation(): void;
  71969. /** @hidden */
  71970. _animate(deltaTime: number): void;
  71971. /** Release associated resources */
  71972. dispose(): void;
  71973. }
  71974. }
  71975. declare module BABYLON {
  71976. /**
  71977. * Information about the result of picking within a scene
  71978. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71979. */
  71980. export class PickingInfo {
  71981. /** @hidden */
  71982. _pickingUnavailable: boolean;
  71983. /**
  71984. * If the pick collided with an object
  71985. */
  71986. hit: boolean;
  71987. /**
  71988. * Distance away where the pick collided
  71989. */
  71990. distance: number;
  71991. /**
  71992. * The location of pick collision
  71993. */
  71994. pickedPoint: Nullable<Vector3>;
  71995. /**
  71996. * The mesh corresponding the the pick collision
  71997. */
  71998. pickedMesh: Nullable<AbstractMesh>;
  71999. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  72000. bu: number;
  72001. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  72002. bv: number;
  72003. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  72004. faceId: number;
  72005. /** Id of the the submesh that was picked */
  72006. subMeshId: number;
  72007. /** If a sprite was picked, this will be the sprite the pick collided with */
  72008. pickedSprite: Nullable<Sprite>;
  72009. /**
  72010. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  72011. */
  72012. originMesh: Nullable<AbstractMesh>;
  72013. /**
  72014. * The ray that was used to perform the picking.
  72015. */
  72016. ray: Nullable<Ray>;
  72017. /**
  72018. * Gets the normal correspodning to the face the pick collided with
  72019. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  72020. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  72021. * @returns The normal correspodning to the face the pick collided with
  72022. */
  72023. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  72024. /**
  72025. * Gets the texture coordinates of where the pick occured
  72026. * @returns the vector containing the coordnates of the texture
  72027. */
  72028. getTextureCoordinates(): Nullable<Vector2>;
  72029. }
  72030. }
  72031. declare module BABYLON {
  72032. /**
  72033. * Gather the list of pointer event types as constants.
  72034. */
  72035. export class PointerEventTypes {
  72036. /**
  72037. * 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.
  72038. */
  72039. static readonly POINTERDOWN: number;
  72040. /**
  72041. * The pointerup event is fired when a pointer is no longer active.
  72042. */
  72043. static readonly POINTERUP: number;
  72044. /**
  72045. * The pointermove event is fired when a pointer changes coordinates.
  72046. */
  72047. static readonly POINTERMOVE: number;
  72048. /**
  72049. * The pointerwheel event is fired when a mouse wheel has been rotated.
  72050. */
  72051. static readonly POINTERWHEEL: number;
  72052. /**
  72053. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  72054. */
  72055. static readonly POINTERPICK: number;
  72056. /**
  72057. * The pointertap event is fired when a the object has been touched and released without drag.
  72058. */
  72059. static readonly POINTERTAP: number;
  72060. /**
  72061. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  72062. */
  72063. static readonly POINTERDOUBLETAP: number;
  72064. }
  72065. /**
  72066. * Base class of pointer info types.
  72067. */
  72068. export class PointerInfoBase {
  72069. /**
  72070. * Defines the type of event (PointerEventTypes)
  72071. */
  72072. type: number;
  72073. /**
  72074. * Defines the related dom event
  72075. */
  72076. event: PointerEvent | MouseWheelEvent;
  72077. /**
  72078. * Instantiates the base class of pointers info.
  72079. * @param type Defines the type of event (PointerEventTypes)
  72080. * @param event Defines the related dom event
  72081. */
  72082. constructor(
  72083. /**
  72084. * Defines the type of event (PointerEventTypes)
  72085. */
  72086. type: number,
  72087. /**
  72088. * Defines the related dom event
  72089. */
  72090. event: PointerEvent | MouseWheelEvent);
  72091. }
  72092. /**
  72093. * This class is used to store pointer related info for the onPrePointerObservable event.
  72094. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  72095. */
  72096. export class PointerInfoPre extends PointerInfoBase {
  72097. /**
  72098. * Ray from a pointer if availible (eg. 6dof controller)
  72099. */
  72100. ray: Nullable<Ray>;
  72101. /**
  72102. * Defines the local position of the pointer on the canvas.
  72103. */
  72104. localPosition: Vector2;
  72105. /**
  72106. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  72107. */
  72108. skipOnPointerObservable: boolean;
  72109. /**
  72110. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  72111. * @param type Defines the type of event (PointerEventTypes)
  72112. * @param event Defines the related dom event
  72113. * @param localX Defines the local x coordinates of the pointer when the event occured
  72114. * @param localY Defines the local y coordinates of the pointer when the event occured
  72115. */
  72116. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  72117. }
  72118. /**
  72119. * This type contains all the data related to a pointer event in Babylon.js.
  72120. * 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.
  72121. */
  72122. export class PointerInfo extends PointerInfoBase {
  72123. /**
  72124. * Defines the picking info associated to the info (if any)\
  72125. */
  72126. pickInfo: Nullable<PickingInfo>;
  72127. /**
  72128. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  72129. * @param type Defines the type of event (PointerEventTypes)
  72130. * @param event Defines the related dom event
  72131. * @param pickInfo Defines the picking info associated to the info (if any)\
  72132. */
  72133. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  72134. /**
  72135. * Defines the picking info associated to the info (if any)\
  72136. */
  72137. pickInfo: Nullable<PickingInfo>);
  72138. }
  72139. /**
  72140. * Data relating to a touch event on the screen.
  72141. */
  72142. export interface PointerTouch {
  72143. /**
  72144. * X coordinate of touch.
  72145. */
  72146. x: number;
  72147. /**
  72148. * Y coordinate of touch.
  72149. */
  72150. y: number;
  72151. /**
  72152. * Id of touch. Unique for each finger.
  72153. */
  72154. pointerId: number;
  72155. /**
  72156. * Event type passed from DOM.
  72157. */
  72158. type: any;
  72159. }
  72160. }
  72161. declare module BABYLON {
  72162. /**
  72163. * Manage the mouse inputs to control the movement of a free camera.
  72164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72165. */
  72166. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  72167. /**
  72168. * Define if touch is enabled in the mouse input
  72169. */
  72170. touchEnabled: boolean;
  72171. /**
  72172. * Defines the camera the input is attached to.
  72173. */
  72174. camera: FreeCamera;
  72175. /**
  72176. * Defines the buttons associated with the input to handle camera move.
  72177. */
  72178. buttons: number[];
  72179. /**
  72180. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  72181. */
  72182. angularSensibility: number;
  72183. private _pointerInput;
  72184. private _onMouseMove;
  72185. private _observer;
  72186. private previousPosition;
  72187. /**
  72188. * Observable for when a pointer move event occurs containing the move offset
  72189. */
  72190. onPointerMovedObservable: Observable<{
  72191. offsetX: number;
  72192. offsetY: number;
  72193. }>;
  72194. /**
  72195. * @hidden
  72196. * If the camera should be rotated automatically based on pointer movement
  72197. */
  72198. _allowCameraRotation: boolean;
  72199. /**
  72200. * Manage the mouse inputs to control the movement of a free camera.
  72201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72202. * @param touchEnabled Defines if touch is enabled or not
  72203. */
  72204. constructor(
  72205. /**
  72206. * Define if touch is enabled in the mouse input
  72207. */
  72208. touchEnabled?: boolean);
  72209. /**
  72210. * Attach the input controls to a specific dom element to get the input from.
  72211. * @param element Defines the element the controls should be listened from
  72212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72213. */
  72214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72215. /**
  72216. * Called on JS contextmenu event.
  72217. * Override this method to provide functionality.
  72218. */
  72219. protected onContextMenu(evt: PointerEvent): void;
  72220. /**
  72221. * Detach the current controls from the specified dom element.
  72222. * @param element Defines the element to stop listening the inputs from
  72223. */
  72224. detachControl(element: Nullable<HTMLElement>): void;
  72225. /**
  72226. * Gets the class name of the current intput.
  72227. * @returns the class name
  72228. */
  72229. getClassName(): string;
  72230. /**
  72231. * Get the friendly name associated with the input class.
  72232. * @returns the input friendly name
  72233. */
  72234. getSimpleName(): string;
  72235. }
  72236. }
  72237. declare module BABYLON {
  72238. /**
  72239. * Manage the touch inputs to control the movement of a free camera.
  72240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72241. */
  72242. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  72243. /**
  72244. * Defines the camera the input is attached to.
  72245. */
  72246. camera: FreeCamera;
  72247. /**
  72248. * Defines the touch sensibility for rotation.
  72249. * The higher the faster.
  72250. */
  72251. touchAngularSensibility: number;
  72252. /**
  72253. * Defines the touch sensibility for move.
  72254. * The higher the faster.
  72255. */
  72256. touchMoveSensibility: number;
  72257. private _offsetX;
  72258. private _offsetY;
  72259. private _pointerPressed;
  72260. private _pointerInput;
  72261. private _observer;
  72262. private _onLostFocus;
  72263. /**
  72264. * Attach the input controls to a specific dom element to get the input from.
  72265. * @param element Defines the element the controls should be listened from
  72266. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72267. */
  72268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72269. /**
  72270. * Detach the current controls from the specified dom element.
  72271. * @param element Defines the element to stop listening the inputs from
  72272. */
  72273. detachControl(element: Nullable<HTMLElement>): void;
  72274. /**
  72275. * Update the current camera state depending on the inputs that have been used this frame.
  72276. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72277. */
  72278. checkInputs(): void;
  72279. /**
  72280. * Gets the class name of the current intput.
  72281. * @returns the class name
  72282. */
  72283. getClassName(): string;
  72284. /**
  72285. * Get the friendly name associated with the input class.
  72286. * @returns the input friendly name
  72287. */
  72288. getSimpleName(): string;
  72289. }
  72290. }
  72291. declare module BABYLON {
  72292. /**
  72293. * Default Inputs manager for the FreeCamera.
  72294. * It groups all the default supported inputs for ease of use.
  72295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72296. */
  72297. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  72298. /**
  72299. * @hidden
  72300. */
  72301. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  72302. /**
  72303. * @hidden
  72304. */
  72305. _mouseInput: Nullable<FreeCameraMouseInput>;
  72306. /**
  72307. * Instantiates a new FreeCameraInputsManager.
  72308. * @param camera Defines the camera the inputs belong to
  72309. */
  72310. constructor(camera: FreeCamera);
  72311. /**
  72312. * Add keyboard input support to the input manager.
  72313. * @returns the current input manager
  72314. */
  72315. addKeyboard(): FreeCameraInputsManager;
  72316. /**
  72317. * Add mouse input support to the input manager.
  72318. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  72319. * @returns the current input manager
  72320. */
  72321. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  72322. /**
  72323. * Removes the mouse input support from the manager
  72324. * @returns the current input manager
  72325. */
  72326. removeMouse(): FreeCameraInputsManager;
  72327. /**
  72328. * Add touch input support to the input manager.
  72329. * @returns the current input manager
  72330. */
  72331. addTouch(): FreeCameraInputsManager;
  72332. }
  72333. }
  72334. declare module BABYLON {
  72335. /**
  72336. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72337. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  72338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72339. */
  72340. export class FreeCamera extends TargetCamera {
  72341. /**
  72342. * Define the collision ellipsoid of the camera.
  72343. * This is helpful to simulate a camera body like the player body around the camera
  72344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  72345. */
  72346. ellipsoid: Vector3;
  72347. /**
  72348. * Define an offset for the position of the ellipsoid around the camera.
  72349. * This can be helpful to determine the center of the body near the gravity center of the body
  72350. * instead of its head.
  72351. */
  72352. ellipsoidOffset: Vector3;
  72353. /**
  72354. * Enable or disable collisions of the camera with the rest of the scene objects.
  72355. */
  72356. checkCollisions: boolean;
  72357. /**
  72358. * Enable or disable gravity on the camera.
  72359. */
  72360. applyGravity: boolean;
  72361. /**
  72362. * Define the input manager associated to the camera.
  72363. */
  72364. inputs: FreeCameraInputsManager;
  72365. /**
  72366. * Gets the input sensibility for a mouse input. (default is 2000.0)
  72367. * Higher values reduce sensitivity.
  72368. */
  72369. /**
  72370. * Sets the input sensibility for a mouse input. (default is 2000.0)
  72371. * Higher values reduce sensitivity.
  72372. */
  72373. angularSensibility: number;
  72374. /**
  72375. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72376. */
  72377. keysUp: number[];
  72378. /**
  72379. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72380. */
  72381. keysDown: number[];
  72382. /**
  72383. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72384. */
  72385. keysLeft: number[];
  72386. /**
  72387. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72388. */
  72389. keysRight: number[];
  72390. /**
  72391. * Event raised when the camera collide with a mesh in the scene.
  72392. */
  72393. onCollide: (collidedMesh: AbstractMesh) => void;
  72394. private _collider;
  72395. private _needMoveForGravity;
  72396. private _oldPosition;
  72397. private _diffPosition;
  72398. private _newPosition;
  72399. /** @hidden */
  72400. _localDirection: Vector3;
  72401. /** @hidden */
  72402. _transformedDirection: Vector3;
  72403. /**
  72404. * Instantiates a Free Camera.
  72405. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  72406. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  72407. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  72408. * @param name Define the name of the camera in the scene
  72409. * @param position Define the start position of the camera in the scene
  72410. * @param scene Define the scene the camera belongs to
  72411. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72412. */
  72413. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72414. /**
  72415. * Attached controls to the current camera.
  72416. * @param element Defines the element the controls should be listened from
  72417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72418. */
  72419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72420. /**
  72421. * Detach the current controls from the camera.
  72422. * The camera will stop reacting to inputs.
  72423. * @param element Defines the element to stop listening the inputs from
  72424. */
  72425. detachControl(element: HTMLElement): void;
  72426. private _collisionMask;
  72427. /**
  72428. * Define a collision mask to limit the list of object the camera can collide with
  72429. */
  72430. collisionMask: number;
  72431. /** @hidden */
  72432. _collideWithWorld(displacement: Vector3): void;
  72433. private _onCollisionPositionChange;
  72434. /** @hidden */
  72435. _checkInputs(): void;
  72436. /** @hidden */
  72437. _decideIfNeedsToMove(): boolean;
  72438. /** @hidden */
  72439. _updatePosition(): void;
  72440. /**
  72441. * Destroy the camera and release the current resources hold by it.
  72442. */
  72443. dispose(): void;
  72444. /**
  72445. * Gets the current object class name.
  72446. * @return the class name
  72447. */
  72448. getClassName(): string;
  72449. }
  72450. }
  72451. declare module BABYLON {
  72452. /**
  72453. * Represents a gamepad control stick position
  72454. */
  72455. export class StickValues {
  72456. /**
  72457. * The x component of the control stick
  72458. */
  72459. x: number;
  72460. /**
  72461. * The y component of the control stick
  72462. */
  72463. y: number;
  72464. /**
  72465. * Initializes the gamepad x and y control stick values
  72466. * @param x The x component of the gamepad control stick value
  72467. * @param y The y component of the gamepad control stick value
  72468. */
  72469. constructor(
  72470. /**
  72471. * The x component of the control stick
  72472. */
  72473. x: number,
  72474. /**
  72475. * The y component of the control stick
  72476. */
  72477. y: number);
  72478. }
  72479. /**
  72480. * An interface which manages callbacks for gamepad button changes
  72481. */
  72482. export interface GamepadButtonChanges {
  72483. /**
  72484. * Called when a gamepad has been changed
  72485. */
  72486. changed: boolean;
  72487. /**
  72488. * Called when a gamepad press event has been triggered
  72489. */
  72490. pressChanged: boolean;
  72491. /**
  72492. * Called when a touch event has been triggered
  72493. */
  72494. touchChanged: boolean;
  72495. /**
  72496. * Called when a value has changed
  72497. */
  72498. valueChanged: boolean;
  72499. }
  72500. /**
  72501. * Represents a gamepad
  72502. */
  72503. export class Gamepad {
  72504. /**
  72505. * The id of the gamepad
  72506. */
  72507. id: string;
  72508. /**
  72509. * The index of the gamepad
  72510. */
  72511. index: number;
  72512. /**
  72513. * The browser gamepad
  72514. */
  72515. browserGamepad: any;
  72516. /**
  72517. * Specifies what type of gamepad this represents
  72518. */
  72519. type: number;
  72520. private _leftStick;
  72521. private _rightStick;
  72522. /** @hidden */
  72523. _isConnected: boolean;
  72524. private _leftStickAxisX;
  72525. private _leftStickAxisY;
  72526. private _rightStickAxisX;
  72527. private _rightStickAxisY;
  72528. /**
  72529. * Triggered when the left control stick has been changed
  72530. */
  72531. private _onleftstickchanged;
  72532. /**
  72533. * Triggered when the right control stick has been changed
  72534. */
  72535. private _onrightstickchanged;
  72536. /**
  72537. * Represents a gamepad controller
  72538. */
  72539. static GAMEPAD: number;
  72540. /**
  72541. * Represents a generic controller
  72542. */
  72543. static GENERIC: number;
  72544. /**
  72545. * Represents an XBox controller
  72546. */
  72547. static XBOX: number;
  72548. /**
  72549. * Represents a pose-enabled controller
  72550. */
  72551. static POSE_ENABLED: number;
  72552. /**
  72553. * Specifies whether the left control stick should be Y-inverted
  72554. */
  72555. protected _invertLeftStickY: boolean;
  72556. /**
  72557. * Specifies if the gamepad has been connected
  72558. */
  72559. readonly isConnected: boolean;
  72560. /**
  72561. * Initializes the gamepad
  72562. * @param id The id of the gamepad
  72563. * @param index The index of the gamepad
  72564. * @param browserGamepad The browser gamepad
  72565. * @param leftStickX The x component of the left joystick
  72566. * @param leftStickY The y component of the left joystick
  72567. * @param rightStickX The x component of the right joystick
  72568. * @param rightStickY The y component of the right joystick
  72569. */
  72570. constructor(
  72571. /**
  72572. * The id of the gamepad
  72573. */
  72574. id: string,
  72575. /**
  72576. * The index of the gamepad
  72577. */
  72578. index: number,
  72579. /**
  72580. * The browser gamepad
  72581. */
  72582. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72583. /**
  72584. * Callback triggered when the left joystick has changed
  72585. * @param callback
  72586. */
  72587. onleftstickchanged(callback: (values: StickValues) => void): void;
  72588. /**
  72589. * Callback triggered when the right joystick has changed
  72590. * @param callback
  72591. */
  72592. onrightstickchanged(callback: (values: StickValues) => void): void;
  72593. /**
  72594. * Gets the left joystick
  72595. */
  72596. /**
  72597. * Sets the left joystick values
  72598. */
  72599. leftStick: StickValues;
  72600. /**
  72601. * Gets the right joystick
  72602. */
  72603. /**
  72604. * Sets the right joystick value
  72605. */
  72606. rightStick: StickValues;
  72607. /**
  72608. * Updates the gamepad joystick positions
  72609. */
  72610. update(): void;
  72611. /**
  72612. * Disposes the gamepad
  72613. */
  72614. dispose(): void;
  72615. }
  72616. /**
  72617. * Represents a generic gamepad
  72618. */
  72619. export class GenericPad extends Gamepad {
  72620. private _buttons;
  72621. private _onbuttondown;
  72622. private _onbuttonup;
  72623. /**
  72624. * Observable triggered when a button has been pressed
  72625. */
  72626. onButtonDownObservable: Observable<number>;
  72627. /**
  72628. * Observable triggered when a button has been released
  72629. */
  72630. onButtonUpObservable: Observable<number>;
  72631. /**
  72632. * Callback triggered when a button has been pressed
  72633. * @param callback Called when a button has been pressed
  72634. */
  72635. onbuttondown(callback: (buttonPressed: number) => void): void;
  72636. /**
  72637. * Callback triggered when a button has been released
  72638. * @param callback Called when a button has been released
  72639. */
  72640. onbuttonup(callback: (buttonReleased: number) => void): void;
  72641. /**
  72642. * Initializes the generic gamepad
  72643. * @param id The id of the generic gamepad
  72644. * @param index The index of the generic gamepad
  72645. * @param browserGamepad The browser gamepad
  72646. */
  72647. constructor(id: string, index: number, browserGamepad: any);
  72648. private _setButtonValue;
  72649. /**
  72650. * Updates the generic gamepad
  72651. */
  72652. update(): void;
  72653. /**
  72654. * Disposes the generic gamepad
  72655. */
  72656. dispose(): void;
  72657. }
  72658. }
  72659. declare module BABYLON {
  72660. /**
  72661. * Defines the types of pose enabled controllers that are supported
  72662. */
  72663. export enum PoseEnabledControllerType {
  72664. /**
  72665. * HTC Vive
  72666. */
  72667. VIVE = 0,
  72668. /**
  72669. * Oculus Rift
  72670. */
  72671. OCULUS = 1,
  72672. /**
  72673. * Windows mixed reality
  72674. */
  72675. WINDOWS = 2,
  72676. /**
  72677. * Samsung gear VR
  72678. */
  72679. GEAR_VR = 3,
  72680. /**
  72681. * Google Daydream
  72682. */
  72683. DAYDREAM = 4,
  72684. /**
  72685. * Generic
  72686. */
  72687. GENERIC = 5
  72688. }
  72689. /**
  72690. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72691. */
  72692. export interface MutableGamepadButton {
  72693. /**
  72694. * Value of the button/trigger
  72695. */
  72696. value: number;
  72697. /**
  72698. * If the button/trigger is currently touched
  72699. */
  72700. touched: boolean;
  72701. /**
  72702. * If the button/trigger is currently pressed
  72703. */
  72704. pressed: boolean;
  72705. }
  72706. /**
  72707. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72708. * @hidden
  72709. */
  72710. export interface ExtendedGamepadButton extends GamepadButton {
  72711. /**
  72712. * If the button/trigger is currently pressed
  72713. */
  72714. readonly pressed: boolean;
  72715. /**
  72716. * If the button/trigger is currently touched
  72717. */
  72718. readonly touched: boolean;
  72719. /**
  72720. * Value of the button/trigger
  72721. */
  72722. readonly value: number;
  72723. }
  72724. /** @hidden */
  72725. export interface _GamePadFactory {
  72726. /**
  72727. * Returns wether or not the current gamepad can be created for this type of controller.
  72728. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72729. * @returns true if it can be created, otherwise false
  72730. */
  72731. canCreate(gamepadInfo: any): boolean;
  72732. /**
  72733. * Creates a new instance of the Gamepad.
  72734. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72735. * @returns the new gamepad instance
  72736. */
  72737. create(gamepadInfo: any): Gamepad;
  72738. }
  72739. /**
  72740. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72741. */
  72742. export class PoseEnabledControllerHelper {
  72743. /** @hidden */
  72744. static _ControllerFactories: _GamePadFactory[];
  72745. /** @hidden */
  72746. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72747. /**
  72748. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72749. * @param vrGamepad the gamepad to initialized
  72750. * @returns a vr controller of the type the gamepad identified as
  72751. */
  72752. static InitiateController(vrGamepad: any): Gamepad;
  72753. }
  72754. /**
  72755. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72756. */
  72757. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72758. private _deviceRoomPosition;
  72759. private _deviceRoomRotationQuaternion;
  72760. /**
  72761. * The device position in babylon space
  72762. */
  72763. devicePosition: Vector3;
  72764. /**
  72765. * The device rotation in babylon space
  72766. */
  72767. deviceRotationQuaternion: Quaternion;
  72768. /**
  72769. * The scale factor of the device in babylon space
  72770. */
  72771. deviceScaleFactor: number;
  72772. /**
  72773. * (Likely devicePosition should be used instead) The device position in its room space
  72774. */
  72775. position: Vector3;
  72776. /**
  72777. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72778. */
  72779. rotationQuaternion: Quaternion;
  72780. /**
  72781. * The type of controller (Eg. Windows mixed reality)
  72782. */
  72783. controllerType: PoseEnabledControllerType;
  72784. protected _calculatedPosition: Vector3;
  72785. private _calculatedRotation;
  72786. /**
  72787. * The raw pose from the device
  72788. */
  72789. rawPose: DevicePose;
  72790. private _trackPosition;
  72791. private _maxRotationDistFromHeadset;
  72792. private _draggedRoomRotation;
  72793. /**
  72794. * @hidden
  72795. */
  72796. _disableTrackPosition(fixedPosition: Vector3): void;
  72797. /**
  72798. * Internal, the mesh attached to the controller
  72799. * @hidden
  72800. */
  72801. _mesh: Nullable<AbstractMesh>;
  72802. private _poseControlledCamera;
  72803. private _leftHandSystemQuaternion;
  72804. /**
  72805. * Internal, matrix used to convert room space to babylon space
  72806. * @hidden
  72807. */
  72808. _deviceToWorld: Matrix;
  72809. /**
  72810. * Node to be used when casting a ray from the controller
  72811. * @hidden
  72812. */
  72813. _pointingPoseNode: Nullable<TransformNode>;
  72814. /**
  72815. * Name of the child mesh that can be used to cast a ray from the controller
  72816. */
  72817. static readonly POINTING_POSE: string;
  72818. /**
  72819. * Creates a new PoseEnabledController from a gamepad
  72820. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72821. */
  72822. constructor(browserGamepad: any);
  72823. private _workingMatrix;
  72824. /**
  72825. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72826. */
  72827. update(): void;
  72828. /**
  72829. * Updates only the pose device and mesh without doing any button event checking
  72830. */
  72831. protected _updatePoseAndMesh(): void;
  72832. /**
  72833. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72834. * @param poseData raw pose fromthe device
  72835. */
  72836. updateFromDevice(poseData: DevicePose): void;
  72837. /**
  72838. * @hidden
  72839. */
  72840. _meshAttachedObservable: Observable<AbstractMesh>;
  72841. /**
  72842. * Attaches a mesh to the controller
  72843. * @param mesh the mesh to be attached
  72844. */
  72845. attachToMesh(mesh: AbstractMesh): void;
  72846. /**
  72847. * Attaches the controllers mesh to a camera
  72848. * @param camera the camera the mesh should be attached to
  72849. */
  72850. attachToPoseControlledCamera(camera: TargetCamera): void;
  72851. /**
  72852. * Disposes of the controller
  72853. */
  72854. dispose(): void;
  72855. /**
  72856. * The mesh that is attached to the controller
  72857. */
  72858. readonly mesh: Nullable<AbstractMesh>;
  72859. /**
  72860. * Gets the ray of the controller in the direction the controller is pointing
  72861. * @param length the length the resulting ray should be
  72862. * @returns a ray in the direction the controller is pointing
  72863. */
  72864. getForwardRay(length?: number): Ray;
  72865. }
  72866. }
  72867. declare module BABYLON {
  72868. /**
  72869. * Defines the WebVRController object that represents controllers tracked in 3D space
  72870. */
  72871. export abstract class WebVRController extends PoseEnabledController {
  72872. /**
  72873. * Internal, the default controller model for the controller
  72874. */
  72875. protected _defaultModel: AbstractMesh;
  72876. /**
  72877. * Fired when the trigger state has changed
  72878. */
  72879. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72880. /**
  72881. * Fired when the main button state has changed
  72882. */
  72883. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72884. /**
  72885. * Fired when the secondary button state has changed
  72886. */
  72887. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72888. /**
  72889. * Fired when the pad state has changed
  72890. */
  72891. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72892. /**
  72893. * Fired when controllers stick values have changed
  72894. */
  72895. onPadValuesChangedObservable: Observable<StickValues>;
  72896. /**
  72897. * Array of button availible on the controller
  72898. */
  72899. protected _buttons: Array<MutableGamepadButton>;
  72900. private _onButtonStateChange;
  72901. /**
  72902. * Fired when a controller button's state has changed
  72903. * @param callback the callback containing the button that was modified
  72904. */
  72905. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72906. /**
  72907. * X and Y axis corrisponding to the controllers joystick
  72908. */
  72909. pad: StickValues;
  72910. /**
  72911. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72912. */
  72913. hand: string;
  72914. /**
  72915. * The default controller model for the controller
  72916. */
  72917. readonly defaultModel: AbstractMesh;
  72918. /**
  72919. * Creates a new WebVRController from a gamepad
  72920. * @param vrGamepad the gamepad that the WebVRController should be created from
  72921. */
  72922. constructor(vrGamepad: any);
  72923. /**
  72924. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72925. */
  72926. update(): void;
  72927. /**
  72928. * Function to be called when a button is modified
  72929. */
  72930. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72931. /**
  72932. * Loads a mesh and attaches it to the controller
  72933. * @param scene the scene the mesh should be added to
  72934. * @param meshLoaded callback for when the mesh has been loaded
  72935. */
  72936. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72937. private _setButtonValue;
  72938. private _changes;
  72939. private _checkChanges;
  72940. /**
  72941. * Disposes of th webVRCOntroller
  72942. */
  72943. dispose(): void;
  72944. }
  72945. }
  72946. declare module BABYLON {
  72947. /**
  72948. * The HemisphericLight simulates the ambient environment light,
  72949. * so the passed direction is the light reflection direction, not the incoming direction.
  72950. */
  72951. export class HemisphericLight extends Light {
  72952. /**
  72953. * The groundColor is the light in the opposite direction to the one specified during creation.
  72954. * 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.
  72955. */
  72956. groundColor: Color3;
  72957. /**
  72958. * The light reflection direction, not the incoming direction.
  72959. */
  72960. direction: Vector3;
  72961. /**
  72962. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72963. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72964. * The HemisphericLight can't cast shadows.
  72965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72966. * @param name The friendly name of the light
  72967. * @param direction The direction of the light reflection
  72968. * @param scene The scene the light belongs to
  72969. */
  72970. constructor(name: string, direction: Vector3, scene: Scene);
  72971. protected _buildUniformLayout(): void;
  72972. /**
  72973. * Returns the string "HemisphericLight".
  72974. * @return The class name
  72975. */
  72976. getClassName(): string;
  72977. /**
  72978. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72979. * Returns the updated direction.
  72980. * @param target The target the direction should point to
  72981. * @return The computed direction
  72982. */
  72983. setDirectionToTarget(target: Vector3): Vector3;
  72984. /**
  72985. * Returns the shadow generator associated to the light.
  72986. * @returns Always null for hemispheric lights because it does not support shadows.
  72987. */
  72988. getShadowGenerator(): Nullable<IShadowGenerator>;
  72989. /**
  72990. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72991. * @param effect The effect to update
  72992. * @param lightIndex The index of the light in the effect to update
  72993. * @returns The hemispheric light
  72994. */
  72995. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72996. /**
  72997. * Computes the world matrix of the node
  72998. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72999. * @param useWasUpdatedFlag defines a reserved property
  73000. * @returns the world matrix
  73001. */
  73002. computeWorldMatrix(): Matrix;
  73003. /**
  73004. * Returns the integer 3.
  73005. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73006. */
  73007. getTypeID(): number;
  73008. /**
  73009. * Prepares the list of defines specific to the light type.
  73010. * @param defines the list of defines
  73011. * @param lightIndex defines the index of the light for the effect
  73012. */
  73013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73014. }
  73015. }
  73016. declare module BABYLON {
  73017. /** @hidden */
  73018. export var vrMultiviewToSingleviewPixelShader: {
  73019. name: string;
  73020. shader: string;
  73021. };
  73022. }
  73023. declare module BABYLON {
  73024. /**
  73025. * Renders to multiple views with a single draw call
  73026. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  73027. */
  73028. export class MultiviewRenderTarget extends RenderTargetTexture {
  73029. /**
  73030. * Creates a multiview render target
  73031. * @param scene scene used with the render target
  73032. * @param size the size of the render target (used for each view)
  73033. */
  73034. constructor(scene: Scene, size?: number | {
  73035. width: number;
  73036. height: number;
  73037. } | {
  73038. ratio: number;
  73039. });
  73040. /**
  73041. * @hidden
  73042. * @param faceIndex the face index, if its a cube texture
  73043. */
  73044. _bindFrameBuffer(faceIndex?: number): void;
  73045. /**
  73046. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  73047. * @returns the view count
  73048. */
  73049. getViewCount(): number;
  73050. }
  73051. }
  73052. declare module BABYLON {
  73053. interface Engine {
  73054. /**
  73055. * Creates a new multiview render target
  73056. * @param width defines the width of the texture
  73057. * @param height defines the height of the texture
  73058. * @returns the created multiview texture
  73059. */
  73060. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  73061. /**
  73062. * Binds a multiview framebuffer to be drawn to
  73063. * @param multiviewTexture texture to bind
  73064. */
  73065. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  73066. }
  73067. interface Camera {
  73068. /**
  73069. * @hidden
  73070. * 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)
  73071. */
  73072. _useMultiviewToSingleView: boolean;
  73073. /**
  73074. * @hidden
  73075. * 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)
  73076. */
  73077. _multiviewTexture: Nullable<RenderTargetTexture>;
  73078. /**
  73079. * @hidden
  73080. * ensures the multiview texture of the camera exists and has the specified width/height
  73081. * @param width height to set on the multiview texture
  73082. * @param height width to set on the multiview texture
  73083. */
  73084. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  73085. }
  73086. interface Scene {
  73087. /** @hidden */
  73088. _transformMatrixR: Matrix;
  73089. /** @hidden */
  73090. _multiviewSceneUbo: Nullable<UniformBuffer>;
  73091. /** @hidden */
  73092. _createMultiviewUbo(): void;
  73093. /** @hidden */
  73094. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  73095. /** @hidden */
  73096. _renderMultiviewToSingleView(camera: Camera): void;
  73097. }
  73098. }
  73099. declare module BABYLON {
  73100. /**
  73101. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  73102. * This will not be used for webXR as it supports displaying texture arrays directly
  73103. */
  73104. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  73105. /**
  73106. * Initializes a VRMultiviewToSingleview
  73107. * @param name name of the post process
  73108. * @param camera camera to be applied to
  73109. * @param scaleFactor scaling factor to the size of the output texture
  73110. */
  73111. constructor(name: string, camera: Camera, scaleFactor: number);
  73112. }
  73113. }
  73114. declare module BABYLON {
  73115. /**
  73116. * Defines the interface used by display changed events
  73117. */
  73118. interface IDisplayChangedEventArgs {
  73119. /** Gets the vrDisplay object (if any) */
  73120. vrDisplay: Nullable<any>;
  73121. /** Gets a boolean indicating if webVR is supported */
  73122. vrSupported: boolean;
  73123. }
  73124. interface Engine {
  73125. /** @hidden */
  73126. _vrDisplay: any;
  73127. /** @hidden */
  73128. _vrSupported: boolean;
  73129. /** @hidden */
  73130. _oldSize: Size;
  73131. /** @hidden */
  73132. _oldHardwareScaleFactor: number;
  73133. /** @hidden */
  73134. _vrExclusivePointerMode: boolean;
  73135. /** @hidden */
  73136. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  73137. /** @hidden */
  73138. _onVRDisplayPointerRestricted: () => void;
  73139. /** @hidden */
  73140. _onVRDisplayPointerUnrestricted: () => void;
  73141. /** @hidden */
  73142. _onVrDisplayConnect: Nullable<(display: any) => void>;
  73143. /** @hidden */
  73144. _onVrDisplayDisconnect: Nullable<() => void>;
  73145. /** @hidden */
  73146. _onVrDisplayPresentChange: Nullable<() => void>;
  73147. /**
  73148. * Observable signaled when VR display mode changes
  73149. */
  73150. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  73151. /**
  73152. * Observable signaled when VR request present is complete
  73153. */
  73154. onVRRequestPresentComplete: Observable<boolean>;
  73155. /**
  73156. * Observable signaled when VR request present starts
  73157. */
  73158. onVRRequestPresentStart: Observable<Engine>;
  73159. /**
  73160. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  73161. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  73162. */
  73163. isInVRExclusivePointerMode: boolean;
  73164. /**
  73165. * Gets a boolean indicating if a webVR device was detected
  73166. * @returns true if a webVR device was detected
  73167. */
  73168. isVRDevicePresent(): boolean;
  73169. /**
  73170. * Gets the current webVR device
  73171. * @returns the current webVR device (or null)
  73172. */
  73173. getVRDevice(): any;
  73174. /**
  73175. * Initializes a webVR display and starts listening to display change events
  73176. * The onVRDisplayChangedObservable will be notified upon these changes
  73177. * @returns A promise containing a VRDisplay and if vr is supported
  73178. */
  73179. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  73180. /** @hidden */
  73181. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  73182. /**
  73183. * Call this function to switch to webVR mode
  73184. * Will do nothing if webVR is not supported or if there is no webVR device
  73185. * @see http://doc.babylonjs.com/how_to/webvr_camera
  73186. */
  73187. enableVR(): void;
  73188. /** @hidden */
  73189. _onVRFullScreenTriggered(): void;
  73190. }
  73191. }
  73192. declare module BABYLON {
  73193. /**
  73194. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  73195. * IMPORTANT!! The data is right-hand data.
  73196. * @export
  73197. * @interface DevicePose
  73198. */
  73199. export interface DevicePose {
  73200. /**
  73201. * The position of the device, values in array are [x,y,z].
  73202. */
  73203. readonly position: Nullable<Float32Array>;
  73204. /**
  73205. * The linearVelocity of the device, values in array are [x,y,z].
  73206. */
  73207. readonly linearVelocity: Nullable<Float32Array>;
  73208. /**
  73209. * The linearAcceleration of the device, values in array are [x,y,z].
  73210. */
  73211. readonly linearAcceleration: Nullable<Float32Array>;
  73212. /**
  73213. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  73214. */
  73215. readonly orientation: Nullable<Float32Array>;
  73216. /**
  73217. * The angularVelocity of the device, values in array are [x,y,z].
  73218. */
  73219. readonly angularVelocity: Nullable<Float32Array>;
  73220. /**
  73221. * The angularAcceleration of the device, values in array are [x,y,z].
  73222. */
  73223. readonly angularAcceleration: Nullable<Float32Array>;
  73224. }
  73225. /**
  73226. * Interface representing a pose controlled object in Babylon.
  73227. * A pose controlled object has both regular pose values as well as pose values
  73228. * from an external device such as a VR head mounted display
  73229. */
  73230. export interface PoseControlled {
  73231. /**
  73232. * The position of the object in babylon space.
  73233. */
  73234. position: Vector3;
  73235. /**
  73236. * The rotation quaternion of the object in babylon space.
  73237. */
  73238. rotationQuaternion: Quaternion;
  73239. /**
  73240. * The position of the device in babylon space.
  73241. */
  73242. devicePosition?: Vector3;
  73243. /**
  73244. * The rotation quaternion of the device in babylon space.
  73245. */
  73246. deviceRotationQuaternion: Quaternion;
  73247. /**
  73248. * The raw pose coming from the device.
  73249. */
  73250. rawPose: Nullable<DevicePose>;
  73251. /**
  73252. * The scale of the device to be used when translating from device space to babylon space.
  73253. */
  73254. deviceScaleFactor: number;
  73255. /**
  73256. * Updates the poseControlled values based on the input device pose.
  73257. * @param poseData the pose data to update the object with
  73258. */
  73259. updateFromDevice(poseData: DevicePose): void;
  73260. }
  73261. /**
  73262. * Set of options to customize the webVRCamera
  73263. */
  73264. export interface WebVROptions {
  73265. /**
  73266. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  73267. */
  73268. trackPosition?: boolean;
  73269. /**
  73270. * Sets the scale of the vrDevice in babylon space. (default: 1)
  73271. */
  73272. positionScale?: number;
  73273. /**
  73274. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  73275. */
  73276. displayName?: string;
  73277. /**
  73278. * Should the native controller meshes be initialized. (default: true)
  73279. */
  73280. controllerMeshes?: boolean;
  73281. /**
  73282. * Creating a default HemiLight only on controllers. (default: true)
  73283. */
  73284. defaultLightingOnControllers?: boolean;
  73285. /**
  73286. * If you don't want to use the default VR button of the helper. (default: false)
  73287. */
  73288. useCustomVRButton?: boolean;
  73289. /**
  73290. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  73291. */
  73292. customVRButton?: HTMLButtonElement;
  73293. /**
  73294. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  73295. */
  73296. rayLength?: number;
  73297. /**
  73298. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  73299. */
  73300. defaultHeight?: number;
  73301. /**
  73302. * If multiview should be used if availible (default: false)
  73303. */
  73304. useMultiview?: boolean;
  73305. }
  73306. /**
  73307. * This represents a WebVR camera.
  73308. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  73309. * @example http://doc.babylonjs.com/how_to/webvr_camera
  73310. */
  73311. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  73312. private webVROptions;
  73313. /**
  73314. * @hidden
  73315. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  73316. */
  73317. _vrDevice: any;
  73318. /**
  73319. * The rawPose of the vrDevice.
  73320. */
  73321. rawPose: Nullable<DevicePose>;
  73322. private _onVREnabled;
  73323. private _specsVersion;
  73324. private _attached;
  73325. private _frameData;
  73326. protected _descendants: Array<Node>;
  73327. private _deviceRoomPosition;
  73328. /** @hidden */
  73329. _deviceRoomRotationQuaternion: Quaternion;
  73330. private _standingMatrix;
  73331. /**
  73332. * Represents device position in babylon space.
  73333. */
  73334. devicePosition: Vector3;
  73335. /**
  73336. * Represents device rotation in babylon space.
  73337. */
  73338. deviceRotationQuaternion: Quaternion;
  73339. /**
  73340. * The scale of the device to be used when translating from device space to babylon space.
  73341. */
  73342. deviceScaleFactor: number;
  73343. private _deviceToWorld;
  73344. private _worldToDevice;
  73345. /**
  73346. * References to the webVR controllers for the vrDevice.
  73347. */
  73348. controllers: Array<WebVRController>;
  73349. /**
  73350. * Emits an event when a controller is attached.
  73351. */
  73352. onControllersAttachedObservable: Observable<WebVRController[]>;
  73353. /**
  73354. * Emits an event when a controller's mesh has been loaded;
  73355. */
  73356. onControllerMeshLoadedObservable: Observable<WebVRController>;
  73357. /**
  73358. * Emits an event when the HMD's pose has been updated.
  73359. */
  73360. onPoseUpdatedFromDeviceObservable: Observable<any>;
  73361. private _poseSet;
  73362. /**
  73363. * If the rig cameras be used as parent instead of this camera.
  73364. */
  73365. rigParenting: boolean;
  73366. private _lightOnControllers;
  73367. private _defaultHeight?;
  73368. /**
  73369. * Instantiates a WebVRFreeCamera.
  73370. * @param name The name of the WebVRFreeCamera
  73371. * @param position The starting anchor position for the camera
  73372. * @param scene The scene the camera belongs to
  73373. * @param webVROptions a set of customizable options for the webVRCamera
  73374. */
  73375. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  73376. /**
  73377. * Gets the device distance from the ground in meters.
  73378. * @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.
  73379. */
  73380. deviceDistanceToRoomGround(): number;
  73381. /**
  73382. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73383. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  73384. */
  73385. useStandingMatrix(callback?: (bool: boolean) => void): void;
  73386. /**
  73387. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  73388. * @returns A promise with a boolean set to if the standing matrix is supported.
  73389. */
  73390. useStandingMatrixAsync(): Promise<boolean>;
  73391. /**
  73392. * Disposes the camera
  73393. */
  73394. dispose(): void;
  73395. /**
  73396. * Gets a vrController by name.
  73397. * @param name The name of the controller to retreive
  73398. * @returns the controller matching the name specified or null if not found
  73399. */
  73400. getControllerByName(name: string): Nullable<WebVRController>;
  73401. private _leftController;
  73402. /**
  73403. * The controller corrisponding to the users left hand.
  73404. */
  73405. readonly leftController: Nullable<WebVRController>;
  73406. private _rightController;
  73407. /**
  73408. * The controller corrisponding to the users right hand.
  73409. */
  73410. readonly rightController: Nullable<WebVRController>;
  73411. /**
  73412. * Casts a ray forward from the vrCamera's gaze.
  73413. * @param length Length of the ray (default: 100)
  73414. * @returns the ray corrisponding to the gaze
  73415. */
  73416. getForwardRay(length?: number): Ray;
  73417. /**
  73418. * @hidden
  73419. * Updates the camera based on device's frame data
  73420. */
  73421. _checkInputs(): void;
  73422. /**
  73423. * Updates the poseControlled values based on the input device pose.
  73424. * @param poseData Pose coming from the device
  73425. */
  73426. updateFromDevice(poseData: DevicePose): void;
  73427. private _htmlElementAttached;
  73428. private _detachIfAttached;
  73429. /**
  73430. * WebVR's attach control will start broadcasting frames to the device.
  73431. * Note that in certain browsers (chrome for example) this function must be called
  73432. * within a user-interaction callback. Example:
  73433. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  73434. *
  73435. * @param element html element to attach the vrDevice to
  73436. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  73437. */
  73438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73439. /**
  73440. * Detaches the camera from the html element and disables VR
  73441. *
  73442. * @param element html element to detach from
  73443. */
  73444. detachControl(element: HTMLElement): void;
  73445. /**
  73446. * @returns the name of this class
  73447. */
  73448. getClassName(): string;
  73449. /**
  73450. * Calls resetPose on the vrDisplay
  73451. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  73452. */
  73453. resetToCurrentRotation(): void;
  73454. /**
  73455. * @hidden
  73456. * Updates the rig cameras (left and right eye)
  73457. */
  73458. _updateRigCameras(): void;
  73459. private _workingVector;
  73460. private _oneVector;
  73461. private _workingMatrix;
  73462. private updateCacheCalled;
  73463. private _correctPositionIfNotTrackPosition;
  73464. /**
  73465. * @hidden
  73466. * Updates the cached values of the camera
  73467. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  73468. */
  73469. _updateCache(ignoreParentClass?: boolean): void;
  73470. /**
  73471. * @hidden
  73472. * Get current device position in babylon world
  73473. */
  73474. _computeDevicePosition(): void;
  73475. /**
  73476. * Updates the current device position and rotation in the babylon world
  73477. */
  73478. update(): void;
  73479. /**
  73480. * @hidden
  73481. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  73482. * @returns an identity matrix
  73483. */
  73484. _getViewMatrix(): Matrix;
  73485. private _tmpMatrix;
  73486. /**
  73487. * This function is called by the two RIG cameras.
  73488. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  73489. * @hidden
  73490. */
  73491. _getWebVRViewMatrix(): Matrix;
  73492. /** @hidden */
  73493. _getWebVRProjectionMatrix(): Matrix;
  73494. private _onGamepadConnectedObserver;
  73495. private _onGamepadDisconnectedObserver;
  73496. private _updateCacheWhenTrackingDisabledObserver;
  73497. /**
  73498. * Initializes the controllers and their meshes
  73499. */
  73500. initControllers(): void;
  73501. }
  73502. }
  73503. declare module BABYLON {
  73504. /**
  73505. * Size options for a post process
  73506. */
  73507. export type PostProcessOptions = {
  73508. width: number;
  73509. height: number;
  73510. };
  73511. /**
  73512. * PostProcess can be used to apply a shader to a texture after it has been rendered
  73513. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73514. */
  73515. export class PostProcess {
  73516. /** Name of the PostProcess. */
  73517. name: string;
  73518. /**
  73519. * Gets or sets the unique id of the post process
  73520. */
  73521. uniqueId: number;
  73522. /**
  73523. * Width of the texture to apply the post process on
  73524. */
  73525. width: number;
  73526. /**
  73527. * Height of the texture to apply the post process on
  73528. */
  73529. height: number;
  73530. /**
  73531. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  73532. * @hidden
  73533. */
  73534. _outputTexture: Nullable<InternalTexture>;
  73535. /**
  73536. * Sampling mode used by the shader
  73537. * See https://doc.babylonjs.com/classes/3.1/texture
  73538. */
  73539. renderTargetSamplingMode: number;
  73540. /**
  73541. * Clear color to use when screen clearing
  73542. */
  73543. clearColor: Color4;
  73544. /**
  73545. * If the buffer needs to be cleared before applying the post process. (default: true)
  73546. * Should be set to false if shader will overwrite all previous pixels.
  73547. */
  73548. autoClear: boolean;
  73549. /**
  73550. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  73551. */
  73552. alphaMode: number;
  73553. /**
  73554. * Sets the setAlphaBlendConstants of the babylon engine
  73555. */
  73556. alphaConstants: Color4;
  73557. /**
  73558. * Animations to be used for the post processing
  73559. */
  73560. animations: Animation[];
  73561. /**
  73562. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  73563. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  73564. */
  73565. enablePixelPerfectMode: boolean;
  73566. /**
  73567. * Force the postprocess to be applied without taking in account viewport
  73568. */
  73569. forceFullscreenViewport: boolean;
  73570. /**
  73571. * List of inspectable custom properties (used by the Inspector)
  73572. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73573. */
  73574. inspectableCustomProperties: IInspectable[];
  73575. /**
  73576. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  73577. *
  73578. * | Value | Type | Description |
  73579. * | ----- | ----------------------------------- | ----------- |
  73580. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  73581. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  73582. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  73583. *
  73584. */
  73585. scaleMode: number;
  73586. /**
  73587. * Force textures to be a power of two (default: false)
  73588. */
  73589. alwaysForcePOT: boolean;
  73590. private _samples;
  73591. /**
  73592. * Number of sample textures (default: 1)
  73593. */
  73594. samples: number;
  73595. /**
  73596. * Modify the scale of the post process to be the same as the viewport (default: false)
  73597. */
  73598. adaptScaleToCurrentViewport: boolean;
  73599. private _camera;
  73600. private _scene;
  73601. private _engine;
  73602. private _options;
  73603. private _reusable;
  73604. private _textureType;
  73605. /**
  73606. * Smart array of input and output textures for the post process.
  73607. * @hidden
  73608. */
  73609. _textures: SmartArray<InternalTexture>;
  73610. /**
  73611. * The index in _textures that corresponds to the output texture.
  73612. * @hidden
  73613. */
  73614. _currentRenderTextureInd: number;
  73615. private _effect;
  73616. private _samplers;
  73617. private _fragmentUrl;
  73618. private _vertexUrl;
  73619. private _parameters;
  73620. private _scaleRatio;
  73621. protected _indexParameters: any;
  73622. private _shareOutputWithPostProcess;
  73623. private _texelSize;
  73624. private _forcedOutputTexture;
  73625. /**
  73626. * Returns the fragment url or shader name used in the post process.
  73627. * @returns the fragment url or name in the shader store.
  73628. */
  73629. getEffectName(): string;
  73630. /**
  73631. * An event triggered when the postprocess is activated.
  73632. */
  73633. onActivateObservable: Observable<Camera>;
  73634. private _onActivateObserver;
  73635. /**
  73636. * A function that is added to the onActivateObservable
  73637. */
  73638. onActivate: Nullable<(camera: Camera) => void>;
  73639. /**
  73640. * An event triggered when the postprocess changes its size.
  73641. */
  73642. onSizeChangedObservable: Observable<PostProcess>;
  73643. private _onSizeChangedObserver;
  73644. /**
  73645. * A function that is added to the onSizeChangedObservable
  73646. */
  73647. onSizeChanged: (postProcess: PostProcess) => void;
  73648. /**
  73649. * An event triggered when the postprocess applies its effect.
  73650. */
  73651. onApplyObservable: Observable<Effect>;
  73652. private _onApplyObserver;
  73653. /**
  73654. * A function that is added to the onApplyObservable
  73655. */
  73656. onApply: (effect: Effect) => void;
  73657. /**
  73658. * An event triggered before rendering the postprocess
  73659. */
  73660. onBeforeRenderObservable: Observable<Effect>;
  73661. private _onBeforeRenderObserver;
  73662. /**
  73663. * A function that is added to the onBeforeRenderObservable
  73664. */
  73665. onBeforeRender: (effect: Effect) => void;
  73666. /**
  73667. * An event triggered after rendering the postprocess
  73668. */
  73669. onAfterRenderObservable: Observable<Effect>;
  73670. private _onAfterRenderObserver;
  73671. /**
  73672. * A function that is added to the onAfterRenderObservable
  73673. */
  73674. onAfterRender: (efect: Effect) => void;
  73675. /**
  73676. * 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
  73677. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73678. */
  73679. inputTexture: InternalTexture;
  73680. /**
  73681. * Gets the camera which post process is applied to.
  73682. * @returns The camera the post process is applied to.
  73683. */
  73684. getCamera(): Camera;
  73685. /**
  73686. * Gets the texel size of the postprocess.
  73687. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73688. */
  73689. readonly texelSize: Vector2;
  73690. /**
  73691. * Creates a new instance PostProcess
  73692. * @param name The name of the PostProcess.
  73693. * @param fragmentUrl The url of the fragment shader to be used.
  73694. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73695. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73697. * @param camera The camera to apply the render pass to.
  73698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73699. * @param engine The engine which the post process will be applied. (default: current engine)
  73700. * @param reusable If the post process can be reused on the same frame. (default: false)
  73701. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73702. * @param textureType Type of textures used when performing the post process. (default: 0)
  73703. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73704. * @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
  73705. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73706. */
  73707. constructor(
  73708. /** Name of the PostProcess. */
  73709. 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);
  73710. /**
  73711. * Gets a string idenfifying the name of the class
  73712. * @returns "PostProcess" string
  73713. */
  73714. getClassName(): string;
  73715. /**
  73716. * Gets the engine which this post process belongs to.
  73717. * @returns The engine the post process was enabled with.
  73718. */
  73719. getEngine(): Engine;
  73720. /**
  73721. * The effect that is created when initializing the post process.
  73722. * @returns The created effect corrisponding the the postprocess.
  73723. */
  73724. getEffect(): Effect;
  73725. /**
  73726. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73727. * @param postProcess The post process to share the output with.
  73728. * @returns This post process.
  73729. */
  73730. shareOutputWith(postProcess: PostProcess): PostProcess;
  73731. /**
  73732. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73733. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73734. */
  73735. useOwnOutput(): void;
  73736. /**
  73737. * Updates the effect with the current post process compile time values and recompiles the shader.
  73738. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73739. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73740. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73741. * @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
  73742. * @param onCompiled Called when the shader has been compiled.
  73743. * @param onError Called if there is an error when compiling a shader.
  73744. */
  73745. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73746. /**
  73747. * The post process is reusable if it can be used multiple times within one frame.
  73748. * @returns If the post process is reusable
  73749. */
  73750. isReusable(): boolean;
  73751. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73752. markTextureDirty(): void;
  73753. /**
  73754. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73755. * 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.
  73756. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73757. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73758. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73759. * @returns The target texture that was bound to be written to.
  73760. */
  73761. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73762. /**
  73763. * If the post process is supported.
  73764. */
  73765. readonly isSupported: boolean;
  73766. /**
  73767. * The aspect ratio of the output texture.
  73768. */
  73769. readonly aspectRatio: number;
  73770. /**
  73771. * Get a value indicating if the post-process is ready to be used
  73772. * @returns true if the post-process is ready (shader is compiled)
  73773. */
  73774. isReady(): boolean;
  73775. /**
  73776. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73777. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73778. */
  73779. apply(): Nullable<Effect>;
  73780. private _disposeTextures;
  73781. /**
  73782. * Disposes the post process.
  73783. * @param camera The camera to dispose the post process on.
  73784. */
  73785. dispose(camera?: Camera): void;
  73786. }
  73787. }
  73788. declare module BABYLON {
  73789. /**
  73790. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73791. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73792. */
  73793. export class PostProcessManager {
  73794. private _scene;
  73795. private _indexBuffer;
  73796. private _vertexBuffers;
  73797. /**
  73798. * Creates a new instance PostProcess
  73799. * @param scene The scene that the post process is associated with.
  73800. */
  73801. constructor(scene: Scene);
  73802. private _prepareBuffers;
  73803. private _buildIndexBuffer;
  73804. /**
  73805. * Rebuilds the vertex buffers of the manager.
  73806. * @hidden
  73807. */
  73808. _rebuild(): void;
  73809. /**
  73810. * Prepares a frame to be run through a post process.
  73811. * @param sourceTexture The input texture to the post procesess. (default: null)
  73812. * @param postProcesses An array of post processes to be run. (default: null)
  73813. * @returns True if the post processes were able to be run.
  73814. * @hidden
  73815. */
  73816. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73817. /**
  73818. * Manually render a set of post processes to a texture.
  73819. * @param postProcesses An array of post processes to be run.
  73820. * @param targetTexture The target texture to render to.
  73821. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73822. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73823. * @param lodLevel defines which lod of the texture to render to
  73824. */
  73825. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73826. /**
  73827. * Finalize the result of the output of the postprocesses.
  73828. * @param doNotPresent If true the result will not be displayed to the screen.
  73829. * @param targetTexture The target texture to render to.
  73830. * @param faceIndex The index of the face to bind the target texture to.
  73831. * @param postProcesses The array of post processes to render.
  73832. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73833. * @hidden
  73834. */
  73835. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73836. /**
  73837. * Disposes of the post process manager.
  73838. */
  73839. dispose(): void;
  73840. }
  73841. }
  73842. declare module BABYLON {
  73843. interface AbstractScene {
  73844. /**
  73845. * The list of layers (background and foreground) of the scene
  73846. */
  73847. layers: Array<Layer>;
  73848. }
  73849. /**
  73850. * Defines the layer scene component responsible to manage any layers
  73851. * in a given scene.
  73852. */
  73853. export class LayerSceneComponent implements ISceneComponent {
  73854. /**
  73855. * The component name helpfull to identify the component in the list of scene components.
  73856. */
  73857. readonly name: string;
  73858. /**
  73859. * The scene the component belongs to.
  73860. */
  73861. scene: Scene;
  73862. private _engine;
  73863. /**
  73864. * Creates a new instance of the component for the given scene
  73865. * @param scene Defines the scene to register the component in
  73866. */
  73867. constructor(scene: Scene);
  73868. /**
  73869. * Registers the component in a given scene
  73870. */
  73871. register(): void;
  73872. /**
  73873. * Rebuilds the elements related to this component in case of
  73874. * context lost for instance.
  73875. */
  73876. rebuild(): void;
  73877. /**
  73878. * Disposes the component and the associated ressources.
  73879. */
  73880. dispose(): void;
  73881. private _draw;
  73882. private _drawCameraPredicate;
  73883. private _drawCameraBackground;
  73884. private _drawCameraForeground;
  73885. private _drawRenderTargetPredicate;
  73886. private _drawRenderTargetBackground;
  73887. private _drawRenderTargetForeground;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /** @hidden */
  73892. export var layerPixelShader: {
  73893. name: string;
  73894. shader: string;
  73895. };
  73896. }
  73897. declare module BABYLON {
  73898. /** @hidden */
  73899. export var layerVertexShader: {
  73900. name: string;
  73901. shader: string;
  73902. };
  73903. }
  73904. declare module BABYLON {
  73905. /**
  73906. * This represents a full screen 2d layer.
  73907. * This can be useful to display a picture in the background of your scene for instance.
  73908. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73909. */
  73910. export class Layer {
  73911. /**
  73912. * Define the name of the layer.
  73913. */
  73914. name: string;
  73915. /**
  73916. * Define the texture the layer should display.
  73917. */
  73918. texture: Nullable<Texture>;
  73919. /**
  73920. * Is the layer in background or foreground.
  73921. */
  73922. isBackground: boolean;
  73923. /**
  73924. * Define the color of the layer (instead of texture).
  73925. */
  73926. color: Color4;
  73927. /**
  73928. * Define the scale of the layer in order to zoom in out of the texture.
  73929. */
  73930. scale: Vector2;
  73931. /**
  73932. * Define an offset for the layer in order to shift the texture.
  73933. */
  73934. offset: Vector2;
  73935. /**
  73936. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73937. */
  73938. alphaBlendingMode: number;
  73939. /**
  73940. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73941. * Alpha test will not mix with the background color in case of transparency.
  73942. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73943. */
  73944. alphaTest: boolean;
  73945. /**
  73946. * Define a mask to restrict the layer to only some of the scene cameras.
  73947. */
  73948. layerMask: number;
  73949. /**
  73950. * Define the list of render target the layer is visible into.
  73951. */
  73952. renderTargetTextures: RenderTargetTexture[];
  73953. /**
  73954. * Define if the layer is only used in renderTarget or if it also
  73955. * renders in the main frame buffer of the canvas.
  73956. */
  73957. renderOnlyInRenderTargetTextures: boolean;
  73958. private _scene;
  73959. private _vertexBuffers;
  73960. private _indexBuffer;
  73961. private _effect;
  73962. private _alphaTestEffect;
  73963. /**
  73964. * An event triggered when the layer is disposed.
  73965. */
  73966. onDisposeObservable: Observable<Layer>;
  73967. private _onDisposeObserver;
  73968. /**
  73969. * Back compatibility with callback before the onDisposeObservable existed.
  73970. * The set callback will be triggered when the layer has been disposed.
  73971. */
  73972. onDispose: () => void;
  73973. /**
  73974. * An event triggered before rendering the scene
  73975. */
  73976. onBeforeRenderObservable: Observable<Layer>;
  73977. private _onBeforeRenderObserver;
  73978. /**
  73979. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73980. * The set callback will be triggered just before rendering the layer.
  73981. */
  73982. onBeforeRender: () => void;
  73983. /**
  73984. * An event triggered after rendering the scene
  73985. */
  73986. onAfterRenderObservable: Observable<Layer>;
  73987. private _onAfterRenderObserver;
  73988. /**
  73989. * Back compatibility with callback before the onAfterRenderObservable existed.
  73990. * The set callback will be triggered just after rendering the layer.
  73991. */
  73992. onAfterRender: () => void;
  73993. /**
  73994. * Instantiates a new layer.
  73995. * This represents a full screen 2d layer.
  73996. * This can be useful to display a picture in the background of your scene for instance.
  73997. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73998. * @param name Define the name of the layer in the scene
  73999. * @param imgUrl Define the url of the texture to display in the layer
  74000. * @param scene Define the scene the layer belongs to
  74001. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  74002. * @param color Defines a color for the layer
  74003. */
  74004. constructor(
  74005. /**
  74006. * Define the name of the layer.
  74007. */
  74008. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  74009. private _createIndexBuffer;
  74010. /** @hidden */
  74011. _rebuild(): void;
  74012. /**
  74013. * Renders the layer in the scene.
  74014. */
  74015. render(): void;
  74016. /**
  74017. * Disposes and releases the associated ressources.
  74018. */
  74019. dispose(): void;
  74020. }
  74021. }
  74022. declare module BABYLON {
  74023. interface AbstractScene {
  74024. /**
  74025. * The list of procedural textures added to the scene
  74026. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74027. */
  74028. proceduralTextures: Array<ProceduralTexture>;
  74029. }
  74030. /**
  74031. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  74032. * in a given scene.
  74033. */
  74034. export class ProceduralTextureSceneComponent implements ISceneComponent {
  74035. /**
  74036. * The component name helpfull to identify the component in the list of scene components.
  74037. */
  74038. readonly name: string;
  74039. /**
  74040. * The scene the component belongs to.
  74041. */
  74042. scene: Scene;
  74043. /**
  74044. * Creates a new instance of the component for the given scene
  74045. * @param scene Defines the scene to register the component in
  74046. */
  74047. constructor(scene: Scene);
  74048. /**
  74049. * Registers the component in a given scene
  74050. */
  74051. register(): void;
  74052. /**
  74053. * Rebuilds the elements related to this component in case of
  74054. * context lost for instance.
  74055. */
  74056. rebuild(): void;
  74057. /**
  74058. * Disposes the component and the associated ressources.
  74059. */
  74060. dispose(): void;
  74061. private _beforeClear;
  74062. }
  74063. }
  74064. declare module BABYLON {
  74065. interface Engine {
  74066. /**
  74067. * Creates a new render target cube texture
  74068. * @param size defines the size of the texture
  74069. * @param options defines the options used to create the texture
  74070. * @returns a new render target cube texture stored in an InternalTexture
  74071. */
  74072. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /** @hidden */
  74077. export var proceduralVertexShader: {
  74078. name: string;
  74079. shader: string;
  74080. };
  74081. }
  74082. declare module BABYLON {
  74083. /**
  74084. * 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.
  74085. * This is the base class of any Procedural texture and contains most of the shareable code.
  74086. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74087. */
  74088. export class ProceduralTexture extends Texture {
  74089. isCube: boolean;
  74090. /**
  74091. * Define if the texture is enabled or not (disabled texture will not render)
  74092. */
  74093. isEnabled: boolean;
  74094. /**
  74095. * Define if the texture must be cleared before rendering (default is true)
  74096. */
  74097. autoClear: boolean;
  74098. /**
  74099. * Callback called when the texture is generated
  74100. */
  74101. onGenerated: () => void;
  74102. /**
  74103. * Event raised when the texture is generated
  74104. */
  74105. onGeneratedObservable: Observable<ProceduralTexture>;
  74106. /** @hidden */
  74107. _generateMipMaps: boolean;
  74108. /** @hidden **/
  74109. _effect: Effect;
  74110. /** @hidden */
  74111. _textures: {
  74112. [key: string]: Texture;
  74113. };
  74114. private _size;
  74115. private _currentRefreshId;
  74116. private _refreshRate;
  74117. private _vertexBuffers;
  74118. private _indexBuffer;
  74119. private _uniforms;
  74120. private _samplers;
  74121. private _fragment;
  74122. private _floats;
  74123. private _ints;
  74124. private _floatsArrays;
  74125. private _colors3;
  74126. private _colors4;
  74127. private _vectors2;
  74128. private _vectors3;
  74129. private _matrices;
  74130. private _fallbackTexture;
  74131. private _fallbackTextureUsed;
  74132. private _engine;
  74133. private _cachedDefines;
  74134. private _contentUpdateId;
  74135. private _contentData;
  74136. /**
  74137. * Instantiates a new procedural texture.
  74138. * 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.
  74139. * This is the base class of any Procedural texture and contains most of the shareable code.
  74140. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  74141. * @param name Define the name of the texture
  74142. * @param size Define the size of the texture to create
  74143. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  74144. * @param scene Define the scene the texture belongs to
  74145. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  74146. * @param generateMipMaps Define if the texture should creates mip maps or not
  74147. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  74148. */
  74149. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  74150. /**
  74151. * The effect that is created when initializing the post process.
  74152. * @returns The created effect corrisponding the the postprocess.
  74153. */
  74154. getEffect(): Effect;
  74155. /**
  74156. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  74157. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  74158. */
  74159. getContent(): Nullable<ArrayBufferView>;
  74160. private _createIndexBuffer;
  74161. /** @hidden */
  74162. _rebuild(): void;
  74163. /**
  74164. * Resets the texture in order to recreate its associated resources.
  74165. * This can be called in case of context loss
  74166. */
  74167. reset(): void;
  74168. protected _getDefines(): string;
  74169. /**
  74170. * Is the texture ready to be used ? (rendered at least once)
  74171. * @returns true if ready, otherwise, false.
  74172. */
  74173. isReady(): boolean;
  74174. /**
  74175. * Resets the refresh counter of the texture and start bak from scratch.
  74176. * Could be useful to regenerate the texture if it is setup to render only once.
  74177. */
  74178. resetRefreshCounter(): void;
  74179. /**
  74180. * Set the fragment shader to use in order to render the texture.
  74181. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  74182. */
  74183. setFragment(fragment: any): void;
  74184. /**
  74185. * Define the refresh rate of the texture or the rendering frequency.
  74186. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74187. */
  74188. refreshRate: number;
  74189. /** @hidden */
  74190. _shouldRender(): boolean;
  74191. /**
  74192. * Get the size the texture is rendering at.
  74193. * @returns the size (texture is always squared)
  74194. */
  74195. getRenderSize(): number;
  74196. /**
  74197. * Resize the texture to new value.
  74198. * @param size Define the new size the texture should have
  74199. * @param generateMipMaps Define whether the new texture should create mip maps
  74200. */
  74201. resize(size: number, generateMipMaps: boolean): void;
  74202. private _checkUniform;
  74203. /**
  74204. * Set a texture in the shader program used to render.
  74205. * @param name Define the name of the uniform samplers as defined in the shader
  74206. * @param texture Define the texture to bind to this sampler
  74207. * @return the texture itself allowing "fluent" like uniform updates
  74208. */
  74209. setTexture(name: string, texture: Texture): ProceduralTexture;
  74210. /**
  74211. * Set a float in the shader.
  74212. * @param name Define the name of the uniform as defined in the shader
  74213. * @param value Define the value to give to the uniform
  74214. * @return the texture itself allowing "fluent" like uniform updates
  74215. */
  74216. setFloat(name: string, value: number): ProceduralTexture;
  74217. /**
  74218. * Set a int in the shader.
  74219. * @param name Define the name of the uniform as defined in the shader
  74220. * @param value Define the value to give to the uniform
  74221. * @return the texture itself allowing "fluent" like uniform updates
  74222. */
  74223. setInt(name: string, value: number): ProceduralTexture;
  74224. /**
  74225. * Set an array of floats in the shader.
  74226. * @param name Define the name of the uniform as defined in the shader
  74227. * @param value Define the value to give to the uniform
  74228. * @return the texture itself allowing "fluent" like uniform updates
  74229. */
  74230. setFloats(name: string, value: number[]): ProceduralTexture;
  74231. /**
  74232. * Set a vec3 in the shader from a Color3.
  74233. * @param name Define the name of the uniform as defined in the shader
  74234. * @param value Define the value to give to the uniform
  74235. * @return the texture itself allowing "fluent" like uniform updates
  74236. */
  74237. setColor3(name: string, value: Color3): ProceduralTexture;
  74238. /**
  74239. * Set a vec4 in the shader from a Color4.
  74240. * @param name Define the name of the uniform as defined in the shader
  74241. * @param value Define the value to give to the uniform
  74242. * @return the texture itself allowing "fluent" like uniform updates
  74243. */
  74244. setColor4(name: string, value: Color4): ProceduralTexture;
  74245. /**
  74246. * Set a vec2 in the shader from a Vector2.
  74247. * @param name Define the name of the uniform as defined in the shader
  74248. * @param value Define the value to give to the uniform
  74249. * @return the texture itself allowing "fluent" like uniform updates
  74250. */
  74251. setVector2(name: string, value: Vector2): ProceduralTexture;
  74252. /**
  74253. * Set a vec3 in the shader from a Vector3.
  74254. * @param name Define the name of the uniform as defined in the shader
  74255. * @param value Define the value to give to the uniform
  74256. * @return the texture itself allowing "fluent" like uniform updates
  74257. */
  74258. setVector3(name: string, value: Vector3): ProceduralTexture;
  74259. /**
  74260. * Set a mat4 in the shader from a MAtrix.
  74261. * @param name Define the name of the uniform as defined in the shader
  74262. * @param value Define the value to give to the uniform
  74263. * @return the texture itself allowing "fluent" like uniform updates
  74264. */
  74265. setMatrix(name: string, value: Matrix): ProceduralTexture;
  74266. /**
  74267. * Render the texture to its associated render target.
  74268. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  74269. */
  74270. render(useCameraPostProcess?: boolean): void;
  74271. /**
  74272. * Clone the texture.
  74273. * @returns the cloned texture
  74274. */
  74275. clone(): ProceduralTexture;
  74276. /**
  74277. * Dispose the texture and release its asoociated resources.
  74278. */
  74279. dispose(): void;
  74280. }
  74281. }
  74282. declare module BABYLON {
  74283. /**
  74284. * This represents the base class for particle system in Babylon.
  74285. * 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.
  74286. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74287. * @example https://doc.babylonjs.com/babylon101/particles
  74288. */
  74289. export class BaseParticleSystem {
  74290. /**
  74291. * Source color is added to the destination color without alpha affecting the result
  74292. */
  74293. static BLENDMODE_ONEONE: number;
  74294. /**
  74295. * Blend current color and particle color using particle’s alpha
  74296. */
  74297. static BLENDMODE_STANDARD: number;
  74298. /**
  74299. * Add current color and particle color multiplied by particle’s alpha
  74300. */
  74301. static BLENDMODE_ADD: number;
  74302. /**
  74303. * Multiply current color with particle color
  74304. */
  74305. static BLENDMODE_MULTIPLY: number;
  74306. /**
  74307. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  74308. */
  74309. static BLENDMODE_MULTIPLYADD: number;
  74310. /**
  74311. * List of animations used by the particle system.
  74312. */
  74313. animations: Animation[];
  74314. /**
  74315. * The id of the Particle system.
  74316. */
  74317. id: string;
  74318. /**
  74319. * The friendly name of the Particle system.
  74320. */
  74321. name: string;
  74322. /**
  74323. * The rendering group used by the Particle system to chose when to render.
  74324. */
  74325. renderingGroupId: number;
  74326. /**
  74327. * The emitter represents the Mesh or position we are attaching the particle system to.
  74328. */
  74329. emitter: Nullable<AbstractMesh | Vector3>;
  74330. /**
  74331. * The maximum number of particles to emit per frame
  74332. */
  74333. emitRate: number;
  74334. /**
  74335. * If you want to launch only a few particles at once, that can be done, as well.
  74336. */
  74337. manualEmitCount: number;
  74338. /**
  74339. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74340. */
  74341. updateSpeed: number;
  74342. /**
  74343. * The amount of time the particle system is running (depends of the overall update speed).
  74344. */
  74345. targetStopDuration: number;
  74346. /**
  74347. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74348. */
  74349. disposeOnStop: boolean;
  74350. /**
  74351. * Minimum power of emitting particles.
  74352. */
  74353. minEmitPower: number;
  74354. /**
  74355. * Maximum power of emitting particles.
  74356. */
  74357. maxEmitPower: number;
  74358. /**
  74359. * Minimum life time of emitting particles.
  74360. */
  74361. minLifeTime: number;
  74362. /**
  74363. * Maximum life time of emitting particles.
  74364. */
  74365. maxLifeTime: number;
  74366. /**
  74367. * Minimum Size of emitting particles.
  74368. */
  74369. minSize: number;
  74370. /**
  74371. * Maximum Size of emitting particles.
  74372. */
  74373. maxSize: number;
  74374. /**
  74375. * Minimum scale of emitting particles on X axis.
  74376. */
  74377. minScaleX: number;
  74378. /**
  74379. * Maximum scale of emitting particles on X axis.
  74380. */
  74381. maxScaleX: number;
  74382. /**
  74383. * Minimum scale of emitting particles on Y axis.
  74384. */
  74385. minScaleY: number;
  74386. /**
  74387. * Maximum scale of emitting particles on Y axis.
  74388. */
  74389. maxScaleY: number;
  74390. /**
  74391. * Gets or sets the minimal initial rotation in radians.
  74392. */
  74393. minInitialRotation: number;
  74394. /**
  74395. * Gets or sets the maximal initial rotation in radians.
  74396. */
  74397. maxInitialRotation: number;
  74398. /**
  74399. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74400. */
  74401. minAngularSpeed: number;
  74402. /**
  74403. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74404. */
  74405. maxAngularSpeed: number;
  74406. /**
  74407. * The texture used to render each particle. (this can be a spritesheet)
  74408. */
  74409. particleTexture: Nullable<Texture>;
  74410. /**
  74411. * The layer mask we are rendering the particles through.
  74412. */
  74413. layerMask: number;
  74414. /**
  74415. * This can help using your own shader to render the particle system.
  74416. * The according effect will be created
  74417. */
  74418. customShader: any;
  74419. /**
  74420. * By default particle system starts as soon as they are created. This prevents the
  74421. * automatic start to happen and let you decide when to start emitting particles.
  74422. */
  74423. preventAutoStart: boolean;
  74424. private _noiseTexture;
  74425. /**
  74426. * Gets or sets a texture used to add random noise to particle positions
  74427. */
  74428. noiseTexture: Nullable<ProceduralTexture>;
  74429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74430. noiseStrength: Vector3;
  74431. /**
  74432. * Callback triggered when the particle animation is ending.
  74433. */
  74434. onAnimationEnd: Nullable<() => void>;
  74435. /**
  74436. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  74437. */
  74438. blendMode: number;
  74439. /**
  74440. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  74441. * to override the particles.
  74442. */
  74443. forceDepthWrite: boolean;
  74444. /** 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 */
  74445. preWarmCycles: number;
  74446. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  74447. preWarmStepOffset: number;
  74448. /**
  74449. * 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)
  74450. */
  74451. spriteCellChangeSpeed: number;
  74452. /**
  74453. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74454. */
  74455. startSpriteCellID: number;
  74456. /**
  74457. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74458. */
  74459. endSpriteCellID: number;
  74460. /**
  74461. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74462. */
  74463. spriteCellWidth: number;
  74464. /**
  74465. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74466. */
  74467. spriteCellHeight: number;
  74468. /**
  74469. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74470. */
  74471. spriteRandomStartCell: boolean;
  74472. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74473. translationPivot: Vector2;
  74474. /** @hidden */
  74475. protected _isAnimationSheetEnabled: boolean;
  74476. /**
  74477. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74478. */
  74479. beginAnimationOnStart: boolean;
  74480. /**
  74481. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74482. */
  74483. beginAnimationFrom: number;
  74484. /**
  74485. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74486. */
  74487. beginAnimationTo: number;
  74488. /**
  74489. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74490. */
  74491. beginAnimationLoop: boolean;
  74492. /**
  74493. * Gets or sets a world offset applied to all particles
  74494. */
  74495. worldOffset: Vector3;
  74496. /**
  74497. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  74498. */
  74499. isAnimationSheetEnabled: boolean;
  74500. /**
  74501. * Get hosting scene
  74502. * @returns the scene
  74503. */
  74504. getScene(): Scene;
  74505. /**
  74506. * You can use gravity if you want to give an orientation to your particles.
  74507. */
  74508. gravity: Vector3;
  74509. protected _colorGradients: Nullable<Array<ColorGradient>>;
  74510. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  74511. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  74512. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  74513. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  74514. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  74515. protected _dragGradients: Nullable<Array<FactorGradient>>;
  74516. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  74517. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  74518. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  74519. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  74520. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  74521. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  74522. /**
  74523. * Defines the delay in milliseconds before starting the system (0 by default)
  74524. */
  74525. startDelay: number;
  74526. /**
  74527. * Gets the current list of drag gradients.
  74528. * You must use addDragGradient and removeDragGradient to udpate this list
  74529. * @returns the list of drag gradients
  74530. */
  74531. getDragGradients(): Nullable<Array<FactorGradient>>;
  74532. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74533. limitVelocityDamping: number;
  74534. /**
  74535. * Gets the current list of limit velocity gradients.
  74536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74537. * @returns the list of limit velocity gradients
  74538. */
  74539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74540. /**
  74541. * Gets the current list of color gradients.
  74542. * You must use addColorGradient and removeColorGradient to udpate this list
  74543. * @returns the list of color gradients
  74544. */
  74545. getColorGradients(): Nullable<Array<ColorGradient>>;
  74546. /**
  74547. * Gets the current list of size gradients.
  74548. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74549. * @returns the list of size gradients
  74550. */
  74551. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74552. /**
  74553. * Gets the current list of color remap gradients.
  74554. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74555. * @returns the list of color remap gradients
  74556. */
  74557. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74558. /**
  74559. * Gets the current list of alpha remap gradients.
  74560. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74561. * @returns the list of alpha remap gradients
  74562. */
  74563. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74564. /**
  74565. * Gets the current list of life time gradients.
  74566. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74567. * @returns the list of life time gradients
  74568. */
  74569. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74570. /**
  74571. * Gets the current list of angular speed gradients.
  74572. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74573. * @returns the list of angular speed gradients
  74574. */
  74575. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74576. /**
  74577. * Gets the current list of velocity gradients.
  74578. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74579. * @returns the list of velocity gradients
  74580. */
  74581. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74582. /**
  74583. * Gets the current list of start size gradients.
  74584. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74585. * @returns the list of start size gradients
  74586. */
  74587. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74588. /**
  74589. * Gets the current list of emit rate gradients.
  74590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74591. * @returns the list of emit rate gradients
  74592. */
  74593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74594. /**
  74595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74597. */
  74598. direction1: Vector3;
  74599. /**
  74600. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74601. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74602. */
  74603. direction2: Vector3;
  74604. /**
  74605. * 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.
  74606. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74607. */
  74608. minEmitBox: Vector3;
  74609. /**
  74610. * 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.
  74611. * This only works when particleEmitterTyps is a BoxParticleEmitter
  74612. */
  74613. maxEmitBox: Vector3;
  74614. /**
  74615. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74616. */
  74617. color1: Color4;
  74618. /**
  74619. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  74620. */
  74621. color2: Color4;
  74622. /**
  74623. * Color the particle will have at the end of its lifetime
  74624. */
  74625. colorDead: Color4;
  74626. /**
  74627. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  74628. */
  74629. textureMask: Color4;
  74630. /**
  74631. * The particle emitter type defines the emitter used by the particle system.
  74632. * It can be for example box, sphere, or cone...
  74633. */
  74634. particleEmitterType: IParticleEmitterType;
  74635. /** @hidden */
  74636. _isSubEmitter: boolean;
  74637. /**
  74638. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74639. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74640. */
  74641. billboardMode: number;
  74642. protected _isBillboardBased: boolean;
  74643. /**
  74644. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74645. */
  74646. isBillboardBased: boolean;
  74647. /**
  74648. * The scene the particle system belongs to.
  74649. */
  74650. protected _scene: Scene;
  74651. /**
  74652. * Local cache of defines for image processing.
  74653. */
  74654. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74655. /**
  74656. * Default configuration related to image processing available in the standard Material.
  74657. */
  74658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74659. /**
  74660. * Gets the image processing configuration used either in this material.
  74661. */
  74662. /**
  74663. * Sets the Default image processing configuration used either in the this material.
  74664. *
  74665. * If sets to null, the scene one is in use.
  74666. */
  74667. imageProcessingConfiguration: ImageProcessingConfiguration;
  74668. /**
  74669. * Attaches a new image processing configuration to the Standard Material.
  74670. * @param configuration
  74671. */
  74672. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74673. /** @hidden */
  74674. protected _reset(): void;
  74675. /** @hidden */
  74676. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74677. /**
  74678. * Instantiates a particle system.
  74679. * 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.
  74680. * @param name The name of the particle system
  74681. */
  74682. constructor(name: string);
  74683. /**
  74684. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74687. * @returns the emitter
  74688. */
  74689. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74690. /**
  74691. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74692. * @param radius The radius of the hemisphere to emit from
  74693. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74694. * @returns the emitter
  74695. */
  74696. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74697. /**
  74698. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74699. * @param radius The radius of the sphere to emit from
  74700. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74701. * @returns the emitter
  74702. */
  74703. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74704. /**
  74705. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74706. * @param radius The radius of the sphere to emit from
  74707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74709. * @returns the emitter
  74710. */
  74711. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74712. /**
  74713. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74714. * @param radius The radius of the emission cylinder
  74715. * @param height The height of the emission cylinder
  74716. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74717. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74718. * @returns the emitter
  74719. */
  74720. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74721. /**
  74722. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74723. * @param radius The radius of the cylinder to emit from
  74724. * @param height The height of the emission cylinder
  74725. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74728. * @returns the emitter
  74729. */
  74730. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74731. /**
  74732. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74733. * @param radius The radius of the cone to emit from
  74734. * @param angle The base angle of the cone
  74735. * @returns the emitter
  74736. */
  74737. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74738. /**
  74739. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74740. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74741. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74742. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74743. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74744. * @returns the emitter
  74745. */
  74746. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /**
  74751. * Type of sub emitter
  74752. */
  74753. export enum SubEmitterType {
  74754. /**
  74755. * Attached to the particle over it's lifetime
  74756. */
  74757. ATTACHED = 0,
  74758. /**
  74759. * Created when the particle dies
  74760. */
  74761. END = 1
  74762. }
  74763. /**
  74764. * Sub emitter class used to emit particles from an existing particle
  74765. */
  74766. export class SubEmitter {
  74767. /**
  74768. * the particle system to be used by the sub emitter
  74769. */
  74770. particleSystem: ParticleSystem;
  74771. /**
  74772. * Type of the submitter (Default: END)
  74773. */
  74774. type: SubEmitterType;
  74775. /**
  74776. * 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)
  74777. * Note: This only is supported when using an emitter of type Mesh
  74778. */
  74779. inheritDirection: boolean;
  74780. /**
  74781. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74782. */
  74783. inheritedVelocityAmount: number;
  74784. /**
  74785. * Creates a sub emitter
  74786. * @param particleSystem the particle system to be used by the sub emitter
  74787. */
  74788. constructor(
  74789. /**
  74790. * the particle system to be used by the sub emitter
  74791. */
  74792. particleSystem: ParticleSystem);
  74793. /**
  74794. * Clones the sub emitter
  74795. * @returns the cloned sub emitter
  74796. */
  74797. clone(): SubEmitter;
  74798. /**
  74799. * Serialize current object to a JSON object
  74800. * @returns the serialized object
  74801. */
  74802. serialize(): any;
  74803. /** @hidden */
  74804. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74805. /**
  74806. * Creates a new SubEmitter from a serialized JSON version
  74807. * @param serializationObject defines the JSON object to read from
  74808. * @param scene defines the hosting scene
  74809. * @param rootUrl defines the rootUrl for data loading
  74810. * @returns a new SubEmitter
  74811. */
  74812. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74813. /** Release associated resources */
  74814. dispose(): void;
  74815. }
  74816. }
  74817. declare module BABYLON {
  74818. /** @hidden */
  74819. export var clipPlaneFragmentDeclaration: {
  74820. name: string;
  74821. shader: string;
  74822. };
  74823. }
  74824. declare module BABYLON {
  74825. /** @hidden */
  74826. export var imageProcessingDeclaration: {
  74827. name: string;
  74828. shader: string;
  74829. };
  74830. }
  74831. declare module BABYLON {
  74832. /** @hidden */
  74833. export var imageProcessingFunctions: {
  74834. name: string;
  74835. shader: string;
  74836. };
  74837. }
  74838. declare module BABYLON {
  74839. /** @hidden */
  74840. export var clipPlaneFragment: {
  74841. name: string;
  74842. shader: string;
  74843. };
  74844. }
  74845. declare module BABYLON {
  74846. /** @hidden */
  74847. export var particlesPixelShader: {
  74848. name: string;
  74849. shader: string;
  74850. };
  74851. }
  74852. declare module BABYLON {
  74853. /** @hidden */
  74854. export var clipPlaneVertexDeclaration: {
  74855. name: string;
  74856. shader: string;
  74857. };
  74858. }
  74859. declare module BABYLON {
  74860. /** @hidden */
  74861. export var clipPlaneVertex: {
  74862. name: string;
  74863. shader: string;
  74864. };
  74865. }
  74866. declare module BABYLON {
  74867. /** @hidden */
  74868. export var particlesVertexShader: {
  74869. name: string;
  74870. shader: string;
  74871. };
  74872. }
  74873. declare module BABYLON {
  74874. /**
  74875. * This represents a particle system in Babylon.
  74876. * 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.
  74877. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74878. * @example https://doc.babylonjs.com/babylon101/particles
  74879. */
  74880. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74881. /**
  74882. * Billboard mode will only apply to Y axis
  74883. */
  74884. static readonly BILLBOARDMODE_Y: number;
  74885. /**
  74886. * Billboard mode will apply to all axes
  74887. */
  74888. static readonly BILLBOARDMODE_ALL: number;
  74889. /**
  74890. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74891. */
  74892. static readonly BILLBOARDMODE_STRETCHED: number;
  74893. /**
  74894. * This function can be defined to provide custom update for active particles.
  74895. * This function will be called instead of regular update (age, position, color, etc.).
  74896. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74897. */
  74898. updateFunction: (particles: Particle[]) => void;
  74899. private _emitterWorldMatrix;
  74900. /**
  74901. * This function can be defined to specify initial direction for every new particle.
  74902. * It by default use the emitterType defined function
  74903. */
  74904. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74905. /**
  74906. * This function can be defined to specify initial position for every new particle.
  74907. * It by default use the emitterType defined function
  74908. */
  74909. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74910. /**
  74911. * @hidden
  74912. */
  74913. _inheritedVelocityOffset: Vector3;
  74914. /**
  74915. * An event triggered when the system is disposed
  74916. */
  74917. onDisposeObservable: Observable<ParticleSystem>;
  74918. private _onDisposeObserver;
  74919. /**
  74920. * Sets a callback that will be triggered when the system is disposed
  74921. */
  74922. onDispose: () => void;
  74923. private _particles;
  74924. private _epsilon;
  74925. private _capacity;
  74926. private _stockParticles;
  74927. private _newPartsExcess;
  74928. private _vertexData;
  74929. private _vertexBuffer;
  74930. private _vertexBuffers;
  74931. private _spriteBuffer;
  74932. private _indexBuffer;
  74933. private _effect;
  74934. private _customEffect;
  74935. private _cachedDefines;
  74936. private _scaledColorStep;
  74937. private _colorDiff;
  74938. private _scaledDirection;
  74939. private _scaledGravity;
  74940. private _currentRenderId;
  74941. private _alive;
  74942. private _useInstancing;
  74943. private _started;
  74944. private _stopped;
  74945. private _actualFrame;
  74946. private _scaledUpdateSpeed;
  74947. private _vertexBufferSize;
  74948. /** @hidden */
  74949. _currentEmitRateGradient: Nullable<FactorGradient>;
  74950. /** @hidden */
  74951. _currentEmitRate1: number;
  74952. /** @hidden */
  74953. _currentEmitRate2: number;
  74954. /** @hidden */
  74955. _currentStartSizeGradient: Nullable<FactorGradient>;
  74956. /** @hidden */
  74957. _currentStartSize1: number;
  74958. /** @hidden */
  74959. _currentStartSize2: number;
  74960. private readonly _rawTextureWidth;
  74961. private _rampGradientsTexture;
  74962. private _useRampGradients;
  74963. /** Gets or sets a boolean indicating that ramp gradients must be used
  74964. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74965. */
  74966. useRampGradients: boolean;
  74967. /**
  74968. * 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.
  74969. * 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: [])
  74970. */
  74971. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74972. private _subEmitters;
  74973. /**
  74974. * @hidden
  74975. * If the particle systems emitter should be disposed when the particle system is disposed
  74976. */
  74977. _disposeEmitterOnDispose: boolean;
  74978. /**
  74979. * The current active Sub-systems, this property is used by the root particle system only.
  74980. */
  74981. activeSubSystems: Array<ParticleSystem>;
  74982. private _rootParticleSystem;
  74983. /**
  74984. * Gets the current list of active particles
  74985. */
  74986. readonly particles: Particle[];
  74987. /**
  74988. * Returns the string "ParticleSystem"
  74989. * @returns a string containing the class name
  74990. */
  74991. getClassName(): string;
  74992. /**
  74993. * Instantiates a particle system.
  74994. * 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.
  74995. * @param name The name of the particle system
  74996. * @param capacity The max number of particles alive at the same time
  74997. * @param scene The scene the particle system belongs to
  74998. * @param customEffect a custom effect used to change the way particles are rendered by default
  74999. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75000. * @param epsilon Offset used to render the particles
  75001. */
  75002. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  75003. private _addFactorGradient;
  75004. private _removeFactorGradient;
  75005. /**
  75006. * Adds a new life time gradient
  75007. * @param gradient defines the gradient to use (between 0 and 1)
  75008. * @param factor defines the life time factor to affect to the specified gradient
  75009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75010. * @returns the current particle system
  75011. */
  75012. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75013. /**
  75014. * Remove a specific life time gradient
  75015. * @param gradient defines the gradient to remove
  75016. * @returns the current particle system
  75017. */
  75018. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75019. /**
  75020. * Adds a new size gradient
  75021. * @param gradient defines the gradient to use (between 0 and 1)
  75022. * @param factor defines the size factor to affect to the specified gradient
  75023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75024. * @returns the current particle system
  75025. */
  75026. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75027. /**
  75028. * Remove a specific size gradient
  75029. * @param gradient defines the gradient to remove
  75030. * @returns the current particle system
  75031. */
  75032. removeSizeGradient(gradient: number): IParticleSystem;
  75033. /**
  75034. * Adds a new color remap gradient
  75035. * @param gradient defines the gradient to use (between 0 and 1)
  75036. * @param min defines the color remap minimal range
  75037. * @param max defines the color remap maximal range
  75038. * @returns the current particle system
  75039. */
  75040. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75041. /**
  75042. * Remove a specific color remap gradient
  75043. * @param gradient defines the gradient to remove
  75044. * @returns the current particle system
  75045. */
  75046. removeColorRemapGradient(gradient: number): IParticleSystem;
  75047. /**
  75048. * Adds a new alpha remap gradient
  75049. * @param gradient defines the gradient to use (between 0 and 1)
  75050. * @param min defines the alpha remap minimal range
  75051. * @param max defines the alpha remap maximal range
  75052. * @returns the current particle system
  75053. */
  75054. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75055. /**
  75056. * Remove a specific alpha remap gradient
  75057. * @param gradient defines the gradient to remove
  75058. * @returns the current particle system
  75059. */
  75060. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  75061. /**
  75062. * Adds a new angular speed gradient
  75063. * @param gradient defines the gradient to use (between 0 and 1)
  75064. * @param factor defines the angular speed to affect to the specified gradient
  75065. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75066. * @returns the current particle system
  75067. */
  75068. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75069. /**
  75070. * Remove a specific angular speed gradient
  75071. * @param gradient defines the gradient to remove
  75072. * @returns the current particle system
  75073. */
  75074. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75075. /**
  75076. * Adds a new velocity gradient
  75077. * @param gradient defines the gradient to use (between 0 and 1)
  75078. * @param factor defines the velocity to affect to the specified gradient
  75079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75080. * @returns the current particle system
  75081. */
  75082. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75083. /**
  75084. * Remove a specific velocity gradient
  75085. * @param gradient defines the gradient to remove
  75086. * @returns the current particle system
  75087. */
  75088. removeVelocityGradient(gradient: number): IParticleSystem;
  75089. /**
  75090. * Adds a new limit velocity gradient
  75091. * @param gradient defines the gradient to use (between 0 and 1)
  75092. * @param factor defines the limit velocity value to affect to the specified gradient
  75093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75094. * @returns the current particle system
  75095. */
  75096. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75097. /**
  75098. * Remove a specific limit velocity gradient
  75099. * @param gradient defines the gradient to remove
  75100. * @returns the current particle system
  75101. */
  75102. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75103. /**
  75104. * Adds a new drag gradient
  75105. * @param gradient defines the gradient to use (between 0 and 1)
  75106. * @param factor defines the drag value to affect to the specified gradient
  75107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75108. * @returns the current particle system
  75109. */
  75110. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75111. /**
  75112. * Remove a specific drag gradient
  75113. * @param gradient defines the gradient to remove
  75114. * @returns the current particle system
  75115. */
  75116. removeDragGradient(gradient: number): IParticleSystem;
  75117. /**
  75118. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75119. * @param gradient defines the gradient to use (between 0 and 1)
  75120. * @param factor defines the emit rate value to affect to the specified gradient
  75121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75122. * @returns the current particle system
  75123. */
  75124. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75125. /**
  75126. * Remove a specific emit rate gradient
  75127. * @param gradient defines the gradient to remove
  75128. * @returns the current particle system
  75129. */
  75130. removeEmitRateGradient(gradient: number): IParticleSystem;
  75131. /**
  75132. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75133. * @param gradient defines the gradient to use (between 0 and 1)
  75134. * @param factor defines the start size value to affect to the specified gradient
  75135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75136. * @returns the current particle system
  75137. */
  75138. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75139. /**
  75140. * Remove a specific start size gradient
  75141. * @param gradient defines the gradient to remove
  75142. * @returns the current particle system
  75143. */
  75144. removeStartSizeGradient(gradient: number): IParticleSystem;
  75145. private _createRampGradientTexture;
  75146. /**
  75147. * Gets the current list of ramp gradients.
  75148. * You must use addRampGradient and removeRampGradient to udpate this list
  75149. * @returns the list of ramp gradients
  75150. */
  75151. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75152. /**
  75153. * Adds a new ramp gradient used to remap particle colors
  75154. * @param gradient defines the gradient to use (between 0 and 1)
  75155. * @param color defines the color to affect to the specified gradient
  75156. * @returns the current particle system
  75157. */
  75158. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  75159. /**
  75160. * Remove a specific ramp gradient
  75161. * @param gradient defines the gradient to remove
  75162. * @returns the current particle system
  75163. */
  75164. removeRampGradient(gradient: number): ParticleSystem;
  75165. /**
  75166. * Adds a new color gradient
  75167. * @param gradient defines the gradient to use (between 0 and 1)
  75168. * @param color1 defines the color to affect to the specified gradient
  75169. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75170. * @returns this particle system
  75171. */
  75172. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75173. /**
  75174. * Remove a specific color gradient
  75175. * @param gradient defines the gradient to remove
  75176. * @returns this particle system
  75177. */
  75178. removeColorGradient(gradient: number): IParticleSystem;
  75179. private _fetchR;
  75180. protected _reset(): void;
  75181. private _resetEffect;
  75182. private _createVertexBuffers;
  75183. private _createIndexBuffer;
  75184. /**
  75185. * Gets the maximum number of particles active at the same time.
  75186. * @returns The max number of active particles.
  75187. */
  75188. getCapacity(): number;
  75189. /**
  75190. * Gets whether there are still active particles in the system.
  75191. * @returns True if it is alive, otherwise false.
  75192. */
  75193. isAlive(): boolean;
  75194. /**
  75195. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75196. * @returns True if it has been started, otherwise false.
  75197. */
  75198. isStarted(): boolean;
  75199. private _prepareSubEmitterInternalArray;
  75200. /**
  75201. * Starts the particle system and begins to emit
  75202. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75203. */
  75204. start(delay?: number): void;
  75205. /**
  75206. * Stops the particle system.
  75207. * @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.
  75208. */
  75209. stop(stopSubEmitters?: boolean): void;
  75210. /**
  75211. * Remove all active particles
  75212. */
  75213. reset(): void;
  75214. /**
  75215. * @hidden (for internal use only)
  75216. */
  75217. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  75218. /**
  75219. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  75220. * Its lifetime will start back at 0.
  75221. */
  75222. recycleParticle: (particle: Particle) => void;
  75223. private _stopSubEmitters;
  75224. private _createParticle;
  75225. private _removeFromRoot;
  75226. private _emitFromParticle;
  75227. private _update;
  75228. /** @hidden */
  75229. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  75230. /** @hidden */
  75231. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  75232. /** @hidden */
  75233. private _getEffect;
  75234. /**
  75235. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75236. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  75237. */
  75238. animate(preWarmOnly?: boolean): void;
  75239. private _appendParticleVertices;
  75240. /**
  75241. * Rebuilds the particle system.
  75242. */
  75243. rebuild(): void;
  75244. /**
  75245. * Is this system ready to be used/rendered
  75246. * @return true if the system is ready
  75247. */
  75248. isReady(): boolean;
  75249. private _render;
  75250. /**
  75251. * Renders the particle system in its current state.
  75252. * @returns the current number of particles
  75253. */
  75254. render(): number;
  75255. /**
  75256. * Disposes the particle system and free the associated resources
  75257. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75258. */
  75259. dispose(disposeTexture?: boolean): void;
  75260. /**
  75261. * Clones the particle system.
  75262. * @param name The name of the cloned object
  75263. * @param newEmitter The new emitter to use
  75264. * @returns the cloned particle system
  75265. */
  75266. clone(name: string, newEmitter: any): ParticleSystem;
  75267. /**
  75268. * Serializes the particle system to a JSON object.
  75269. * @returns the JSON object
  75270. */
  75271. serialize(): any;
  75272. /** @hidden */
  75273. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  75274. /** @hidden */
  75275. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  75276. /**
  75277. * Parses a JSON object to create a particle system.
  75278. * @param parsedParticleSystem The JSON object to parse
  75279. * @param scene The scene to create the particle system in
  75280. * @param rootUrl The root url to use to load external dependencies like texture
  75281. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75282. * @returns the Parsed particle system
  75283. */
  75284. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  75285. }
  75286. }
  75287. declare module BABYLON {
  75288. /**
  75289. * A particle represents one of the element emitted by a particle system.
  75290. * This is mainly define by its coordinates, direction, velocity and age.
  75291. */
  75292. export class Particle {
  75293. /**
  75294. * The particle system the particle belongs to.
  75295. */
  75296. particleSystem: ParticleSystem;
  75297. private static _Count;
  75298. /**
  75299. * Unique ID of the particle
  75300. */
  75301. id: number;
  75302. /**
  75303. * The world position of the particle in the scene.
  75304. */
  75305. position: Vector3;
  75306. /**
  75307. * The world direction of the particle in the scene.
  75308. */
  75309. direction: Vector3;
  75310. /**
  75311. * The color of the particle.
  75312. */
  75313. color: Color4;
  75314. /**
  75315. * The color change of the particle per step.
  75316. */
  75317. colorStep: Color4;
  75318. /**
  75319. * Defines how long will the life of the particle be.
  75320. */
  75321. lifeTime: number;
  75322. /**
  75323. * The current age of the particle.
  75324. */
  75325. age: number;
  75326. /**
  75327. * The current size of the particle.
  75328. */
  75329. size: number;
  75330. /**
  75331. * The current scale of the particle.
  75332. */
  75333. scale: Vector2;
  75334. /**
  75335. * The current angle of the particle.
  75336. */
  75337. angle: number;
  75338. /**
  75339. * Defines how fast is the angle changing.
  75340. */
  75341. angularSpeed: number;
  75342. /**
  75343. * Defines the cell index used by the particle to be rendered from a sprite.
  75344. */
  75345. cellIndex: number;
  75346. /**
  75347. * The information required to support color remapping
  75348. */
  75349. remapData: Vector4;
  75350. /** @hidden */
  75351. _randomCellOffset?: number;
  75352. /** @hidden */
  75353. _initialDirection: Nullable<Vector3>;
  75354. /** @hidden */
  75355. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  75356. /** @hidden */
  75357. _initialStartSpriteCellID: number;
  75358. /** @hidden */
  75359. _initialEndSpriteCellID: number;
  75360. /** @hidden */
  75361. _currentColorGradient: Nullable<ColorGradient>;
  75362. /** @hidden */
  75363. _currentColor1: Color4;
  75364. /** @hidden */
  75365. _currentColor2: Color4;
  75366. /** @hidden */
  75367. _currentSizeGradient: Nullable<FactorGradient>;
  75368. /** @hidden */
  75369. _currentSize1: number;
  75370. /** @hidden */
  75371. _currentSize2: number;
  75372. /** @hidden */
  75373. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  75374. /** @hidden */
  75375. _currentAngularSpeed1: number;
  75376. /** @hidden */
  75377. _currentAngularSpeed2: number;
  75378. /** @hidden */
  75379. _currentVelocityGradient: Nullable<FactorGradient>;
  75380. /** @hidden */
  75381. _currentVelocity1: number;
  75382. /** @hidden */
  75383. _currentVelocity2: number;
  75384. /** @hidden */
  75385. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  75386. /** @hidden */
  75387. _currentLimitVelocity1: number;
  75388. /** @hidden */
  75389. _currentLimitVelocity2: number;
  75390. /** @hidden */
  75391. _currentDragGradient: Nullable<FactorGradient>;
  75392. /** @hidden */
  75393. _currentDrag1: number;
  75394. /** @hidden */
  75395. _currentDrag2: number;
  75396. /** @hidden */
  75397. _randomNoiseCoordinates1: Vector3;
  75398. /** @hidden */
  75399. _randomNoiseCoordinates2: Vector3;
  75400. /**
  75401. * Creates a new instance Particle
  75402. * @param particleSystem the particle system the particle belongs to
  75403. */
  75404. constructor(
  75405. /**
  75406. * The particle system the particle belongs to.
  75407. */
  75408. particleSystem: ParticleSystem);
  75409. private updateCellInfoFromSystem;
  75410. /**
  75411. * Defines how the sprite cell index is updated for the particle
  75412. */
  75413. updateCellIndex(): void;
  75414. /** @hidden */
  75415. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  75416. /** @hidden */
  75417. _inheritParticleInfoToSubEmitters(): void;
  75418. /** @hidden */
  75419. _reset(): void;
  75420. /**
  75421. * Copy the properties of particle to another one.
  75422. * @param other the particle to copy the information to.
  75423. */
  75424. copyTo(other: Particle): void;
  75425. }
  75426. }
  75427. declare module BABYLON {
  75428. /**
  75429. * Particle emitter represents a volume emitting particles.
  75430. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  75431. */
  75432. export interface IParticleEmitterType {
  75433. /**
  75434. * Called by the particle System when the direction is computed for the created particle.
  75435. * @param worldMatrix is the world matrix of the particle system
  75436. * @param directionToUpdate is the direction vector to update with the result
  75437. * @param particle is the particle we are computed the direction for
  75438. */
  75439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75440. /**
  75441. * Called by the particle System when the position is computed for the created particle.
  75442. * @param worldMatrix is the world matrix of the particle system
  75443. * @param positionToUpdate is the position vector to update with the result
  75444. * @param particle is the particle we are computed the position for
  75445. */
  75446. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75447. /**
  75448. * Clones the current emitter and returns a copy of it
  75449. * @returns the new emitter
  75450. */
  75451. clone(): IParticleEmitterType;
  75452. /**
  75453. * Called by the GPUParticleSystem to setup the update shader
  75454. * @param effect defines the update shader
  75455. */
  75456. applyToShader(effect: Effect): void;
  75457. /**
  75458. * Returns a string to use to update the GPU particles update shader
  75459. * @returns the effect defines string
  75460. */
  75461. getEffectDefines(): string;
  75462. /**
  75463. * Returns a string representing the class name
  75464. * @returns a string containing the class name
  75465. */
  75466. getClassName(): string;
  75467. /**
  75468. * Serializes the particle system to a JSON object.
  75469. * @returns the JSON object
  75470. */
  75471. serialize(): any;
  75472. /**
  75473. * Parse properties from a JSON object
  75474. * @param serializationObject defines the JSON object
  75475. */
  75476. parse(serializationObject: any): void;
  75477. }
  75478. }
  75479. declare module BABYLON {
  75480. /**
  75481. * Particle emitter emitting particles from the inside of a box.
  75482. * It emits the particles randomly between 2 given directions.
  75483. */
  75484. export class BoxParticleEmitter implements IParticleEmitterType {
  75485. /**
  75486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75487. */
  75488. direction1: Vector3;
  75489. /**
  75490. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75491. */
  75492. direction2: Vector3;
  75493. /**
  75494. * 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.
  75495. */
  75496. minEmitBox: Vector3;
  75497. /**
  75498. * 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.
  75499. */
  75500. maxEmitBox: Vector3;
  75501. /**
  75502. * Creates a new instance BoxParticleEmitter
  75503. */
  75504. constructor();
  75505. /**
  75506. * Called by the particle System when the direction is computed for the created particle.
  75507. * @param worldMatrix is the world matrix of the particle system
  75508. * @param directionToUpdate is the direction vector to update with the result
  75509. * @param particle is the particle we are computed the direction for
  75510. */
  75511. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75512. /**
  75513. * Called by the particle System when the position is computed for the created particle.
  75514. * @param worldMatrix is the world matrix of the particle system
  75515. * @param positionToUpdate is the position vector to update with the result
  75516. * @param particle is the particle we are computed the position for
  75517. */
  75518. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75519. /**
  75520. * Clones the current emitter and returns a copy of it
  75521. * @returns the new emitter
  75522. */
  75523. clone(): BoxParticleEmitter;
  75524. /**
  75525. * Called by the GPUParticleSystem to setup the update shader
  75526. * @param effect defines the update shader
  75527. */
  75528. applyToShader(effect: Effect): void;
  75529. /**
  75530. * Returns a string to use to update the GPU particles update shader
  75531. * @returns a string containng the defines string
  75532. */
  75533. getEffectDefines(): string;
  75534. /**
  75535. * Returns the string "BoxParticleEmitter"
  75536. * @returns a string containing the class name
  75537. */
  75538. getClassName(): string;
  75539. /**
  75540. * Serializes the particle system to a JSON object.
  75541. * @returns the JSON object
  75542. */
  75543. serialize(): any;
  75544. /**
  75545. * Parse properties from a JSON object
  75546. * @param serializationObject defines the JSON object
  75547. */
  75548. parse(serializationObject: any): void;
  75549. }
  75550. }
  75551. declare module BABYLON {
  75552. /**
  75553. * Particle emitter emitting particles from the inside of a cone.
  75554. * It emits the particles alongside the cone volume from the base to the particle.
  75555. * The emission direction might be randomized.
  75556. */
  75557. export class ConeParticleEmitter implements IParticleEmitterType {
  75558. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75559. directionRandomizer: number;
  75560. private _radius;
  75561. private _angle;
  75562. private _height;
  75563. /**
  75564. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  75565. */
  75566. radiusRange: number;
  75567. /**
  75568. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  75569. */
  75570. heightRange: number;
  75571. /**
  75572. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  75573. */
  75574. emitFromSpawnPointOnly: boolean;
  75575. /**
  75576. * Gets or sets the radius of the emission cone
  75577. */
  75578. radius: number;
  75579. /**
  75580. * Gets or sets the angle of the emission cone
  75581. */
  75582. angle: number;
  75583. private _buildHeight;
  75584. /**
  75585. * Creates a new instance ConeParticleEmitter
  75586. * @param radius the radius of the emission cone (1 by default)
  75587. * @param angle the cone base angle (PI by default)
  75588. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  75589. */
  75590. constructor(radius?: number, angle?: number,
  75591. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  75592. directionRandomizer?: number);
  75593. /**
  75594. * Called by the particle System when the direction is computed for the created particle.
  75595. * @param worldMatrix is the world matrix of the particle system
  75596. * @param directionToUpdate is the direction vector to update with the result
  75597. * @param particle is the particle we are computed the direction for
  75598. */
  75599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75600. /**
  75601. * Called by the particle System when the position is computed for the created particle.
  75602. * @param worldMatrix is the world matrix of the particle system
  75603. * @param positionToUpdate is the position vector to update with the result
  75604. * @param particle is the particle we are computed the position for
  75605. */
  75606. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75607. /**
  75608. * Clones the current emitter and returns a copy of it
  75609. * @returns the new emitter
  75610. */
  75611. clone(): ConeParticleEmitter;
  75612. /**
  75613. * Called by the GPUParticleSystem to setup the update shader
  75614. * @param effect defines the update shader
  75615. */
  75616. applyToShader(effect: Effect): void;
  75617. /**
  75618. * Returns a string to use to update the GPU particles update shader
  75619. * @returns a string containng the defines string
  75620. */
  75621. getEffectDefines(): string;
  75622. /**
  75623. * Returns the string "ConeParticleEmitter"
  75624. * @returns a string containing the class name
  75625. */
  75626. getClassName(): string;
  75627. /**
  75628. * Serializes the particle system to a JSON object.
  75629. * @returns the JSON object
  75630. */
  75631. serialize(): any;
  75632. /**
  75633. * Parse properties from a JSON object
  75634. * @param serializationObject defines the JSON object
  75635. */
  75636. parse(serializationObject: any): void;
  75637. }
  75638. }
  75639. declare module BABYLON {
  75640. /**
  75641. * Particle emitter emitting particles from the inside of a cylinder.
  75642. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75643. */
  75644. export class CylinderParticleEmitter implements IParticleEmitterType {
  75645. /**
  75646. * The radius of the emission cylinder.
  75647. */
  75648. radius: number;
  75649. /**
  75650. * The height of the emission cylinder.
  75651. */
  75652. height: number;
  75653. /**
  75654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75655. */
  75656. radiusRange: number;
  75657. /**
  75658. * How much to randomize the particle direction [0-1].
  75659. */
  75660. directionRandomizer: number;
  75661. /**
  75662. * Creates a new instance CylinderParticleEmitter
  75663. * @param radius the radius of the emission cylinder (1 by default)
  75664. * @param height the height of the emission cylinder (1 by default)
  75665. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75666. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75667. */
  75668. constructor(
  75669. /**
  75670. * The radius of the emission cylinder.
  75671. */
  75672. radius?: number,
  75673. /**
  75674. * The height of the emission cylinder.
  75675. */
  75676. height?: number,
  75677. /**
  75678. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75679. */
  75680. radiusRange?: number,
  75681. /**
  75682. * How much to randomize the particle direction [0-1].
  75683. */
  75684. directionRandomizer?: number);
  75685. /**
  75686. * Called by the particle System when the direction is computed for the created particle.
  75687. * @param worldMatrix is the world matrix of the particle system
  75688. * @param directionToUpdate is the direction vector to update with the result
  75689. * @param particle is the particle we are computed the direction for
  75690. */
  75691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75692. /**
  75693. * Called by the particle System when the position is computed for the created particle.
  75694. * @param worldMatrix is the world matrix of the particle system
  75695. * @param positionToUpdate is the position vector to update with the result
  75696. * @param particle is the particle we are computed the position for
  75697. */
  75698. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75699. /**
  75700. * Clones the current emitter and returns a copy of it
  75701. * @returns the new emitter
  75702. */
  75703. clone(): CylinderParticleEmitter;
  75704. /**
  75705. * Called by the GPUParticleSystem to setup the update shader
  75706. * @param effect defines the update shader
  75707. */
  75708. applyToShader(effect: Effect): void;
  75709. /**
  75710. * Returns a string to use to update the GPU particles update shader
  75711. * @returns a string containng the defines string
  75712. */
  75713. getEffectDefines(): string;
  75714. /**
  75715. * Returns the string "CylinderParticleEmitter"
  75716. * @returns a string containing the class name
  75717. */
  75718. getClassName(): string;
  75719. /**
  75720. * Serializes the particle system to a JSON object.
  75721. * @returns the JSON object
  75722. */
  75723. serialize(): any;
  75724. /**
  75725. * Parse properties from a JSON object
  75726. * @param serializationObject defines the JSON object
  75727. */
  75728. parse(serializationObject: any): void;
  75729. }
  75730. /**
  75731. * Particle emitter emitting particles from the inside of a cylinder.
  75732. * It emits the particles randomly between two vectors.
  75733. */
  75734. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75735. /**
  75736. * The min limit of the emission direction.
  75737. */
  75738. direction1: Vector3;
  75739. /**
  75740. * The max limit of the emission direction.
  75741. */
  75742. direction2: Vector3;
  75743. /**
  75744. * Creates a new instance CylinderDirectedParticleEmitter
  75745. * @param radius the radius of the emission cylinder (1 by default)
  75746. * @param height the height of the emission cylinder (1 by default)
  75747. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75748. * @param direction1 the min limit of the emission direction (up vector by default)
  75749. * @param direction2 the max limit of the emission direction (up vector by default)
  75750. */
  75751. constructor(radius?: number, height?: number, radiusRange?: number,
  75752. /**
  75753. * The min limit of the emission direction.
  75754. */
  75755. direction1?: Vector3,
  75756. /**
  75757. * The max limit of the emission direction.
  75758. */
  75759. direction2?: Vector3);
  75760. /**
  75761. * Called by the particle System when the direction is computed for the created particle.
  75762. * @param worldMatrix is the world matrix of the particle system
  75763. * @param directionToUpdate is the direction vector to update with the result
  75764. * @param particle is the particle we are computed the direction for
  75765. */
  75766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75767. /**
  75768. * Clones the current emitter and returns a copy of it
  75769. * @returns the new emitter
  75770. */
  75771. clone(): CylinderDirectedParticleEmitter;
  75772. /**
  75773. * Called by the GPUParticleSystem to setup the update shader
  75774. * @param effect defines the update shader
  75775. */
  75776. applyToShader(effect: Effect): void;
  75777. /**
  75778. * Returns a string to use to update the GPU particles update shader
  75779. * @returns a string containng the defines string
  75780. */
  75781. getEffectDefines(): string;
  75782. /**
  75783. * Returns the string "CylinderDirectedParticleEmitter"
  75784. * @returns a string containing the class name
  75785. */
  75786. getClassName(): string;
  75787. /**
  75788. * Serializes the particle system to a JSON object.
  75789. * @returns the JSON object
  75790. */
  75791. serialize(): any;
  75792. /**
  75793. * Parse properties from a JSON object
  75794. * @param serializationObject defines the JSON object
  75795. */
  75796. parse(serializationObject: any): void;
  75797. }
  75798. }
  75799. declare module BABYLON {
  75800. /**
  75801. * Particle emitter emitting particles from the inside of a hemisphere.
  75802. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75803. */
  75804. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75805. /**
  75806. * The radius of the emission hemisphere.
  75807. */
  75808. radius: number;
  75809. /**
  75810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75811. */
  75812. radiusRange: number;
  75813. /**
  75814. * How much to randomize the particle direction [0-1].
  75815. */
  75816. directionRandomizer: number;
  75817. /**
  75818. * Creates a new instance HemisphericParticleEmitter
  75819. * @param radius the radius of the emission hemisphere (1 by default)
  75820. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75822. */
  75823. constructor(
  75824. /**
  75825. * The radius of the emission hemisphere.
  75826. */
  75827. radius?: number,
  75828. /**
  75829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75830. */
  75831. radiusRange?: number,
  75832. /**
  75833. * How much to randomize the particle direction [0-1].
  75834. */
  75835. directionRandomizer?: number);
  75836. /**
  75837. * Called by the particle System when the direction is computed for the created particle.
  75838. * @param worldMatrix is the world matrix of the particle system
  75839. * @param directionToUpdate is the direction vector to update with the result
  75840. * @param particle is the particle we are computed the direction for
  75841. */
  75842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75843. /**
  75844. * Called by the particle System when the position is computed for the created particle.
  75845. * @param worldMatrix is the world matrix of the particle system
  75846. * @param positionToUpdate is the position vector to update with the result
  75847. * @param particle is the particle we are computed the position for
  75848. */
  75849. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75850. /**
  75851. * Clones the current emitter and returns a copy of it
  75852. * @returns the new emitter
  75853. */
  75854. clone(): HemisphericParticleEmitter;
  75855. /**
  75856. * Called by the GPUParticleSystem to setup the update shader
  75857. * @param effect defines the update shader
  75858. */
  75859. applyToShader(effect: Effect): void;
  75860. /**
  75861. * Returns a string to use to update the GPU particles update shader
  75862. * @returns a string containng the defines string
  75863. */
  75864. getEffectDefines(): string;
  75865. /**
  75866. * Returns the string "HemisphericParticleEmitter"
  75867. * @returns a string containing the class name
  75868. */
  75869. getClassName(): string;
  75870. /**
  75871. * Serializes the particle system to a JSON object.
  75872. * @returns the JSON object
  75873. */
  75874. serialize(): any;
  75875. /**
  75876. * Parse properties from a JSON object
  75877. * @param serializationObject defines the JSON object
  75878. */
  75879. parse(serializationObject: any): void;
  75880. }
  75881. }
  75882. declare module BABYLON {
  75883. /**
  75884. * Particle emitter emitting particles from a point.
  75885. * It emits the particles randomly between 2 given directions.
  75886. */
  75887. export class PointParticleEmitter implements IParticleEmitterType {
  75888. /**
  75889. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75890. */
  75891. direction1: Vector3;
  75892. /**
  75893. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75894. */
  75895. direction2: Vector3;
  75896. /**
  75897. * Creates a new instance PointParticleEmitter
  75898. */
  75899. constructor();
  75900. /**
  75901. * Called by the particle System when the direction is computed for the created particle.
  75902. * @param worldMatrix is the world matrix of the particle system
  75903. * @param directionToUpdate is the direction vector to update with the result
  75904. * @param particle is the particle we are computed the direction for
  75905. */
  75906. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75907. /**
  75908. * Called by the particle System when the position is computed for the created particle.
  75909. * @param worldMatrix is the world matrix of the particle system
  75910. * @param positionToUpdate is the position vector to update with the result
  75911. * @param particle is the particle we are computed the position for
  75912. */
  75913. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75914. /**
  75915. * Clones the current emitter and returns a copy of it
  75916. * @returns the new emitter
  75917. */
  75918. clone(): PointParticleEmitter;
  75919. /**
  75920. * Called by the GPUParticleSystem to setup the update shader
  75921. * @param effect defines the update shader
  75922. */
  75923. applyToShader(effect: Effect): void;
  75924. /**
  75925. * Returns a string to use to update the GPU particles update shader
  75926. * @returns a string containng the defines string
  75927. */
  75928. getEffectDefines(): string;
  75929. /**
  75930. * Returns the string "PointParticleEmitter"
  75931. * @returns a string containing the class name
  75932. */
  75933. getClassName(): string;
  75934. /**
  75935. * Serializes the particle system to a JSON object.
  75936. * @returns the JSON object
  75937. */
  75938. serialize(): any;
  75939. /**
  75940. * Parse properties from a JSON object
  75941. * @param serializationObject defines the JSON object
  75942. */
  75943. parse(serializationObject: any): void;
  75944. }
  75945. }
  75946. declare module BABYLON {
  75947. /**
  75948. * Particle emitter emitting particles from the inside of a sphere.
  75949. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75950. */
  75951. export class SphereParticleEmitter implements IParticleEmitterType {
  75952. /**
  75953. * The radius of the emission sphere.
  75954. */
  75955. radius: number;
  75956. /**
  75957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75958. */
  75959. radiusRange: number;
  75960. /**
  75961. * How much to randomize the particle direction [0-1].
  75962. */
  75963. directionRandomizer: number;
  75964. /**
  75965. * Creates a new instance SphereParticleEmitter
  75966. * @param radius the radius of the emission sphere (1 by default)
  75967. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75968. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75969. */
  75970. constructor(
  75971. /**
  75972. * The radius of the emission sphere.
  75973. */
  75974. radius?: number,
  75975. /**
  75976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75977. */
  75978. radiusRange?: number,
  75979. /**
  75980. * How much to randomize the particle direction [0-1].
  75981. */
  75982. directionRandomizer?: number);
  75983. /**
  75984. * Called by the particle System when the direction is computed for the created particle.
  75985. * @param worldMatrix is the world matrix of the particle system
  75986. * @param directionToUpdate is the direction vector to update with the result
  75987. * @param particle is the particle we are computed the direction for
  75988. */
  75989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75990. /**
  75991. * Called by the particle System when the position is computed for the created particle.
  75992. * @param worldMatrix is the world matrix of the particle system
  75993. * @param positionToUpdate is the position vector to update with the result
  75994. * @param particle is the particle we are computed the position for
  75995. */
  75996. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75997. /**
  75998. * Clones the current emitter and returns a copy of it
  75999. * @returns the new emitter
  76000. */
  76001. clone(): SphereParticleEmitter;
  76002. /**
  76003. * Called by the GPUParticleSystem to setup the update shader
  76004. * @param effect defines the update shader
  76005. */
  76006. applyToShader(effect: Effect): void;
  76007. /**
  76008. * Returns a string to use to update the GPU particles update shader
  76009. * @returns a string containng the defines string
  76010. */
  76011. getEffectDefines(): string;
  76012. /**
  76013. * Returns the string "SphereParticleEmitter"
  76014. * @returns a string containing the class name
  76015. */
  76016. getClassName(): string;
  76017. /**
  76018. * Serializes the particle system to a JSON object.
  76019. * @returns the JSON object
  76020. */
  76021. serialize(): any;
  76022. /**
  76023. * Parse properties from a JSON object
  76024. * @param serializationObject defines the JSON object
  76025. */
  76026. parse(serializationObject: any): void;
  76027. }
  76028. /**
  76029. * Particle emitter emitting particles from the inside of a sphere.
  76030. * It emits the particles randomly between two vectors.
  76031. */
  76032. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  76033. /**
  76034. * The min limit of the emission direction.
  76035. */
  76036. direction1: Vector3;
  76037. /**
  76038. * The max limit of the emission direction.
  76039. */
  76040. direction2: Vector3;
  76041. /**
  76042. * Creates a new instance SphereDirectedParticleEmitter
  76043. * @param radius the radius of the emission sphere (1 by default)
  76044. * @param direction1 the min limit of the emission direction (up vector by default)
  76045. * @param direction2 the max limit of the emission direction (up vector by default)
  76046. */
  76047. constructor(radius?: number,
  76048. /**
  76049. * The min limit of the emission direction.
  76050. */
  76051. direction1?: Vector3,
  76052. /**
  76053. * The max limit of the emission direction.
  76054. */
  76055. direction2?: Vector3);
  76056. /**
  76057. * Called by the particle System when the direction is computed for the created particle.
  76058. * @param worldMatrix is the world matrix of the particle system
  76059. * @param directionToUpdate is the direction vector to update with the result
  76060. * @param particle is the particle we are computed the direction for
  76061. */
  76062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  76063. /**
  76064. * Clones the current emitter and returns a copy of it
  76065. * @returns the new emitter
  76066. */
  76067. clone(): SphereDirectedParticleEmitter;
  76068. /**
  76069. * Called by the GPUParticleSystem to setup the update shader
  76070. * @param effect defines the update shader
  76071. */
  76072. applyToShader(effect: Effect): void;
  76073. /**
  76074. * Returns a string to use to update the GPU particles update shader
  76075. * @returns a string containng the defines string
  76076. */
  76077. getEffectDefines(): string;
  76078. /**
  76079. * Returns the string "SphereDirectedParticleEmitter"
  76080. * @returns a string containing the class name
  76081. */
  76082. getClassName(): string;
  76083. /**
  76084. * Serializes the particle system to a JSON object.
  76085. * @returns the JSON object
  76086. */
  76087. serialize(): any;
  76088. /**
  76089. * Parse properties from a JSON object
  76090. * @param serializationObject defines the JSON object
  76091. */
  76092. parse(serializationObject: any): void;
  76093. }
  76094. }
  76095. declare module BABYLON {
  76096. /**
  76097. * Interface representing a particle system in Babylon.js.
  76098. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  76099. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  76100. */
  76101. export interface IParticleSystem {
  76102. /**
  76103. * List of animations used by the particle system.
  76104. */
  76105. animations: Animation[];
  76106. /**
  76107. * The id of the Particle system.
  76108. */
  76109. id: string;
  76110. /**
  76111. * The name of the Particle system.
  76112. */
  76113. name: string;
  76114. /**
  76115. * The emitter represents the Mesh or position we are attaching the particle system to.
  76116. */
  76117. emitter: Nullable<AbstractMesh | Vector3>;
  76118. /**
  76119. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76120. */
  76121. isBillboardBased: boolean;
  76122. /**
  76123. * The rendering group used by the Particle system to chose when to render.
  76124. */
  76125. renderingGroupId: number;
  76126. /**
  76127. * The layer mask we are rendering the particles through.
  76128. */
  76129. layerMask: number;
  76130. /**
  76131. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76132. */
  76133. updateSpeed: number;
  76134. /**
  76135. * The amount of time the particle system is running (depends of the overall update speed).
  76136. */
  76137. targetStopDuration: number;
  76138. /**
  76139. * The texture used to render each particle. (this can be a spritesheet)
  76140. */
  76141. particleTexture: Nullable<Texture>;
  76142. /**
  76143. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  76144. */
  76145. blendMode: number;
  76146. /**
  76147. * Minimum life time of emitting particles.
  76148. */
  76149. minLifeTime: number;
  76150. /**
  76151. * Maximum life time of emitting particles.
  76152. */
  76153. maxLifeTime: number;
  76154. /**
  76155. * Minimum Size of emitting particles.
  76156. */
  76157. minSize: number;
  76158. /**
  76159. * Maximum Size of emitting particles.
  76160. */
  76161. maxSize: number;
  76162. /**
  76163. * Minimum scale of emitting particles on X axis.
  76164. */
  76165. minScaleX: number;
  76166. /**
  76167. * Maximum scale of emitting particles on X axis.
  76168. */
  76169. maxScaleX: number;
  76170. /**
  76171. * Minimum scale of emitting particles on Y axis.
  76172. */
  76173. minScaleY: number;
  76174. /**
  76175. * Maximum scale of emitting particles on Y axis.
  76176. */
  76177. maxScaleY: number;
  76178. /**
  76179. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76180. */
  76181. color1: Color4;
  76182. /**
  76183. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  76184. */
  76185. color2: Color4;
  76186. /**
  76187. * Color the particle will have at the end of its lifetime.
  76188. */
  76189. colorDead: Color4;
  76190. /**
  76191. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  76192. */
  76193. emitRate: number;
  76194. /**
  76195. * You can use gravity if you want to give an orientation to your particles.
  76196. */
  76197. gravity: Vector3;
  76198. /**
  76199. * Minimum power of emitting particles.
  76200. */
  76201. minEmitPower: number;
  76202. /**
  76203. * Maximum power of emitting particles.
  76204. */
  76205. maxEmitPower: number;
  76206. /**
  76207. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76208. */
  76209. minAngularSpeed: number;
  76210. /**
  76211. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76212. */
  76213. maxAngularSpeed: number;
  76214. /**
  76215. * Gets or sets the minimal initial rotation in radians.
  76216. */
  76217. minInitialRotation: number;
  76218. /**
  76219. * Gets or sets the maximal initial rotation in radians.
  76220. */
  76221. maxInitialRotation: number;
  76222. /**
  76223. * The particle emitter type defines the emitter used by the particle system.
  76224. * It can be for example box, sphere, or cone...
  76225. */
  76226. particleEmitterType: Nullable<IParticleEmitterType>;
  76227. /**
  76228. * Defines the delay in milliseconds before starting the system (0 by default)
  76229. */
  76230. startDelay: number;
  76231. /**
  76232. * 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
  76233. */
  76234. preWarmCycles: number;
  76235. /**
  76236. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  76237. */
  76238. preWarmStepOffset: number;
  76239. /**
  76240. * 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)
  76241. */
  76242. spriteCellChangeSpeed: number;
  76243. /**
  76244. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76245. */
  76246. startSpriteCellID: number;
  76247. /**
  76248. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76249. */
  76250. endSpriteCellID: number;
  76251. /**
  76252. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76253. */
  76254. spriteCellWidth: number;
  76255. /**
  76256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76257. */
  76258. spriteCellHeight: number;
  76259. /**
  76260. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76261. */
  76262. spriteRandomStartCell: boolean;
  76263. /**
  76264. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  76265. */
  76266. isAnimationSheetEnabled: boolean;
  76267. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76268. translationPivot: Vector2;
  76269. /**
  76270. * Gets or sets a texture used to add random noise to particle positions
  76271. */
  76272. noiseTexture: Nullable<BaseTexture>;
  76273. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76274. noiseStrength: Vector3;
  76275. /**
  76276. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76277. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76278. */
  76279. billboardMode: number;
  76280. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76281. limitVelocityDamping: number;
  76282. /**
  76283. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76284. */
  76285. beginAnimationOnStart: boolean;
  76286. /**
  76287. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76288. */
  76289. beginAnimationFrom: number;
  76290. /**
  76291. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76292. */
  76293. beginAnimationTo: number;
  76294. /**
  76295. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76296. */
  76297. beginAnimationLoop: boolean;
  76298. /**
  76299. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76300. */
  76301. disposeOnStop: boolean;
  76302. /**
  76303. * Gets the maximum number of particles active at the same time.
  76304. * @returns The max number of active particles.
  76305. */
  76306. getCapacity(): number;
  76307. /**
  76308. * Gets if the system has been started. (Note: this will still be true after stop is called)
  76309. * @returns True if it has been started, otherwise false.
  76310. */
  76311. isStarted(): boolean;
  76312. /**
  76313. * Animates the particle system for this frame.
  76314. */
  76315. animate(): void;
  76316. /**
  76317. * Renders the particle system in its current state.
  76318. * @returns the current number of particles
  76319. */
  76320. render(): number;
  76321. /**
  76322. * Dispose the particle system and frees its associated resources.
  76323. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  76324. */
  76325. dispose(disposeTexture?: boolean): void;
  76326. /**
  76327. * Clones the particle system.
  76328. * @param name The name of the cloned object
  76329. * @param newEmitter The new emitter to use
  76330. * @returns the cloned particle system
  76331. */
  76332. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  76333. /**
  76334. * Serializes the particle system to a JSON object.
  76335. * @returns the JSON object
  76336. */
  76337. serialize(): any;
  76338. /**
  76339. * Rebuild the particle system
  76340. */
  76341. rebuild(): void;
  76342. /**
  76343. * Starts the particle system and begins to emit
  76344. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  76345. */
  76346. start(delay?: number): void;
  76347. /**
  76348. * Stops the particle system.
  76349. */
  76350. stop(): void;
  76351. /**
  76352. * Remove all active particles
  76353. */
  76354. reset(): void;
  76355. /**
  76356. * Is this system ready to be used/rendered
  76357. * @return true if the system is ready
  76358. */
  76359. isReady(): boolean;
  76360. /**
  76361. * Adds a new color gradient
  76362. * @param gradient defines the gradient to use (between 0 and 1)
  76363. * @param color1 defines the color to affect to the specified gradient
  76364. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  76365. * @returns the current particle system
  76366. */
  76367. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  76368. /**
  76369. * Remove a specific color gradient
  76370. * @param gradient defines the gradient to remove
  76371. * @returns the current particle system
  76372. */
  76373. removeColorGradient(gradient: number): IParticleSystem;
  76374. /**
  76375. * Adds a new size gradient
  76376. * @param gradient defines the gradient to use (between 0 and 1)
  76377. * @param factor defines the size factor to affect to the specified gradient
  76378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76379. * @returns the current particle system
  76380. */
  76381. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76382. /**
  76383. * Remove a specific size gradient
  76384. * @param gradient defines the gradient to remove
  76385. * @returns the current particle system
  76386. */
  76387. removeSizeGradient(gradient: number): IParticleSystem;
  76388. /**
  76389. * Gets the current list of color gradients.
  76390. * You must use addColorGradient and removeColorGradient to udpate this list
  76391. * @returns the list of color gradients
  76392. */
  76393. getColorGradients(): Nullable<Array<ColorGradient>>;
  76394. /**
  76395. * Gets the current list of size gradients.
  76396. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76397. * @returns the list of size gradients
  76398. */
  76399. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76400. /**
  76401. * Gets the current list of angular speed gradients.
  76402. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76403. * @returns the list of angular speed gradients
  76404. */
  76405. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76406. /**
  76407. * Adds a new angular speed gradient
  76408. * @param gradient defines the gradient to use (between 0 and 1)
  76409. * @param factor defines the angular speed to affect to the specified gradient
  76410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76411. * @returns the current particle system
  76412. */
  76413. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76414. /**
  76415. * Remove a specific angular speed gradient
  76416. * @param gradient defines the gradient to remove
  76417. * @returns the current particle system
  76418. */
  76419. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  76420. /**
  76421. * Gets the current list of velocity gradients.
  76422. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76423. * @returns the list of velocity gradients
  76424. */
  76425. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76426. /**
  76427. * Adds a new velocity gradient
  76428. * @param gradient defines the gradient to use (between 0 and 1)
  76429. * @param factor defines the velocity to affect to the specified gradient
  76430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76431. * @returns the current particle system
  76432. */
  76433. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76434. /**
  76435. * Remove a specific velocity gradient
  76436. * @param gradient defines the gradient to remove
  76437. * @returns the current particle system
  76438. */
  76439. removeVelocityGradient(gradient: number): IParticleSystem;
  76440. /**
  76441. * Gets the current list of limit velocity gradients.
  76442. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76443. * @returns the list of limit velocity gradients
  76444. */
  76445. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76446. /**
  76447. * Adds a new limit velocity gradient
  76448. * @param gradient defines the gradient to use (between 0 and 1)
  76449. * @param factor defines the limit velocity to affect to the specified gradient
  76450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76451. * @returns the current particle system
  76452. */
  76453. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76454. /**
  76455. * Remove a specific limit velocity gradient
  76456. * @param gradient defines the gradient to remove
  76457. * @returns the current particle system
  76458. */
  76459. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  76460. /**
  76461. * Adds a new drag gradient
  76462. * @param gradient defines the gradient to use (between 0 and 1)
  76463. * @param factor defines the drag to affect to the specified gradient
  76464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76465. * @returns the current particle system
  76466. */
  76467. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76468. /**
  76469. * Remove a specific drag gradient
  76470. * @param gradient defines the gradient to remove
  76471. * @returns the current particle system
  76472. */
  76473. removeDragGradient(gradient: number): IParticleSystem;
  76474. /**
  76475. * Gets the current list of drag gradients.
  76476. * You must use addDragGradient and removeDragGradient to udpate this list
  76477. * @returns the list of drag gradients
  76478. */
  76479. getDragGradients(): Nullable<Array<FactorGradient>>;
  76480. /**
  76481. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  76482. * @param gradient defines the gradient to use (between 0 and 1)
  76483. * @param factor defines the emit rate to affect to the specified gradient
  76484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76485. * @returns the current particle system
  76486. */
  76487. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76488. /**
  76489. * Remove a specific emit rate gradient
  76490. * @param gradient defines the gradient to remove
  76491. * @returns the current particle system
  76492. */
  76493. removeEmitRateGradient(gradient: number): IParticleSystem;
  76494. /**
  76495. * Gets the current list of emit rate gradients.
  76496. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76497. * @returns the list of emit rate gradients
  76498. */
  76499. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76500. /**
  76501. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  76502. * @param gradient defines the gradient to use (between 0 and 1)
  76503. * @param factor defines the start size to affect to the specified gradient
  76504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76505. * @returns the current particle system
  76506. */
  76507. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76508. /**
  76509. * Remove a specific start size gradient
  76510. * @param gradient defines the gradient to remove
  76511. * @returns the current particle system
  76512. */
  76513. removeStartSizeGradient(gradient: number): IParticleSystem;
  76514. /**
  76515. * Gets the current list of start size gradients.
  76516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76517. * @returns the list of start size gradients
  76518. */
  76519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76520. /**
  76521. * Adds a new life time gradient
  76522. * @param gradient defines the gradient to use (between 0 and 1)
  76523. * @param factor defines the life time factor to affect to the specified gradient
  76524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  76525. * @returns the current particle system
  76526. */
  76527. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  76528. /**
  76529. * Remove a specific life time gradient
  76530. * @param gradient defines the gradient to remove
  76531. * @returns the current particle system
  76532. */
  76533. removeLifeTimeGradient(gradient: number): IParticleSystem;
  76534. /**
  76535. * Gets the current list of life time gradients.
  76536. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76537. * @returns the list of life time gradients
  76538. */
  76539. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76540. /**
  76541. * Gets the current list of color gradients.
  76542. * You must use addColorGradient and removeColorGradient to udpate this list
  76543. * @returns the list of color gradients
  76544. */
  76545. getColorGradients(): Nullable<Array<ColorGradient>>;
  76546. /**
  76547. * Adds a new ramp gradient used to remap particle colors
  76548. * @param gradient defines the gradient to use (between 0 and 1)
  76549. * @param color defines the color to affect to the specified gradient
  76550. * @returns the current particle system
  76551. */
  76552. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  76553. /**
  76554. * Gets the current list of ramp gradients.
  76555. * You must use addRampGradient and removeRampGradient to udpate this list
  76556. * @returns the list of ramp gradients
  76557. */
  76558. getRampGradients(): Nullable<Array<Color3Gradient>>;
  76559. /** Gets or sets a boolean indicating that ramp gradients must be used
  76560. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  76561. */
  76562. useRampGradients: boolean;
  76563. /**
  76564. * Adds a new color remap gradient
  76565. * @param gradient defines the gradient to use (between 0 and 1)
  76566. * @param min defines the color remap minimal range
  76567. * @param max defines the color remap maximal range
  76568. * @returns the current particle system
  76569. */
  76570. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76571. /**
  76572. * Gets the current list of color remap gradients.
  76573. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76574. * @returns the list of color remap gradients
  76575. */
  76576. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76577. /**
  76578. * Adds a new alpha remap gradient
  76579. * @param gradient defines the gradient to use (between 0 and 1)
  76580. * @param min defines the alpha remap minimal range
  76581. * @param max defines the alpha remap maximal range
  76582. * @returns the current particle system
  76583. */
  76584. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  76585. /**
  76586. * Gets the current list of alpha remap gradients.
  76587. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76588. * @returns the list of alpha remap gradients
  76589. */
  76590. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76591. /**
  76592. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76595. * @returns the emitter
  76596. */
  76597. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76598. /**
  76599. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76600. * @param radius The radius of the hemisphere to emit from
  76601. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76602. * @returns the emitter
  76603. */
  76604. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  76605. /**
  76606. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76607. * @param radius The radius of the sphere to emit from
  76608. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76609. * @returns the emitter
  76610. */
  76611. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  76612. /**
  76613. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76614. * @param radius The radius of the sphere to emit from
  76615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76617. * @returns the emitter
  76618. */
  76619. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76620. /**
  76621. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76622. * @param radius The radius of the emission cylinder
  76623. * @param height The height of the emission cylinder
  76624. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76625. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76626. * @returns the emitter
  76627. */
  76628. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  76629. /**
  76630. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76631. * @param radius The radius of the cylinder to emit from
  76632. * @param height The height of the emission cylinder
  76633. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76636. * @returns the emitter
  76637. */
  76638. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76639. /**
  76640. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76641. * @param radius The radius of the cone to emit from
  76642. * @param angle The base angle of the cone
  76643. * @returns the emitter
  76644. */
  76645. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76646. /**
  76647. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76648. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76649. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76650. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76651. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76652. * @returns the emitter
  76653. */
  76654. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76655. /**
  76656. * Get hosting scene
  76657. * @returns the scene
  76658. */
  76659. getScene(): Scene;
  76660. }
  76661. }
  76662. declare module BABYLON {
  76663. /**
  76664. * Creates an instance based on a source mesh.
  76665. */
  76666. export class InstancedMesh extends AbstractMesh {
  76667. private _sourceMesh;
  76668. private _currentLOD;
  76669. /** @hidden */
  76670. _indexInSourceMeshInstanceArray: number;
  76671. constructor(name: string, source: Mesh);
  76672. /**
  76673. * Returns the string "InstancedMesh".
  76674. */
  76675. getClassName(): string;
  76676. /** Gets the list of lights affecting that mesh */
  76677. readonly lightSources: Light[];
  76678. _resyncLightSources(): void;
  76679. _resyncLighSource(light: Light): void;
  76680. _removeLightSource(light: Light): void;
  76681. /**
  76682. * If the source mesh receives shadows
  76683. */
  76684. readonly receiveShadows: boolean;
  76685. /**
  76686. * The material of the source mesh
  76687. */
  76688. readonly material: Nullable<Material>;
  76689. /**
  76690. * Visibility of the source mesh
  76691. */
  76692. readonly visibility: number;
  76693. /**
  76694. * Skeleton of the source mesh
  76695. */
  76696. readonly skeleton: Nullable<Skeleton>;
  76697. /**
  76698. * Rendering ground id of the source mesh
  76699. */
  76700. renderingGroupId: number;
  76701. /**
  76702. * Returns the total number of vertices (integer).
  76703. */
  76704. getTotalVertices(): number;
  76705. /**
  76706. * Returns a positive integer : the total number of indices in this mesh geometry.
  76707. * @returns the numner of indices or zero if the mesh has no geometry.
  76708. */
  76709. getTotalIndices(): number;
  76710. /**
  76711. * The source mesh of the instance
  76712. */
  76713. readonly sourceMesh: Mesh;
  76714. /**
  76715. * Is this node ready to be used/rendered
  76716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76717. * @return {boolean} is it ready
  76718. */
  76719. isReady(completeCheck?: boolean): boolean;
  76720. /**
  76721. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76722. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76723. * @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.
  76724. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76725. */
  76726. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76727. /**
  76728. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76729. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76730. * The `data` are either a numeric array either a Float32Array.
  76731. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76732. * 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).
  76733. * Note that a new underlying VertexBuffer object is created each call.
  76734. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76735. *
  76736. * Possible `kind` values :
  76737. * - VertexBuffer.PositionKind
  76738. * - VertexBuffer.UVKind
  76739. * - VertexBuffer.UV2Kind
  76740. * - VertexBuffer.UV3Kind
  76741. * - VertexBuffer.UV4Kind
  76742. * - VertexBuffer.UV5Kind
  76743. * - VertexBuffer.UV6Kind
  76744. * - VertexBuffer.ColorKind
  76745. * - VertexBuffer.MatricesIndicesKind
  76746. * - VertexBuffer.MatricesIndicesExtraKind
  76747. * - VertexBuffer.MatricesWeightsKind
  76748. * - VertexBuffer.MatricesWeightsExtraKind
  76749. *
  76750. * Returns the Mesh.
  76751. */
  76752. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76753. /**
  76754. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76755. * If the mesh has no geometry, it is simply returned as it is.
  76756. * The `data` are either a numeric array either a Float32Array.
  76757. * No new underlying VertexBuffer object is created.
  76758. * 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.
  76759. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76760. *
  76761. * Possible `kind` values :
  76762. * - VertexBuffer.PositionKind
  76763. * - VertexBuffer.UVKind
  76764. * - VertexBuffer.UV2Kind
  76765. * - VertexBuffer.UV3Kind
  76766. * - VertexBuffer.UV4Kind
  76767. * - VertexBuffer.UV5Kind
  76768. * - VertexBuffer.UV6Kind
  76769. * - VertexBuffer.ColorKind
  76770. * - VertexBuffer.MatricesIndicesKind
  76771. * - VertexBuffer.MatricesIndicesExtraKind
  76772. * - VertexBuffer.MatricesWeightsKind
  76773. * - VertexBuffer.MatricesWeightsExtraKind
  76774. *
  76775. * Returns the Mesh.
  76776. */
  76777. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76778. /**
  76779. * Sets the mesh indices.
  76780. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76781. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76782. * This method creates a new index buffer each call.
  76783. * Returns the Mesh.
  76784. */
  76785. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76786. /**
  76787. * Boolean : True if the mesh owns the requested kind of data.
  76788. */
  76789. isVerticesDataPresent(kind: string): boolean;
  76790. /**
  76791. * Returns an array of indices (IndicesArray).
  76792. */
  76793. getIndices(): Nullable<IndicesArray>;
  76794. readonly _positions: Nullable<Vector3[]>;
  76795. /**
  76796. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76797. * This means the mesh underlying bounding box and sphere are recomputed.
  76798. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76799. * @returns the current mesh
  76800. */
  76801. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76802. /** @hidden */
  76803. _preActivate(): InstancedMesh;
  76804. /** @hidden */
  76805. _activate(renderId: number): boolean;
  76806. /** @hidden */
  76807. _postActivate(): void;
  76808. getWorldMatrix(): Matrix;
  76809. readonly isAnInstance: boolean;
  76810. /**
  76811. * Returns the current associated LOD AbstractMesh.
  76812. */
  76813. getLOD(camera: Camera): AbstractMesh;
  76814. /** @hidden */
  76815. _syncSubMeshes(): InstancedMesh;
  76816. /** @hidden */
  76817. _generatePointsArray(): boolean;
  76818. /**
  76819. * Creates a new InstancedMesh from the current mesh.
  76820. * - name (string) : the cloned mesh name
  76821. * - newParent (optional Node) : the optional Node to parent the clone to.
  76822. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76823. *
  76824. * Returns the clone.
  76825. */
  76826. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76827. /**
  76828. * Disposes the InstancedMesh.
  76829. * Returns nothing.
  76830. */
  76831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76832. }
  76833. }
  76834. declare module BABYLON {
  76835. /**
  76836. * Defines the options associated with the creation of a shader material.
  76837. */
  76838. export interface IShaderMaterialOptions {
  76839. /**
  76840. * Does the material work in alpha blend mode
  76841. */
  76842. needAlphaBlending: boolean;
  76843. /**
  76844. * Does the material work in alpha test mode
  76845. */
  76846. needAlphaTesting: boolean;
  76847. /**
  76848. * The list of attribute names used in the shader
  76849. */
  76850. attributes: string[];
  76851. /**
  76852. * The list of unifrom names used in the shader
  76853. */
  76854. uniforms: string[];
  76855. /**
  76856. * The list of UBO names used in the shader
  76857. */
  76858. uniformBuffers: string[];
  76859. /**
  76860. * The list of sampler names used in the shader
  76861. */
  76862. samplers: string[];
  76863. /**
  76864. * The list of defines used in the shader
  76865. */
  76866. defines: string[];
  76867. }
  76868. /**
  76869. * 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.
  76870. *
  76871. * This returned material effects how the mesh will look based on the code in the shaders.
  76872. *
  76873. * @see http://doc.babylonjs.com/how_to/shader_material
  76874. */
  76875. export class ShaderMaterial extends Material {
  76876. private _shaderPath;
  76877. private _options;
  76878. private _textures;
  76879. private _textureArrays;
  76880. private _floats;
  76881. private _ints;
  76882. private _floatsArrays;
  76883. private _colors3;
  76884. private _colors3Arrays;
  76885. private _colors4;
  76886. private _vectors2;
  76887. private _vectors3;
  76888. private _vectors4;
  76889. private _matrices;
  76890. private _matrices3x3;
  76891. private _matrices2x2;
  76892. private _vectors2Arrays;
  76893. private _vectors3Arrays;
  76894. private _cachedWorldViewMatrix;
  76895. private _renderId;
  76896. /**
  76897. * Instantiate a new shader material.
  76898. * 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.
  76899. * This returned material effects how the mesh will look based on the code in the shaders.
  76900. * @see http://doc.babylonjs.com/how_to/shader_material
  76901. * @param name Define the name of the material in the scene
  76902. * @param scene Define the scene the material belongs to
  76903. * @param shaderPath Defines the route to the shader code in one of three ways:
  76904. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76905. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76906. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76907. * @param options Define the options used to create the shader
  76908. */
  76909. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76910. /**
  76911. * Gets the options used to compile the shader.
  76912. * They can be modified to trigger a new compilation
  76913. */
  76914. readonly options: IShaderMaterialOptions;
  76915. /**
  76916. * Gets the current class name of the material e.g. "ShaderMaterial"
  76917. * Mainly use in serialization.
  76918. * @returns the class name
  76919. */
  76920. getClassName(): string;
  76921. /**
  76922. * Specifies if the material will require alpha blending
  76923. * @returns a boolean specifying if alpha blending is needed
  76924. */
  76925. needAlphaBlending(): boolean;
  76926. /**
  76927. * Specifies if this material should be rendered in alpha test mode
  76928. * @returns a boolean specifying if an alpha test is needed.
  76929. */
  76930. needAlphaTesting(): boolean;
  76931. private _checkUniform;
  76932. /**
  76933. * Set a texture in the shader.
  76934. * @param name Define the name of the uniform samplers as defined in the shader
  76935. * @param texture Define the texture to bind to this sampler
  76936. * @return the material itself allowing "fluent" like uniform updates
  76937. */
  76938. setTexture(name: string, texture: Texture): ShaderMaterial;
  76939. /**
  76940. * Set a texture array in the shader.
  76941. * @param name Define the name of the uniform sampler array as defined in the shader
  76942. * @param textures Define the list of textures to bind to this sampler
  76943. * @return the material itself allowing "fluent" like uniform updates
  76944. */
  76945. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76946. /**
  76947. * Set a float in the shader.
  76948. * @param name Define the name of the uniform as defined in the shader
  76949. * @param value Define the value to give to the uniform
  76950. * @return the material itself allowing "fluent" like uniform updates
  76951. */
  76952. setFloat(name: string, value: number): ShaderMaterial;
  76953. /**
  76954. * Set a int in the shader.
  76955. * @param name Define the name of the uniform as defined in the shader
  76956. * @param value Define the value to give to the uniform
  76957. * @return the material itself allowing "fluent" like uniform updates
  76958. */
  76959. setInt(name: string, value: number): ShaderMaterial;
  76960. /**
  76961. * Set an array of floats in the shader.
  76962. * @param name Define the name of the uniform as defined in the shader
  76963. * @param value Define the value to give to the uniform
  76964. * @return the material itself allowing "fluent" like uniform updates
  76965. */
  76966. setFloats(name: string, value: number[]): ShaderMaterial;
  76967. /**
  76968. * Set a vec3 in the shader from a Color3.
  76969. * @param name Define the name of the uniform as defined in the shader
  76970. * @param value Define the value to give to the uniform
  76971. * @return the material itself allowing "fluent" like uniform updates
  76972. */
  76973. setColor3(name: string, value: Color3): ShaderMaterial;
  76974. /**
  76975. * Set a vec3 array in the shader from a Color3 array.
  76976. * @param name Define the name of the uniform as defined in the shader
  76977. * @param value Define the value to give to the uniform
  76978. * @return the material itself allowing "fluent" like uniform updates
  76979. */
  76980. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76981. /**
  76982. * Set a vec4 in the shader from a Color4.
  76983. * @param name Define the name of the uniform as defined in the shader
  76984. * @param value Define the value to give to the uniform
  76985. * @return the material itself allowing "fluent" like uniform updates
  76986. */
  76987. setColor4(name: string, value: Color4): ShaderMaterial;
  76988. /**
  76989. * Set a vec2 in the shader from a Vector2.
  76990. * @param name Define the name of the uniform as defined in the shader
  76991. * @param value Define the value to give to the uniform
  76992. * @return the material itself allowing "fluent" like uniform updates
  76993. */
  76994. setVector2(name: string, value: Vector2): ShaderMaterial;
  76995. /**
  76996. * Set a vec3 in the shader from a Vector3.
  76997. * @param name Define the name of the uniform as defined in the shader
  76998. * @param value Define the value to give to the uniform
  76999. * @return the material itself allowing "fluent" like uniform updates
  77000. */
  77001. setVector3(name: string, value: Vector3): ShaderMaterial;
  77002. /**
  77003. * Set a vec4 in the shader from a Vector4.
  77004. * @param name Define the name of the uniform as defined in the shader
  77005. * @param value Define the value to give to the uniform
  77006. * @return the material itself allowing "fluent" like uniform updates
  77007. */
  77008. setVector4(name: string, value: Vector4): ShaderMaterial;
  77009. /**
  77010. * Set a mat4 in the shader from a Matrix.
  77011. * @param name Define the name of the uniform as defined in the shader
  77012. * @param value Define the value to give to the uniform
  77013. * @return the material itself allowing "fluent" like uniform updates
  77014. */
  77015. setMatrix(name: string, value: Matrix): ShaderMaterial;
  77016. /**
  77017. * Set a mat3 in the shader from a Float32Array.
  77018. * @param name Define the name of the uniform as defined in the shader
  77019. * @param value Define the value to give to the uniform
  77020. * @return the material itself allowing "fluent" like uniform updates
  77021. */
  77022. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  77023. /**
  77024. * Set a mat2 in the shader from a Float32Array.
  77025. * @param name Define the name of the uniform as defined in the shader
  77026. * @param value Define the value to give to the uniform
  77027. * @return the material itself allowing "fluent" like uniform updates
  77028. */
  77029. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  77030. /**
  77031. * Set a vec2 array in the shader from a number array.
  77032. * @param name Define the name of the uniform as defined in the shader
  77033. * @param value Define the value to give to the uniform
  77034. * @return the material itself allowing "fluent" like uniform updates
  77035. */
  77036. setArray2(name: string, value: number[]): ShaderMaterial;
  77037. /**
  77038. * Set a vec3 array in the shader from a number array.
  77039. * @param name Define the name of the uniform as defined in the shader
  77040. * @param value Define the value to give to the uniform
  77041. * @return the material itself allowing "fluent" like uniform updates
  77042. */
  77043. setArray3(name: string, value: number[]): ShaderMaterial;
  77044. private _checkCache;
  77045. /**
  77046. * Specifies that the submesh is ready to be used
  77047. * @param mesh defines the mesh to check
  77048. * @param subMesh defines which submesh to check
  77049. * @param useInstances specifies that instances should be used
  77050. * @returns a boolean indicating that the submesh is ready or not
  77051. */
  77052. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77053. /**
  77054. * Checks if the material is ready to render the requested mesh
  77055. * @param mesh Define the mesh to render
  77056. * @param useInstances Define whether or not the material is used with instances
  77057. * @returns true if ready, otherwise false
  77058. */
  77059. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  77060. /**
  77061. * Binds the world matrix to the material
  77062. * @param world defines the world transformation matrix
  77063. */
  77064. bindOnlyWorldMatrix(world: Matrix): void;
  77065. /**
  77066. * Binds the material to the mesh
  77067. * @param world defines the world transformation matrix
  77068. * @param mesh defines the mesh to bind the material to
  77069. */
  77070. bind(world: Matrix, mesh?: Mesh): void;
  77071. /**
  77072. * Gets the active textures from the material
  77073. * @returns an array of textures
  77074. */
  77075. getActiveTextures(): BaseTexture[];
  77076. /**
  77077. * Specifies if the material uses a texture
  77078. * @param texture defines the texture to check against the material
  77079. * @returns a boolean specifying if the material uses the texture
  77080. */
  77081. hasTexture(texture: BaseTexture): boolean;
  77082. /**
  77083. * Makes a duplicate of the material, and gives it a new name
  77084. * @param name defines the new name for the duplicated material
  77085. * @returns the cloned material
  77086. */
  77087. clone(name: string): ShaderMaterial;
  77088. /**
  77089. * Disposes the material
  77090. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  77091. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  77092. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  77093. */
  77094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  77095. /**
  77096. * Serializes this material in a JSON representation
  77097. * @returns the serialized material object
  77098. */
  77099. serialize(): any;
  77100. /**
  77101. * Creates a shader material from parsed shader material data
  77102. * @param source defines the JSON represnetation of the material
  77103. * @param scene defines the hosting scene
  77104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  77105. * @returns a new material
  77106. */
  77107. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  77108. }
  77109. }
  77110. declare module BABYLON {
  77111. /** @hidden */
  77112. export var colorPixelShader: {
  77113. name: string;
  77114. shader: string;
  77115. };
  77116. }
  77117. declare module BABYLON {
  77118. /** @hidden */
  77119. export var colorVertexShader: {
  77120. name: string;
  77121. shader: string;
  77122. };
  77123. }
  77124. declare module BABYLON {
  77125. /**
  77126. * Line mesh
  77127. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  77128. */
  77129. export class LinesMesh extends Mesh {
  77130. /**
  77131. * If vertex color should be applied to the mesh
  77132. */
  77133. useVertexColor?: boolean | undefined;
  77134. /**
  77135. * If vertex alpha should be applied to the mesh
  77136. */
  77137. useVertexAlpha?: boolean | undefined;
  77138. /**
  77139. * Color of the line (Default: White)
  77140. */
  77141. color: Color3;
  77142. /**
  77143. * Alpha of the line (Default: 1)
  77144. */
  77145. alpha: number;
  77146. /**
  77147. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77148. * This margin is expressed in world space coordinates, so its value may vary.
  77149. * Default value is 0.1
  77150. */
  77151. intersectionThreshold: number;
  77152. private _colorShader;
  77153. /**
  77154. * Creates a new LinesMesh
  77155. * @param name defines the name
  77156. * @param scene defines the hosting scene
  77157. * @param parent defines the parent mesh if any
  77158. * @param source defines the optional source LinesMesh used to clone data from
  77159. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77160. * When false, achieved by calling a clone(), also passing False.
  77161. * This will make creation of children, recursive.
  77162. * @param useVertexColor defines if this LinesMesh supports vertex color
  77163. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  77164. */
  77165. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  77166. /**
  77167. * If vertex color should be applied to the mesh
  77168. */
  77169. useVertexColor?: boolean | undefined,
  77170. /**
  77171. * If vertex alpha should be applied to the mesh
  77172. */
  77173. useVertexAlpha?: boolean | undefined);
  77174. private _addClipPlaneDefine;
  77175. private _removeClipPlaneDefine;
  77176. isReady(): boolean;
  77177. /**
  77178. * Returns the string "LineMesh"
  77179. */
  77180. getClassName(): string;
  77181. /**
  77182. * @hidden
  77183. */
  77184. /**
  77185. * @hidden
  77186. */
  77187. material: Material;
  77188. /**
  77189. * @hidden
  77190. */
  77191. readonly checkCollisions: boolean;
  77192. /** @hidden */
  77193. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  77194. /** @hidden */
  77195. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  77196. /**
  77197. * Disposes of the line mesh
  77198. * @param doNotRecurse If children should be disposed
  77199. */
  77200. dispose(doNotRecurse?: boolean): void;
  77201. /**
  77202. * Returns a new LineMesh object cloned from the current one.
  77203. */
  77204. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  77205. /**
  77206. * Creates a new InstancedLinesMesh object from the mesh model.
  77207. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77208. * @param name defines the name of the new instance
  77209. * @returns a new InstancedLinesMesh
  77210. */
  77211. createInstance(name: string): InstancedLinesMesh;
  77212. }
  77213. /**
  77214. * Creates an instance based on a source LinesMesh
  77215. */
  77216. export class InstancedLinesMesh extends InstancedMesh {
  77217. /**
  77218. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  77219. * This margin is expressed in world space coordinates, so its value may vary.
  77220. * Initilized with the intersectionThreshold value of the source LinesMesh
  77221. */
  77222. intersectionThreshold: number;
  77223. constructor(name: string, source: LinesMesh);
  77224. /**
  77225. * Returns the string "InstancedLinesMesh".
  77226. */
  77227. getClassName(): string;
  77228. }
  77229. }
  77230. declare module BABYLON {
  77231. /** @hidden */
  77232. export var linePixelShader: {
  77233. name: string;
  77234. shader: string;
  77235. };
  77236. }
  77237. declare module BABYLON {
  77238. /** @hidden */
  77239. export var lineVertexShader: {
  77240. name: string;
  77241. shader: string;
  77242. };
  77243. }
  77244. declare module BABYLON {
  77245. interface AbstractMesh {
  77246. /**
  77247. * Disables the mesh edge rendering mode
  77248. * @returns the currentAbstractMesh
  77249. */
  77250. disableEdgesRendering(): AbstractMesh;
  77251. /**
  77252. * Enables the edge rendering mode on the mesh.
  77253. * This mode makes the mesh edges visible
  77254. * @param epsilon defines the maximal distance between two angles to detect a face
  77255. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77256. * @returns the currentAbstractMesh
  77257. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77258. */
  77259. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77260. /**
  77261. * Gets the edgesRenderer associated with the mesh
  77262. */
  77263. edgesRenderer: Nullable<EdgesRenderer>;
  77264. }
  77265. interface LinesMesh {
  77266. /**
  77267. * Enables the edge rendering mode on the mesh.
  77268. * This mode makes the mesh edges visible
  77269. * @param epsilon defines the maximal distance between two angles to detect a face
  77270. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77271. * @returns the currentAbstractMesh
  77272. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77273. */
  77274. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  77275. }
  77276. interface InstancedLinesMesh {
  77277. /**
  77278. * Enables the edge rendering mode on the mesh.
  77279. * This mode makes the mesh edges visible
  77280. * @param epsilon defines the maximal distance between two angles to detect a face
  77281. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  77282. * @returns the current InstancedLinesMesh
  77283. * @see https://www.babylonjs-playground.com/#19O9TU#0
  77284. */
  77285. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  77286. }
  77287. /**
  77288. * Defines the minimum contract an Edges renderer should follow.
  77289. */
  77290. export interface IEdgesRenderer extends IDisposable {
  77291. /**
  77292. * Gets or sets a boolean indicating if the edgesRenderer is active
  77293. */
  77294. isEnabled: boolean;
  77295. /**
  77296. * Renders the edges of the attached mesh,
  77297. */
  77298. render(): void;
  77299. /**
  77300. * Checks wether or not the edges renderer is ready to render.
  77301. * @return true if ready, otherwise false.
  77302. */
  77303. isReady(): boolean;
  77304. }
  77305. /**
  77306. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  77307. */
  77308. export class EdgesRenderer implements IEdgesRenderer {
  77309. /**
  77310. * Define the size of the edges with an orthographic camera
  77311. */
  77312. edgesWidthScalerForOrthographic: number;
  77313. /**
  77314. * Define the size of the edges with a perspective camera
  77315. */
  77316. edgesWidthScalerForPerspective: number;
  77317. protected _source: AbstractMesh;
  77318. protected _linesPositions: number[];
  77319. protected _linesNormals: number[];
  77320. protected _linesIndices: number[];
  77321. protected _epsilon: number;
  77322. protected _indicesCount: number;
  77323. protected _lineShader: ShaderMaterial;
  77324. protected _ib: DataBuffer;
  77325. protected _buffers: {
  77326. [key: string]: Nullable<VertexBuffer>;
  77327. };
  77328. protected _checkVerticesInsteadOfIndices: boolean;
  77329. private _meshRebuildObserver;
  77330. private _meshDisposeObserver;
  77331. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  77332. isEnabled: boolean;
  77333. /**
  77334. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  77335. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  77336. * @param source Mesh used to create edges
  77337. * @param epsilon sum of angles in adjacency to check for edge
  77338. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  77339. * @param generateEdgesLines - should generate Lines or only prepare resources.
  77340. */
  77341. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  77342. protected _prepareRessources(): void;
  77343. /** @hidden */
  77344. _rebuild(): void;
  77345. /**
  77346. * Releases the required resources for the edges renderer
  77347. */
  77348. dispose(): void;
  77349. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  77350. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  77351. /**
  77352. * Checks if the pair of p0 and p1 is en edge
  77353. * @param faceIndex
  77354. * @param edge
  77355. * @param faceNormals
  77356. * @param p0
  77357. * @param p1
  77358. * @private
  77359. */
  77360. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  77361. /**
  77362. * push line into the position, normal and index buffer
  77363. * @protected
  77364. */
  77365. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  77366. /**
  77367. * Generates lines edges from adjacencjes
  77368. * @private
  77369. */
  77370. _generateEdgesLines(): void;
  77371. /**
  77372. * Checks wether or not the edges renderer is ready to render.
  77373. * @return true if ready, otherwise false.
  77374. */
  77375. isReady(): boolean;
  77376. /**
  77377. * Renders the edges of the attached mesh,
  77378. */
  77379. render(): void;
  77380. }
  77381. /**
  77382. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  77383. */
  77384. export class LineEdgesRenderer extends EdgesRenderer {
  77385. /**
  77386. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  77387. * @param source LineMesh used to generate edges
  77388. * @param epsilon not important (specified angle for edge detection)
  77389. * @param checkVerticesInsteadOfIndices not important for LineMesh
  77390. */
  77391. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  77392. /**
  77393. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  77394. */
  77395. _generateEdgesLines(): void;
  77396. }
  77397. }
  77398. declare module BABYLON {
  77399. /**
  77400. * This represents the object necessary to create a rendering group.
  77401. * This is exclusively used and created by the rendering manager.
  77402. * To modify the behavior, you use the available helpers in your scene or meshes.
  77403. * @hidden
  77404. */
  77405. export class RenderingGroup {
  77406. index: number;
  77407. private _scene;
  77408. private _opaqueSubMeshes;
  77409. private _transparentSubMeshes;
  77410. private _alphaTestSubMeshes;
  77411. private _depthOnlySubMeshes;
  77412. private _particleSystems;
  77413. private _spriteManagers;
  77414. private _opaqueSortCompareFn;
  77415. private _alphaTestSortCompareFn;
  77416. private _transparentSortCompareFn;
  77417. private _renderOpaque;
  77418. private _renderAlphaTest;
  77419. private _renderTransparent;
  77420. /** @hidden */
  77421. _edgesRenderers: SmartArray<IEdgesRenderer>;
  77422. onBeforeTransparentRendering: () => void;
  77423. /**
  77424. * Set the opaque sort comparison function.
  77425. * If null the sub meshes will be render in the order they were created
  77426. */
  77427. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77428. /**
  77429. * Set the alpha test sort comparison function.
  77430. * If null the sub meshes will be render in the order they were created
  77431. */
  77432. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77433. /**
  77434. * Set the transparent sort comparison function.
  77435. * If null the sub meshes will be render in the order they were created
  77436. */
  77437. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  77438. /**
  77439. * Creates a new rendering group.
  77440. * @param index The rendering group index
  77441. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  77442. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  77443. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  77444. */
  77445. 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>);
  77446. /**
  77447. * Render all the sub meshes contained in the group.
  77448. * @param customRenderFunction Used to override the default render behaviour of the group.
  77449. * @returns true if rendered some submeshes.
  77450. */
  77451. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  77452. /**
  77453. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  77454. * @param subMeshes The submeshes to render
  77455. */
  77456. private renderOpaqueSorted;
  77457. /**
  77458. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  77459. * @param subMeshes The submeshes to render
  77460. */
  77461. private renderAlphaTestSorted;
  77462. /**
  77463. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  77464. * @param subMeshes The submeshes to render
  77465. */
  77466. private renderTransparentSorted;
  77467. /**
  77468. * Renders the submeshes in a specified order.
  77469. * @param subMeshes The submeshes to sort before render
  77470. * @param sortCompareFn The comparison function use to sort
  77471. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  77472. * @param transparent Specifies to activate blending if true
  77473. */
  77474. private static renderSorted;
  77475. /**
  77476. * Renders the submeshes in the order they were dispatched (no sort applied).
  77477. * @param subMeshes The submeshes to render
  77478. */
  77479. private static renderUnsorted;
  77480. /**
  77481. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77482. * are rendered back to front if in the same alpha index.
  77483. *
  77484. * @param a The first submesh
  77485. * @param b The second submesh
  77486. * @returns The result of the comparison
  77487. */
  77488. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  77489. /**
  77490. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77491. * are rendered back to front.
  77492. *
  77493. * @param a The first submesh
  77494. * @param b The second submesh
  77495. * @returns The result of the comparison
  77496. */
  77497. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  77498. /**
  77499. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  77500. * are rendered front to back (prevent overdraw).
  77501. *
  77502. * @param a The first submesh
  77503. * @param b The second submesh
  77504. * @returns The result of the comparison
  77505. */
  77506. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  77507. /**
  77508. * Resets the different lists of submeshes to prepare a new frame.
  77509. */
  77510. prepare(): void;
  77511. dispose(): void;
  77512. /**
  77513. * Inserts the submesh in its correct queue depending on its material.
  77514. * @param subMesh The submesh to dispatch
  77515. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77516. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77517. */
  77518. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77519. dispatchSprites(spriteManager: ISpriteManager): void;
  77520. dispatchParticles(particleSystem: IParticleSystem): void;
  77521. private _renderParticles;
  77522. private _renderSprites;
  77523. }
  77524. }
  77525. declare module BABYLON {
  77526. /**
  77527. * Interface describing the different options available in the rendering manager
  77528. * regarding Auto Clear between groups.
  77529. */
  77530. export interface IRenderingManagerAutoClearSetup {
  77531. /**
  77532. * Defines whether or not autoclear is enable.
  77533. */
  77534. autoClear: boolean;
  77535. /**
  77536. * Defines whether or not to autoclear the depth buffer.
  77537. */
  77538. depth: boolean;
  77539. /**
  77540. * Defines whether or not to autoclear the stencil buffer.
  77541. */
  77542. stencil: boolean;
  77543. }
  77544. /**
  77545. * This class is used by the onRenderingGroupObservable
  77546. */
  77547. export class RenderingGroupInfo {
  77548. /**
  77549. * The Scene that being rendered
  77550. */
  77551. scene: Scene;
  77552. /**
  77553. * The camera currently used for the rendering pass
  77554. */
  77555. camera: Nullable<Camera>;
  77556. /**
  77557. * The ID of the renderingGroup being processed
  77558. */
  77559. renderingGroupId: number;
  77560. }
  77561. /**
  77562. * This is the manager responsible of all the rendering for meshes sprites and particles.
  77563. * It is enable to manage the different groups as well as the different necessary sort functions.
  77564. * This should not be used directly aside of the few static configurations
  77565. */
  77566. export class RenderingManager {
  77567. /**
  77568. * The max id used for rendering groups (not included)
  77569. */
  77570. static MAX_RENDERINGGROUPS: number;
  77571. /**
  77572. * The min id used for rendering groups (included)
  77573. */
  77574. static MIN_RENDERINGGROUPS: number;
  77575. /**
  77576. * Used to globally prevent autoclearing scenes.
  77577. */
  77578. static AUTOCLEAR: boolean;
  77579. /**
  77580. * @hidden
  77581. */
  77582. _useSceneAutoClearSetup: boolean;
  77583. private _scene;
  77584. private _renderingGroups;
  77585. private _depthStencilBufferAlreadyCleaned;
  77586. private _autoClearDepthStencil;
  77587. private _customOpaqueSortCompareFn;
  77588. private _customAlphaTestSortCompareFn;
  77589. private _customTransparentSortCompareFn;
  77590. private _renderingGroupInfo;
  77591. /**
  77592. * Instantiates a new rendering group for a particular scene
  77593. * @param scene Defines the scene the groups belongs to
  77594. */
  77595. constructor(scene: Scene);
  77596. private _clearDepthStencilBuffer;
  77597. /**
  77598. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  77599. * @hidden
  77600. */
  77601. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  77602. /**
  77603. * Resets the different information of the group to prepare a new frame
  77604. * @hidden
  77605. */
  77606. reset(): void;
  77607. /**
  77608. * Dispose and release the group and its associated resources.
  77609. * @hidden
  77610. */
  77611. dispose(): void;
  77612. /**
  77613. * Clear the info related to rendering groups preventing retention points during dispose.
  77614. */
  77615. freeRenderingGroups(): void;
  77616. private _prepareRenderingGroup;
  77617. /**
  77618. * Add a sprite manager to the rendering manager in order to render it this frame.
  77619. * @param spriteManager Define the sprite manager to render
  77620. */
  77621. dispatchSprites(spriteManager: ISpriteManager): void;
  77622. /**
  77623. * Add a particle system to the rendering manager in order to render it this frame.
  77624. * @param particleSystem Define the particle system to render
  77625. */
  77626. dispatchParticles(particleSystem: IParticleSystem): void;
  77627. /**
  77628. * Add a submesh to the manager in order to render it this frame
  77629. * @param subMesh The submesh to dispatch
  77630. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  77631. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  77632. */
  77633. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  77634. /**
  77635. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77636. * This allowed control for front to back rendering or reversly depending of the special needs.
  77637. *
  77638. * @param renderingGroupId The rendering group id corresponding to its index
  77639. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77640. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77641. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77642. */
  77643. 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;
  77644. /**
  77645. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77646. *
  77647. * @param renderingGroupId The rendering group id corresponding to its index
  77648. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77649. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77650. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77651. */
  77652. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77653. /**
  77654. * Gets the current auto clear configuration for one rendering group of the rendering
  77655. * manager.
  77656. * @param index the rendering group index to get the information for
  77657. * @returns The auto clear setup for the requested rendering group
  77658. */
  77659. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77660. }
  77661. }
  77662. declare module BABYLON {
  77663. /**
  77664. * This Helps creating a texture that will be created from a camera in your scene.
  77665. * It is basically a dynamic texture that could be used to create special effects for instance.
  77666. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77667. */
  77668. export class RenderTargetTexture extends Texture {
  77669. isCube: boolean;
  77670. /**
  77671. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77672. */
  77673. static readonly REFRESHRATE_RENDER_ONCE: number;
  77674. /**
  77675. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77676. */
  77677. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77678. /**
  77679. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77680. * the central point of your effect and can save a lot of performances.
  77681. */
  77682. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77683. /**
  77684. * Use this predicate to dynamically define the list of mesh you want to render.
  77685. * If set, the renderList property will be overwritten.
  77686. */
  77687. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77688. private _renderList;
  77689. /**
  77690. * Use this list to define the list of mesh you want to render.
  77691. */
  77692. renderList: Nullable<Array<AbstractMesh>>;
  77693. private _hookArray;
  77694. /**
  77695. * Define if particles should be rendered in your texture.
  77696. */
  77697. renderParticles: boolean;
  77698. /**
  77699. * Define if sprites should be rendered in your texture.
  77700. */
  77701. renderSprites: boolean;
  77702. /**
  77703. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77704. */
  77705. coordinatesMode: number;
  77706. /**
  77707. * Define the camera used to render the texture.
  77708. */
  77709. activeCamera: Nullable<Camera>;
  77710. /**
  77711. * Override the render function of the texture with your own one.
  77712. */
  77713. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77714. /**
  77715. * Define if camera post processes should be use while rendering the texture.
  77716. */
  77717. useCameraPostProcesses: boolean;
  77718. /**
  77719. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77720. */
  77721. ignoreCameraViewport: boolean;
  77722. private _postProcessManager;
  77723. private _postProcesses;
  77724. private _resizeObserver;
  77725. /**
  77726. * An event triggered when the texture is unbind.
  77727. */
  77728. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77729. /**
  77730. * An event triggered when the texture is unbind.
  77731. */
  77732. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77733. private _onAfterUnbindObserver;
  77734. /**
  77735. * Set a after unbind callback in the texture.
  77736. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77737. */
  77738. onAfterUnbind: () => void;
  77739. /**
  77740. * An event triggered before rendering the texture
  77741. */
  77742. onBeforeRenderObservable: Observable<number>;
  77743. private _onBeforeRenderObserver;
  77744. /**
  77745. * Set a before render callback in the texture.
  77746. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77747. */
  77748. onBeforeRender: (faceIndex: number) => void;
  77749. /**
  77750. * An event triggered after rendering the texture
  77751. */
  77752. onAfterRenderObservable: Observable<number>;
  77753. private _onAfterRenderObserver;
  77754. /**
  77755. * Set a after render callback in the texture.
  77756. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77757. */
  77758. onAfterRender: (faceIndex: number) => void;
  77759. /**
  77760. * An event triggered after the texture clear
  77761. */
  77762. onClearObservable: Observable<Engine>;
  77763. private _onClearObserver;
  77764. /**
  77765. * Set a clear callback in the texture.
  77766. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77767. */
  77768. onClear: (Engine: Engine) => void;
  77769. /**
  77770. * Define the clear color of the Render Target if it should be different from the scene.
  77771. */
  77772. clearColor: Color4;
  77773. protected _size: number | {
  77774. width: number;
  77775. height: number;
  77776. };
  77777. protected _initialSizeParameter: number | {
  77778. width: number;
  77779. height: number;
  77780. } | {
  77781. ratio: number;
  77782. };
  77783. protected _sizeRatio: Nullable<number>;
  77784. /** @hidden */
  77785. _generateMipMaps: boolean;
  77786. protected _renderingManager: RenderingManager;
  77787. /** @hidden */
  77788. _waitingRenderList: string[];
  77789. protected _doNotChangeAspectRatio: boolean;
  77790. protected _currentRefreshId: number;
  77791. protected _refreshRate: number;
  77792. protected _textureMatrix: Matrix;
  77793. protected _samples: number;
  77794. protected _renderTargetOptions: RenderTargetCreationOptions;
  77795. /**
  77796. * Gets render target creation options that were used.
  77797. */
  77798. readonly renderTargetOptions: RenderTargetCreationOptions;
  77799. protected _engine: Engine;
  77800. protected _onRatioRescale(): void;
  77801. /**
  77802. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77803. * It must define where the camera used to render the texture is set
  77804. */
  77805. boundingBoxPosition: Vector3;
  77806. private _boundingBoxSize;
  77807. /**
  77808. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77809. * When defined, the cubemap will switch to local mode
  77810. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77811. * @example https://www.babylonjs-playground.com/#RNASML
  77812. */
  77813. boundingBoxSize: Vector3;
  77814. /**
  77815. * In case the RTT has been created with a depth texture, get the associated
  77816. * depth texture.
  77817. * Otherwise, return null.
  77818. */
  77819. depthStencilTexture: Nullable<InternalTexture>;
  77820. /**
  77821. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77822. * or used a shadow, depth texture...
  77823. * @param name The friendly name of the texture
  77824. * @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)
  77825. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77826. * @param generateMipMaps True if mip maps need to be generated after render.
  77827. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77828. * @param type The type of the buffer in the RTT (int, half float, float...)
  77829. * @param isCube True if a cube texture needs to be created
  77830. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77831. * @param generateDepthBuffer True to generate a depth buffer
  77832. * @param generateStencilBuffer True to generate a stencil buffer
  77833. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77834. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77835. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77836. */
  77837. constructor(name: string, size: number | {
  77838. width: number;
  77839. height: number;
  77840. } | {
  77841. ratio: number;
  77842. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77843. /**
  77844. * Creates a depth stencil texture.
  77845. * This is only available in WebGL 2 or with the depth texture extension available.
  77846. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77847. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77848. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77849. */
  77850. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77851. private _processSizeParameter;
  77852. /**
  77853. * Define the number of samples to use in case of MSAA.
  77854. * It defaults to one meaning no MSAA has been enabled.
  77855. */
  77856. samples: number;
  77857. /**
  77858. * Resets the refresh counter of the texture and start bak from scratch.
  77859. * Could be useful to regenerate the texture if it is setup to render only once.
  77860. */
  77861. resetRefreshCounter(): void;
  77862. /**
  77863. * Define the refresh rate of the texture or the rendering frequency.
  77864. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77865. */
  77866. refreshRate: number;
  77867. /**
  77868. * Adds a post process to the render target rendering passes.
  77869. * @param postProcess define the post process to add
  77870. */
  77871. addPostProcess(postProcess: PostProcess): void;
  77872. /**
  77873. * Clear all the post processes attached to the render target
  77874. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77875. */
  77876. clearPostProcesses(dispose?: boolean): void;
  77877. /**
  77878. * Remove one of the post process from the list of attached post processes to the texture
  77879. * @param postProcess define the post process to remove from the list
  77880. */
  77881. removePostProcess(postProcess: PostProcess): void;
  77882. /** @hidden */
  77883. _shouldRender(): boolean;
  77884. /**
  77885. * Gets the actual render size of the texture.
  77886. * @returns the width of the render size
  77887. */
  77888. getRenderSize(): number;
  77889. /**
  77890. * Gets the actual render width of the texture.
  77891. * @returns the width of the render size
  77892. */
  77893. getRenderWidth(): number;
  77894. /**
  77895. * Gets the actual render height of the texture.
  77896. * @returns the height of the render size
  77897. */
  77898. getRenderHeight(): number;
  77899. /**
  77900. * Get if the texture can be rescaled or not.
  77901. */
  77902. readonly canRescale: boolean;
  77903. /**
  77904. * Resize the texture using a ratio.
  77905. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77906. */
  77907. scale(ratio: number): void;
  77908. /**
  77909. * Get the texture reflection matrix used to rotate/transform the reflection.
  77910. * @returns the reflection matrix
  77911. */
  77912. getReflectionTextureMatrix(): Matrix;
  77913. /**
  77914. * Resize the texture to a new desired size.
  77915. * Be carrefull as it will recreate all the data in the new texture.
  77916. * @param size Define the new size. It can be:
  77917. * - a number for squared texture,
  77918. * - an object containing { width: number, height: number }
  77919. * - or an object containing a ratio { ratio: number }
  77920. */
  77921. resize(size: number | {
  77922. width: number;
  77923. height: number;
  77924. } | {
  77925. ratio: number;
  77926. }): void;
  77927. /**
  77928. * Renders all the objects from the render list into the texture.
  77929. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77930. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77931. */
  77932. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77933. private _bestReflectionRenderTargetDimension;
  77934. /**
  77935. * @hidden
  77936. * @param faceIndex face index to bind to if this is a cubetexture
  77937. */
  77938. _bindFrameBuffer(faceIndex?: number): void;
  77939. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77940. private renderToTarget;
  77941. /**
  77942. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77943. * This allowed control for front to back rendering or reversly depending of the special needs.
  77944. *
  77945. * @param renderingGroupId The rendering group id corresponding to its index
  77946. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77947. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77948. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77949. */
  77950. 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;
  77951. /**
  77952. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77953. *
  77954. * @param renderingGroupId The rendering group id corresponding to its index
  77955. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77956. */
  77957. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77958. /**
  77959. * Clones the texture.
  77960. * @returns the cloned texture
  77961. */
  77962. clone(): RenderTargetTexture;
  77963. /**
  77964. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77965. * @returns The JSON representation of the texture
  77966. */
  77967. serialize(): any;
  77968. /**
  77969. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77970. */
  77971. disposeFramebufferObjects(): void;
  77972. /**
  77973. * Dispose the texture and release its associated resources.
  77974. */
  77975. dispose(): void;
  77976. /** @hidden */
  77977. _rebuild(): void;
  77978. /**
  77979. * Clear the info related to rendering groups preventing retention point in material dispose.
  77980. */
  77981. freeRenderingGroups(): void;
  77982. /**
  77983. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77984. * @returns the view count
  77985. */
  77986. getViewCount(): number;
  77987. }
  77988. }
  77989. declare module BABYLON {
  77990. /**
  77991. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77992. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77993. * You can then easily use it as a reflectionTexture on a flat surface.
  77994. * In case the surface is not a plane, please consider relying on reflection probes.
  77995. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77996. */
  77997. export class MirrorTexture extends RenderTargetTexture {
  77998. private scene;
  77999. /**
  78000. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78001. * 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.
  78002. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78003. */
  78004. mirrorPlane: Plane;
  78005. /**
  78006. * Define the blur ratio used to blur the reflection if needed.
  78007. */
  78008. blurRatio: number;
  78009. /**
  78010. * Define the adaptive blur kernel used to blur the reflection if needed.
  78011. * This will autocompute the closest best match for the `blurKernel`
  78012. */
  78013. adaptiveBlurKernel: number;
  78014. /**
  78015. * Define the blur kernel used to blur the reflection if needed.
  78016. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78017. */
  78018. blurKernel: number;
  78019. /**
  78020. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78022. */
  78023. blurKernelX: number;
  78024. /**
  78025. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78027. */
  78028. blurKernelY: number;
  78029. private _autoComputeBlurKernel;
  78030. protected _onRatioRescale(): void;
  78031. private _updateGammaSpace;
  78032. private _imageProcessingConfigChangeObserver;
  78033. private _transformMatrix;
  78034. private _mirrorMatrix;
  78035. private _savedViewMatrix;
  78036. private _blurX;
  78037. private _blurY;
  78038. private _adaptiveBlurKernel;
  78039. private _blurKernelX;
  78040. private _blurKernelY;
  78041. private _blurRatio;
  78042. /**
  78043. * Instantiates a Mirror Texture.
  78044. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78045. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78046. * You can then easily use it as a reflectionTexture on a flat surface.
  78047. * In case the surface is not a plane, please consider relying on reflection probes.
  78048. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78049. * @param name
  78050. * @param size
  78051. * @param scene
  78052. * @param generateMipMaps
  78053. * @param type
  78054. * @param samplingMode
  78055. * @param generateDepthBuffer
  78056. */
  78057. constructor(name: string, size: number | {
  78058. width: number;
  78059. height: number;
  78060. } | {
  78061. ratio: number;
  78062. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78063. private _preparePostProcesses;
  78064. /**
  78065. * Clone the mirror texture.
  78066. * @returns the cloned texture
  78067. */
  78068. clone(): MirrorTexture;
  78069. /**
  78070. * Serialize the texture to a JSON representation you could use in Parse later on
  78071. * @returns the serialized JSON representation
  78072. */
  78073. serialize(): any;
  78074. /**
  78075. * Dispose the texture and release its associated resources.
  78076. */
  78077. dispose(): void;
  78078. }
  78079. }
  78080. declare module BABYLON {
  78081. /**
  78082. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78083. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78084. */
  78085. export class Texture extends BaseTexture {
  78086. /** @hidden */
  78087. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78088. /** @hidden */
  78089. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78090. /** @hidden */
  78091. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78092. /** nearest is mag = nearest and min = nearest and mip = linear */
  78093. static readonly NEAREST_SAMPLINGMODE: number;
  78094. /** nearest is mag = nearest and min = nearest and mip = linear */
  78095. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78096. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78097. static readonly BILINEAR_SAMPLINGMODE: number;
  78098. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78099. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78100. /** Trilinear is mag = linear and min = linear and mip = linear */
  78101. static readonly TRILINEAR_SAMPLINGMODE: number;
  78102. /** Trilinear is mag = linear and min = linear and mip = linear */
  78103. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78104. /** mag = nearest and min = nearest and mip = nearest */
  78105. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78106. /** mag = nearest and min = linear and mip = nearest */
  78107. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78108. /** mag = nearest and min = linear and mip = linear */
  78109. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78110. /** mag = nearest and min = linear and mip = none */
  78111. static readonly NEAREST_LINEAR: number;
  78112. /** mag = nearest and min = nearest and mip = none */
  78113. static readonly NEAREST_NEAREST: number;
  78114. /** mag = linear and min = nearest and mip = nearest */
  78115. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78116. /** mag = linear and min = nearest and mip = linear */
  78117. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78118. /** mag = linear and min = linear and mip = none */
  78119. static readonly LINEAR_LINEAR: number;
  78120. /** mag = linear and min = nearest and mip = none */
  78121. static readonly LINEAR_NEAREST: number;
  78122. /** Explicit coordinates mode */
  78123. static readonly EXPLICIT_MODE: number;
  78124. /** Spherical coordinates mode */
  78125. static readonly SPHERICAL_MODE: number;
  78126. /** Planar coordinates mode */
  78127. static readonly PLANAR_MODE: number;
  78128. /** Cubic coordinates mode */
  78129. static readonly CUBIC_MODE: number;
  78130. /** Projection coordinates mode */
  78131. static readonly PROJECTION_MODE: number;
  78132. /** Inverse Cubic coordinates mode */
  78133. static readonly SKYBOX_MODE: number;
  78134. /** Inverse Cubic coordinates mode */
  78135. static readonly INVCUBIC_MODE: number;
  78136. /** Equirectangular coordinates mode */
  78137. static readonly EQUIRECTANGULAR_MODE: number;
  78138. /** Equirectangular Fixed coordinates mode */
  78139. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78140. /** Equirectangular Fixed Mirrored coordinates mode */
  78141. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78142. /** Texture is not repeating outside of 0..1 UVs */
  78143. static readonly CLAMP_ADDRESSMODE: number;
  78144. /** Texture is repeating outside of 0..1 UVs */
  78145. static readonly WRAP_ADDRESSMODE: number;
  78146. /** Texture is repeating and mirrored */
  78147. static readonly MIRROR_ADDRESSMODE: number;
  78148. /**
  78149. * 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
  78150. */
  78151. static UseSerializedUrlIfAny: boolean;
  78152. /**
  78153. * Define the url of the texture.
  78154. */
  78155. url: Nullable<string>;
  78156. /**
  78157. * Define an offset on the texture to offset the u coordinates of the UVs
  78158. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78159. */
  78160. uOffset: number;
  78161. /**
  78162. * Define an offset on the texture to offset the v coordinates of the UVs
  78163. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78164. */
  78165. vOffset: number;
  78166. /**
  78167. * Define an offset on the texture to scale the u coordinates of the UVs
  78168. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78169. */
  78170. uScale: number;
  78171. /**
  78172. * Define an offset on the texture to scale the v coordinates of the UVs
  78173. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78174. */
  78175. vScale: number;
  78176. /**
  78177. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78178. * @see http://doc.babylonjs.com/how_to/more_materials
  78179. */
  78180. uAng: number;
  78181. /**
  78182. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78183. * @see http://doc.babylonjs.com/how_to/more_materials
  78184. */
  78185. vAng: number;
  78186. /**
  78187. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78188. * @see http://doc.babylonjs.com/how_to/more_materials
  78189. */
  78190. wAng: number;
  78191. /**
  78192. * Defines the center of rotation (U)
  78193. */
  78194. uRotationCenter: number;
  78195. /**
  78196. * Defines the center of rotation (V)
  78197. */
  78198. vRotationCenter: number;
  78199. /**
  78200. * Defines the center of rotation (W)
  78201. */
  78202. wRotationCenter: number;
  78203. /**
  78204. * Are mip maps generated for this texture or not.
  78205. */
  78206. readonly noMipmap: boolean;
  78207. /**
  78208. * List of inspectable custom properties (used by the Inspector)
  78209. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78210. */
  78211. inspectableCustomProperties: Nullable<IInspectable[]>;
  78212. private _noMipmap;
  78213. /** @hidden */
  78214. _invertY: boolean;
  78215. private _rowGenerationMatrix;
  78216. private _cachedTextureMatrix;
  78217. private _projectionModeMatrix;
  78218. private _t0;
  78219. private _t1;
  78220. private _t2;
  78221. private _cachedUOffset;
  78222. private _cachedVOffset;
  78223. private _cachedUScale;
  78224. private _cachedVScale;
  78225. private _cachedUAng;
  78226. private _cachedVAng;
  78227. private _cachedWAng;
  78228. private _cachedProjectionMatrixId;
  78229. private _cachedCoordinatesMode;
  78230. /** @hidden */
  78231. protected _initialSamplingMode: number;
  78232. /** @hidden */
  78233. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78234. private _deleteBuffer;
  78235. protected _format: Nullable<number>;
  78236. private _delayedOnLoad;
  78237. private _delayedOnError;
  78238. /**
  78239. * Observable triggered once the texture has been loaded.
  78240. */
  78241. onLoadObservable: Observable<Texture>;
  78242. protected _isBlocking: boolean;
  78243. /**
  78244. * Is the texture preventing material to render while loading.
  78245. * If false, a default texture will be used instead of the loading one during the preparation step.
  78246. */
  78247. isBlocking: boolean;
  78248. /**
  78249. * Get the current sampling mode associated with the texture.
  78250. */
  78251. readonly samplingMode: number;
  78252. /**
  78253. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78254. */
  78255. readonly invertY: boolean;
  78256. /**
  78257. * Instantiates a new texture.
  78258. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78259. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78260. * @param url define the url of the picture to load as a texture
  78261. * @param scene define the scene the texture will belong to
  78262. * @param noMipmap define if the texture will require mip maps or not
  78263. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78264. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78265. * @param onLoad define a callback triggered when the texture has been loaded
  78266. * @param onError define a callback triggered when an error occurred during the loading session
  78267. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78268. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78269. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78270. */
  78271. 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);
  78272. /**
  78273. * Update the url (and optional buffer) of this texture if url was null during construction.
  78274. * @param url the url of the texture
  78275. * @param buffer the buffer of the texture (defaults to null)
  78276. * @param onLoad callback called when the texture is loaded (defaults to null)
  78277. */
  78278. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78279. /**
  78280. * Finish the loading sequence of a texture flagged as delayed load.
  78281. * @hidden
  78282. */
  78283. delayLoad(): void;
  78284. private _prepareRowForTextureGeneration;
  78285. /**
  78286. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78287. * @returns the transform matrix of the texture.
  78288. */
  78289. getTextureMatrix(): Matrix;
  78290. /**
  78291. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78292. * @returns The reflection texture transform
  78293. */
  78294. getReflectionTextureMatrix(): Matrix;
  78295. /**
  78296. * Clones the texture.
  78297. * @returns the cloned texture
  78298. */
  78299. clone(): Texture;
  78300. /**
  78301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78302. * @returns The JSON representation of the texture
  78303. */
  78304. serialize(): any;
  78305. /**
  78306. * Get the current class name of the texture useful for serialization or dynamic coding.
  78307. * @returns "Texture"
  78308. */
  78309. getClassName(): string;
  78310. /**
  78311. * Dispose the texture and release its associated resources.
  78312. */
  78313. dispose(): void;
  78314. /**
  78315. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78316. * @param parsedTexture Define the JSON representation of the texture
  78317. * @param scene Define the scene the parsed texture should be instantiated in
  78318. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78319. * @returns The parsed texture if successful
  78320. */
  78321. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78322. /**
  78323. * Creates a texture from its base 64 representation.
  78324. * @param data Define the base64 payload without the data: prefix
  78325. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78326. * @param scene Define the scene the texture should belong to
  78327. * @param noMipmap Forces the texture to not create mip map information if true
  78328. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78329. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78330. * @param onLoad define a callback triggered when the texture has been loaded
  78331. * @param onError define a callback triggered when an error occurred during the loading session
  78332. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78333. * @returns the created texture
  78334. */
  78335. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78336. /**
  78337. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78338. * @param data Define the base64 payload without the data: prefix
  78339. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78340. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78341. * @param scene Define the scene the texture should belong to
  78342. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78343. * @param noMipmap Forces the texture to not create mip map information if true
  78344. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78345. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78346. * @param onLoad define a callback triggered when the texture has been loaded
  78347. * @param onError define a callback triggered when an error occurred during the loading session
  78348. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78349. * @returns the created texture
  78350. */
  78351. 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;
  78352. }
  78353. }
  78354. declare module BABYLON {
  78355. interface Engine {
  78356. /**
  78357. * Creates a raw texture
  78358. * @param data defines the data to store in the texture
  78359. * @param width defines the width of the texture
  78360. * @param height defines the height of the texture
  78361. * @param format defines the format of the data
  78362. * @param generateMipMaps defines if the engine should generate the mip levels
  78363. * @param invertY defines if data must be stored with Y axis inverted
  78364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78365. * @param compression defines the compression used (null by default)
  78366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78367. * @returns the raw texture inside an InternalTexture
  78368. */
  78369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78370. /**
  78371. * Update a raw texture
  78372. * @param texture defines the texture to update
  78373. * @param data defines the data to store in the texture
  78374. * @param format defines the format of the data
  78375. * @param invertY defines if data must be stored with Y axis inverted
  78376. */
  78377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78378. /**
  78379. * Update a raw texture
  78380. * @param texture defines the texture to update
  78381. * @param data defines the data to store in the texture
  78382. * @param format defines the format of the data
  78383. * @param invertY defines if data must be stored with Y axis inverted
  78384. * @param compression defines the compression used (null by default)
  78385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78386. */
  78387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78388. /**
  78389. * Creates a new raw cube texture
  78390. * @param data defines the array of data to use to create each face
  78391. * @param size defines the size of the textures
  78392. * @param format defines the format of the data
  78393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78394. * @param generateMipMaps defines if the engine should generate the mip levels
  78395. * @param invertY defines if data must be stored with Y axis inverted
  78396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78397. * @param compression defines the compression used (null by default)
  78398. * @returns the cube texture as an InternalTexture
  78399. */
  78400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78401. /**
  78402. * Update a raw cube texture
  78403. * @param texture defines the texture to udpdate
  78404. * @param data defines the data to store
  78405. * @param format defines the data format
  78406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78407. * @param invertY defines if data must be stored with Y axis inverted
  78408. */
  78409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78410. /**
  78411. * Update a raw cube texture
  78412. * @param texture defines the texture to udpdate
  78413. * @param data defines the data to store
  78414. * @param format defines the data format
  78415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78416. * @param invertY defines if data must be stored with Y axis inverted
  78417. * @param compression defines the compression used (null by default)
  78418. */
  78419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78420. /**
  78421. * Update a raw cube texture
  78422. * @param texture defines the texture to udpdate
  78423. * @param data defines the data to store
  78424. * @param format defines the data format
  78425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78426. * @param invertY defines if data must be stored with Y axis inverted
  78427. * @param compression defines the compression used (null by default)
  78428. * @param level defines which level of the texture to update
  78429. */
  78430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78431. /**
  78432. * Creates a new raw cube texture from a specified url
  78433. * @param url defines the url where the data is located
  78434. * @param scene defines the current scene
  78435. * @param size defines the size of the textures
  78436. * @param format defines the format of the data
  78437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78438. * @param noMipmap defines if the engine should avoid generating the mip levels
  78439. * @param callback defines a callback used to extract texture data from loaded data
  78440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78441. * @param onLoad defines a callback called when texture is loaded
  78442. * @param onError defines a callback called if there is an error
  78443. * @returns the cube texture as an InternalTexture
  78444. */
  78445. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  78446. /**
  78447. * Creates a new raw cube texture from a specified url
  78448. * @param url defines the url where the data is located
  78449. * @param scene defines the current scene
  78450. * @param size defines the size of the textures
  78451. * @param format defines the format of the data
  78452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78453. * @param noMipmap defines if the engine should avoid generating the mip levels
  78454. * @param callback defines a callback used to extract texture data from loaded data
  78455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78456. * @param onLoad defines a callback called when texture is loaded
  78457. * @param onError defines a callback called if there is an error
  78458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78459. * @param invertY defines if data must be stored with Y axis inverted
  78460. * @returns the cube texture as an InternalTexture
  78461. */
  78462. 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;
  78463. /**
  78464. * Creates a new raw 3D texture
  78465. * @param data defines the data used to create the texture
  78466. * @param width defines the width of the texture
  78467. * @param height defines the height of the texture
  78468. * @param depth defines the depth of the texture
  78469. * @param format defines the format of the texture
  78470. * @param generateMipMaps defines if the engine must generate mip levels
  78471. * @param invertY defines if data must be stored with Y axis inverted
  78472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78473. * @param compression defines the compressed used (can be null)
  78474. * @param textureType defines the compressed used (can be null)
  78475. * @returns a new raw 3D texture (stored in an InternalTexture)
  78476. */
  78477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78478. /**
  78479. * Update a raw 3D texture
  78480. * @param texture defines the texture to update
  78481. * @param data defines the data to store
  78482. * @param format defines the data format
  78483. * @param invertY defines if data must be stored with Y axis inverted
  78484. */
  78485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78486. /**
  78487. * Update a raw 3D texture
  78488. * @param texture defines the texture to update
  78489. * @param data defines the data to store
  78490. * @param format defines the data format
  78491. * @param invertY defines if data must be stored with Y axis inverted
  78492. * @param compression defines the used compression (can be null)
  78493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78494. */
  78495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78496. }
  78497. }
  78498. declare module BABYLON {
  78499. /**
  78500. * Raw texture can help creating a texture directly from an array of data.
  78501. * This can be super useful if you either get the data from an uncompressed source or
  78502. * if you wish to create your texture pixel by pixel.
  78503. */
  78504. export class RawTexture extends Texture {
  78505. /**
  78506. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78507. */
  78508. format: number;
  78509. private _engine;
  78510. /**
  78511. * Instantiates a new RawTexture.
  78512. * Raw texture can help creating a texture directly from an array of data.
  78513. * This can be super useful if you either get the data from an uncompressed source or
  78514. * if you wish to create your texture pixel by pixel.
  78515. * @param data define the array of data to use to create the texture
  78516. * @param width define the width of the texture
  78517. * @param height define the height of the texture
  78518. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78519. * @param scene define the scene the texture belongs to
  78520. * @param generateMipMaps define whether mip maps should be generated or not
  78521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78523. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78524. */
  78525. constructor(data: ArrayBufferView, width: number, height: number,
  78526. /**
  78527. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78528. */
  78529. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78530. /**
  78531. * Updates the texture underlying data.
  78532. * @param data Define the new data of the texture
  78533. */
  78534. update(data: ArrayBufferView): void;
  78535. /**
  78536. * Creates a luminance texture from some data.
  78537. * @param data Define the texture data
  78538. * @param width Define the width of the texture
  78539. * @param height Define the height of the texture
  78540. * @param scene Define the scene the texture belongs to
  78541. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78542. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78543. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78544. * @returns the luminance texture
  78545. */
  78546. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78547. /**
  78548. * Creates a luminance alpha texture from some data.
  78549. * @param data Define the texture data
  78550. * @param width Define the width of the texture
  78551. * @param height Define the height of the texture
  78552. * @param scene Define the scene the texture belongs to
  78553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78556. * @returns the luminance alpha texture
  78557. */
  78558. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78559. /**
  78560. * Creates an alpha texture from some data.
  78561. * @param data Define the texture data
  78562. * @param width Define the width of the texture
  78563. * @param height Define the height of the texture
  78564. * @param scene Define the scene the texture belongs to
  78565. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78566. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78567. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78568. * @returns the alpha texture
  78569. */
  78570. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78571. /**
  78572. * Creates a RGB texture from some data.
  78573. * @param data Define the texture data
  78574. * @param width Define the width of the texture
  78575. * @param height Define the height of the texture
  78576. * @param scene Define the scene the texture belongs to
  78577. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78578. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78579. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78580. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78581. * @returns the RGB alpha texture
  78582. */
  78583. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78584. /**
  78585. * Creates a RGBA texture from some data.
  78586. * @param data Define the texture data
  78587. * @param width Define the width of the texture
  78588. * @param height Define the height of the texture
  78589. * @param scene Define the scene the texture belongs to
  78590. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78593. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78594. * @returns the RGBA texture
  78595. */
  78596. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78597. /**
  78598. * Creates a R texture from some data.
  78599. * @param data Define the texture data
  78600. * @param width Define the width of the texture
  78601. * @param height Define the height of the texture
  78602. * @param scene Define the scene the texture belongs to
  78603. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78604. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78605. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78606. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78607. * @returns the R texture
  78608. */
  78609. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78610. }
  78611. }
  78612. declare module BABYLON {
  78613. /**
  78614. * Defines a runtime animation
  78615. */
  78616. export class RuntimeAnimation {
  78617. private _events;
  78618. /**
  78619. * The current frame of the runtime animation
  78620. */
  78621. private _currentFrame;
  78622. /**
  78623. * The animation used by the runtime animation
  78624. */
  78625. private _animation;
  78626. /**
  78627. * The target of the runtime animation
  78628. */
  78629. private _target;
  78630. /**
  78631. * The initiating animatable
  78632. */
  78633. private _host;
  78634. /**
  78635. * The original value of the runtime animation
  78636. */
  78637. private _originalValue;
  78638. /**
  78639. * The original blend value of the runtime animation
  78640. */
  78641. private _originalBlendValue;
  78642. /**
  78643. * The offsets cache of the runtime animation
  78644. */
  78645. private _offsetsCache;
  78646. /**
  78647. * The high limits cache of the runtime animation
  78648. */
  78649. private _highLimitsCache;
  78650. /**
  78651. * Specifies if the runtime animation has been stopped
  78652. */
  78653. private _stopped;
  78654. /**
  78655. * The blending factor of the runtime animation
  78656. */
  78657. private _blendingFactor;
  78658. /**
  78659. * The BabylonJS scene
  78660. */
  78661. private _scene;
  78662. /**
  78663. * The current value of the runtime animation
  78664. */
  78665. private _currentValue;
  78666. /** @hidden */
  78667. _animationState: _IAnimationState;
  78668. /**
  78669. * The active target of the runtime animation
  78670. */
  78671. private _activeTargets;
  78672. private _currentActiveTarget;
  78673. private _directTarget;
  78674. /**
  78675. * The target path of the runtime animation
  78676. */
  78677. private _targetPath;
  78678. /**
  78679. * The weight of the runtime animation
  78680. */
  78681. private _weight;
  78682. /**
  78683. * The ratio offset of the runtime animation
  78684. */
  78685. private _ratioOffset;
  78686. /**
  78687. * The previous delay of the runtime animation
  78688. */
  78689. private _previousDelay;
  78690. /**
  78691. * The previous ratio of the runtime animation
  78692. */
  78693. private _previousRatio;
  78694. private _enableBlending;
  78695. private _keys;
  78696. private _minFrame;
  78697. private _maxFrame;
  78698. private _minValue;
  78699. private _maxValue;
  78700. private _targetIsArray;
  78701. /**
  78702. * Gets the current frame of the runtime animation
  78703. */
  78704. readonly currentFrame: number;
  78705. /**
  78706. * Gets the weight of the runtime animation
  78707. */
  78708. readonly weight: number;
  78709. /**
  78710. * Gets the current value of the runtime animation
  78711. */
  78712. readonly currentValue: any;
  78713. /**
  78714. * Gets the target path of the runtime animation
  78715. */
  78716. readonly targetPath: string;
  78717. /**
  78718. * Gets the actual target of the runtime animation
  78719. */
  78720. readonly target: any;
  78721. /** @hidden */
  78722. _onLoop: () => void;
  78723. /**
  78724. * Create a new RuntimeAnimation object
  78725. * @param target defines the target of the animation
  78726. * @param animation defines the source animation object
  78727. * @param scene defines the hosting scene
  78728. * @param host defines the initiating Animatable
  78729. */
  78730. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78731. private _preparePath;
  78732. /**
  78733. * Gets the animation from the runtime animation
  78734. */
  78735. readonly animation: Animation;
  78736. /**
  78737. * Resets the runtime animation to the beginning
  78738. * @param restoreOriginal defines whether to restore the target property to the original value
  78739. */
  78740. reset(restoreOriginal?: boolean): void;
  78741. /**
  78742. * Specifies if the runtime animation is stopped
  78743. * @returns Boolean specifying if the runtime animation is stopped
  78744. */
  78745. isStopped(): boolean;
  78746. /**
  78747. * Disposes of the runtime animation
  78748. */
  78749. dispose(): void;
  78750. /**
  78751. * Apply the interpolated value to the target
  78752. * @param currentValue defines the value computed by the animation
  78753. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78754. */
  78755. setValue(currentValue: any, weight: number): void;
  78756. private _getOriginalValues;
  78757. private _setValue;
  78758. /**
  78759. * Gets the loop pmode of the runtime animation
  78760. * @returns Loop Mode
  78761. */
  78762. private _getCorrectLoopMode;
  78763. /**
  78764. * Move the current animation to a given frame
  78765. * @param frame defines the frame to move to
  78766. */
  78767. goToFrame(frame: number): void;
  78768. /**
  78769. * @hidden Internal use only
  78770. */
  78771. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78772. /**
  78773. * Execute the current animation
  78774. * @param delay defines the delay to add to the current frame
  78775. * @param from defines the lower bound of the animation range
  78776. * @param to defines the upper bound of the animation range
  78777. * @param loop defines if the current animation must loop
  78778. * @param speedRatio defines the current speed ratio
  78779. * @param weight defines the weight of the animation (default is -1 so no weight)
  78780. * @param onLoop optional callback called when animation loops
  78781. * @returns a boolean indicating if the animation is running
  78782. */
  78783. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78784. }
  78785. }
  78786. declare module BABYLON {
  78787. /**
  78788. * Class used to store an actual running animation
  78789. */
  78790. export class Animatable {
  78791. /** defines the target object */
  78792. target: any;
  78793. /** defines the starting frame number (default is 0) */
  78794. fromFrame: number;
  78795. /** defines the ending frame number (default is 100) */
  78796. toFrame: number;
  78797. /** defines if the animation must loop (default is false) */
  78798. loopAnimation: boolean;
  78799. /** defines a callback to call when animation ends if it is not looping */
  78800. onAnimationEnd?: (() => void) | null | undefined;
  78801. /** defines a callback to call when animation loops */
  78802. onAnimationLoop?: (() => void) | null | undefined;
  78803. private _localDelayOffset;
  78804. private _pausedDelay;
  78805. private _runtimeAnimations;
  78806. private _paused;
  78807. private _scene;
  78808. private _speedRatio;
  78809. private _weight;
  78810. private _syncRoot;
  78811. /**
  78812. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78813. * This will only apply for non looping animation (default is true)
  78814. */
  78815. disposeOnEnd: boolean;
  78816. /**
  78817. * Gets a boolean indicating if the animation has started
  78818. */
  78819. animationStarted: boolean;
  78820. /**
  78821. * Observer raised when the animation ends
  78822. */
  78823. onAnimationEndObservable: Observable<Animatable>;
  78824. /**
  78825. * Observer raised when the animation loops
  78826. */
  78827. onAnimationLoopObservable: Observable<Animatable>;
  78828. /**
  78829. * Gets the root Animatable used to synchronize and normalize animations
  78830. */
  78831. readonly syncRoot: Nullable<Animatable>;
  78832. /**
  78833. * Gets the current frame of the first RuntimeAnimation
  78834. * Used to synchronize Animatables
  78835. */
  78836. readonly masterFrame: number;
  78837. /**
  78838. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78839. */
  78840. weight: number;
  78841. /**
  78842. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78843. */
  78844. speedRatio: number;
  78845. /**
  78846. * Creates a new Animatable
  78847. * @param scene defines the hosting scene
  78848. * @param target defines the target object
  78849. * @param fromFrame defines the starting frame number (default is 0)
  78850. * @param toFrame defines the ending frame number (default is 100)
  78851. * @param loopAnimation defines if the animation must loop (default is false)
  78852. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78853. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78854. * @param animations defines a group of animation to add to the new Animatable
  78855. * @param onAnimationLoop defines a callback to call when animation loops
  78856. */
  78857. constructor(scene: Scene,
  78858. /** defines the target object */
  78859. target: any,
  78860. /** defines the starting frame number (default is 0) */
  78861. fromFrame?: number,
  78862. /** defines the ending frame number (default is 100) */
  78863. toFrame?: number,
  78864. /** defines if the animation must loop (default is false) */
  78865. loopAnimation?: boolean, speedRatio?: number,
  78866. /** defines a callback to call when animation ends if it is not looping */
  78867. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78868. /** defines a callback to call when animation loops */
  78869. onAnimationLoop?: (() => void) | null | undefined);
  78870. /**
  78871. * Synchronize and normalize current Animatable with a source Animatable
  78872. * This is useful when using animation weights and when animations are not of the same length
  78873. * @param root defines the root Animatable to synchronize with
  78874. * @returns the current Animatable
  78875. */
  78876. syncWith(root: Animatable): Animatable;
  78877. /**
  78878. * Gets the list of runtime animations
  78879. * @returns an array of RuntimeAnimation
  78880. */
  78881. getAnimations(): RuntimeAnimation[];
  78882. /**
  78883. * Adds more animations to the current animatable
  78884. * @param target defines the target of the animations
  78885. * @param animations defines the new animations to add
  78886. */
  78887. appendAnimations(target: any, animations: Animation[]): void;
  78888. /**
  78889. * Gets the source animation for a specific property
  78890. * @param property defines the propertyu to look for
  78891. * @returns null or the source animation for the given property
  78892. */
  78893. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78894. /**
  78895. * Gets the runtime animation for a specific property
  78896. * @param property defines the propertyu to look for
  78897. * @returns null or the runtime animation for the given property
  78898. */
  78899. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78900. /**
  78901. * Resets the animatable to its original state
  78902. */
  78903. reset(): void;
  78904. /**
  78905. * Allows the animatable to blend with current running animations
  78906. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78907. * @param blendingSpeed defines the blending speed to use
  78908. */
  78909. enableBlending(blendingSpeed: number): void;
  78910. /**
  78911. * Disable animation blending
  78912. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78913. */
  78914. disableBlending(): void;
  78915. /**
  78916. * Jump directly to a given frame
  78917. * @param frame defines the frame to jump to
  78918. */
  78919. goToFrame(frame: number): void;
  78920. /**
  78921. * Pause the animation
  78922. */
  78923. pause(): void;
  78924. /**
  78925. * Restart the animation
  78926. */
  78927. restart(): void;
  78928. private _raiseOnAnimationEnd;
  78929. /**
  78930. * Stop and delete the current animation
  78931. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78932. * @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)
  78933. */
  78934. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78935. /**
  78936. * Wait asynchronously for the animation to end
  78937. * @returns a promise which will be fullfilled when the animation ends
  78938. */
  78939. waitAsync(): Promise<Animatable>;
  78940. /** @hidden */
  78941. _animate(delay: number): boolean;
  78942. }
  78943. interface Scene {
  78944. /** @hidden */
  78945. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78946. /** @hidden */
  78947. _processLateAnimationBindingsForMatrices(holder: {
  78948. totalWeight: number;
  78949. animations: RuntimeAnimation[];
  78950. originalValue: Matrix;
  78951. }): any;
  78952. /** @hidden */
  78953. _processLateAnimationBindingsForQuaternions(holder: {
  78954. totalWeight: number;
  78955. animations: RuntimeAnimation[];
  78956. originalValue: Quaternion;
  78957. }, refQuaternion: Quaternion): Quaternion;
  78958. /** @hidden */
  78959. _processLateAnimationBindings(): void;
  78960. /**
  78961. * Will start the animation sequence of a given target
  78962. * @param target defines the target
  78963. * @param from defines from which frame should animation start
  78964. * @param to defines until which frame should animation run.
  78965. * @param weight defines the weight to apply to the animation (1.0 by default)
  78966. * @param loop defines if the animation loops
  78967. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78968. * @param onAnimationEnd defines the function to be executed when the animation ends
  78969. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78970. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78971. * @param onAnimationLoop defines the callback to call when an animation loops
  78972. * @returns the animatable object created for this animation
  78973. */
  78974. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78975. /**
  78976. * Will start the animation sequence of a given target
  78977. * @param target defines the target
  78978. * @param from defines from which frame should animation start
  78979. * @param to defines until which frame should animation run.
  78980. * @param loop defines if the animation loops
  78981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78982. * @param onAnimationEnd defines the function to be executed when the animation ends
  78983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78985. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78986. * @param onAnimationLoop defines the callback to call when an animation loops
  78987. * @returns the animatable object created for this animation
  78988. */
  78989. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78990. /**
  78991. * Will start the animation sequence of a given target and its hierarchy
  78992. * @param target defines the target
  78993. * @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.
  78994. * @param from defines from which frame should animation start
  78995. * @param to defines until which frame should animation run.
  78996. * @param loop defines if the animation loops
  78997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78998. * @param onAnimationEnd defines the function to be executed when the animation ends
  78999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79000. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79001. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79002. * @param onAnimationLoop defines the callback to call when an animation loops
  79003. * @returns the list of created animatables
  79004. */
  79005. 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[];
  79006. /**
  79007. * Begin a new animation on a given node
  79008. * @param target defines the target where the animation will take place
  79009. * @param animations defines the list of animations to start
  79010. * @param from defines the initial value
  79011. * @param to defines the final value
  79012. * @param loop defines if you want animation to loop (off by default)
  79013. * @param speedRatio defines the speed ratio to apply to all animations
  79014. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79015. * @param onAnimationLoop defines the callback to call when an animation loops
  79016. * @returns the list of created animatables
  79017. */
  79018. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79019. /**
  79020. * Begin a new animation on a given node and its hierarchy
  79021. * @param target defines the root node where the animation will take place
  79022. * @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.
  79023. * @param animations defines the list of animations to start
  79024. * @param from defines the initial value
  79025. * @param to defines the final value
  79026. * @param loop defines if you want animation to loop (off by default)
  79027. * @param speedRatio defines the speed ratio to apply to all animations
  79028. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79029. * @param onAnimationLoop defines the callback to call when an animation loops
  79030. * @returns the list of animatables created for all nodes
  79031. */
  79032. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79033. /**
  79034. * Gets the animatable associated with a specific target
  79035. * @param target defines the target of the animatable
  79036. * @returns the required animatable if found
  79037. */
  79038. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79039. /**
  79040. * Gets all animatables associated with a given target
  79041. * @param target defines the target to look animatables for
  79042. * @returns an array of Animatables
  79043. */
  79044. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79045. /**
  79046. * Stops and removes all animations that have been applied to the scene
  79047. */
  79048. stopAllAnimations(): void;
  79049. }
  79050. interface Bone {
  79051. /**
  79052. * Copy an animation range from another bone
  79053. * @param source defines the source bone
  79054. * @param rangeName defines the range name to copy
  79055. * @param frameOffset defines the frame offset
  79056. * @param rescaleAsRequired defines if rescaling must be applied if required
  79057. * @param skelDimensionsRatio defines the scaling ratio
  79058. * @returns true if operation was successful
  79059. */
  79060. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79061. }
  79062. }
  79063. declare module BABYLON {
  79064. /**
  79065. * Class used to handle skinning animations
  79066. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79067. */
  79068. export class Skeleton implements IAnimatable {
  79069. /** defines the skeleton name */
  79070. name: string;
  79071. /** defines the skeleton Id */
  79072. id: string;
  79073. /**
  79074. * Defines the list of child bones
  79075. */
  79076. bones: Bone[];
  79077. /**
  79078. * Defines an estimate of the dimension of the skeleton at rest
  79079. */
  79080. dimensionsAtRest: Vector3;
  79081. /**
  79082. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79083. */
  79084. needInitialSkinMatrix: boolean;
  79085. /**
  79086. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79087. */
  79088. overrideMesh: Nullable<AbstractMesh>;
  79089. /**
  79090. * Gets the list of animations attached to this skeleton
  79091. */
  79092. animations: Array<Animation>;
  79093. private _scene;
  79094. private _isDirty;
  79095. private _transformMatrices;
  79096. private _transformMatrixTexture;
  79097. private _meshesWithPoseMatrix;
  79098. private _animatables;
  79099. private _identity;
  79100. private _synchronizedWithMesh;
  79101. private _ranges;
  79102. private _lastAbsoluteTransformsUpdateId;
  79103. private _canUseTextureForBones;
  79104. private _uniqueId;
  79105. /** @hidden */
  79106. _numBonesWithLinkedTransformNode: number;
  79107. /**
  79108. * Specifies if the skeleton should be serialized
  79109. */
  79110. doNotSerialize: boolean;
  79111. private _useTextureToStoreBoneMatrices;
  79112. /**
  79113. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79114. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79115. */
  79116. useTextureToStoreBoneMatrices: boolean;
  79117. private _animationPropertiesOverride;
  79118. /**
  79119. * Gets or sets the animation properties override
  79120. */
  79121. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79122. /**
  79123. * List of inspectable custom properties (used by the Inspector)
  79124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79125. */
  79126. inspectableCustomProperties: IInspectable[];
  79127. /**
  79128. * An observable triggered before computing the skeleton's matrices
  79129. */
  79130. onBeforeComputeObservable: Observable<Skeleton>;
  79131. /**
  79132. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79133. */
  79134. readonly isUsingTextureForMatrices: boolean;
  79135. /**
  79136. * Gets the unique ID of this skeleton
  79137. */
  79138. readonly uniqueId: number;
  79139. /**
  79140. * Creates a new skeleton
  79141. * @param name defines the skeleton name
  79142. * @param id defines the skeleton Id
  79143. * @param scene defines the hosting scene
  79144. */
  79145. constructor(
  79146. /** defines the skeleton name */
  79147. name: string,
  79148. /** defines the skeleton Id */
  79149. id: string, scene: Scene);
  79150. /**
  79151. * Gets the current object class name.
  79152. * @return the class name
  79153. */
  79154. getClassName(): string;
  79155. /**
  79156. * Returns an array containing the root bones
  79157. * @returns an array containing the root bones
  79158. */
  79159. getChildren(): Array<Bone>;
  79160. /**
  79161. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79162. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79163. * @returns a Float32Array containing matrices data
  79164. */
  79165. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79166. /**
  79167. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79168. * @returns a raw texture containing the data
  79169. */
  79170. getTransformMatrixTexture(): Nullable<RawTexture>;
  79171. /**
  79172. * Gets the current hosting scene
  79173. * @returns a scene object
  79174. */
  79175. getScene(): Scene;
  79176. /**
  79177. * Gets a string representing the current skeleton data
  79178. * @param fullDetails defines a boolean indicating if we want a verbose version
  79179. * @returns a string representing the current skeleton data
  79180. */
  79181. toString(fullDetails?: boolean): string;
  79182. /**
  79183. * Get bone's index searching by name
  79184. * @param name defines bone's name to search for
  79185. * @return the indice of the bone. Returns -1 if not found
  79186. */
  79187. getBoneIndexByName(name: string): number;
  79188. /**
  79189. * Creater a new animation range
  79190. * @param name defines the name of the range
  79191. * @param from defines the start key
  79192. * @param to defines the end key
  79193. */
  79194. createAnimationRange(name: string, from: number, to: number): void;
  79195. /**
  79196. * Delete a specific animation range
  79197. * @param name defines the name of the range
  79198. * @param deleteFrames defines if frames must be removed as well
  79199. */
  79200. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79201. /**
  79202. * Gets a specific animation range
  79203. * @param name defines the name of the range to look for
  79204. * @returns the requested animation range or null if not found
  79205. */
  79206. getAnimationRange(name: string): Nullable<AnimationRange>;
  79207. /**
  79208. * Gets the list of all animation ranges defined on this skeleton
  79209. * @returns an array
  79210. */
  79211. getAnimationRanges(): Nullable<AnimationRange>[];
  79212. /**
  79213. * Copy animation range from a source skeleton.
  79214. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79215. * @param source defines the source skeleton
  79216. * @param name defines the name of the range to copy
  79217. * @param rescaleAsRequired defines if rescaling must be applied if required
  79218. * @returns true if operation was successful
  79219. */
  79220. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79221. /**
  79222. * Forces the skeleton to go to rest pose
  79223. */
  79224. returnToRest(): void;
  79225. private _getHighestAnimationFrame;
  79226. /**
  79227. * Begin a specific animation range
  79228. * @param name defines the name of the range to start
  79229. * @param loop defines if looping must be turned on (false by default)
  79230. * @param speedRatio defines the speed ratio to apply (1 by default)
  79231. * @param onAnimationEnd defines a callback which will be called when animation will end
  79232. * @returns a new animatable
  79233. */
  79234. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79235. /** @hidden */
  79236. _markAsDirty(): void;
  79237. /** @hidden */
  79238. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79239. /** @hidden */
  79240. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79241. private _computeTransformMatrices;
  79242. /**
  79243. * Build all resources required to render a skeleton
  79244. */
  79245. prepare(): void;
  79246. /**
  79247. * Gets the list of animatables currently running for this skeleton
  79248. * @returns an array of animatables
  79249. */
  79250. getAnimatables(): IAnimatable[];
  79251. /**
  79252. * Clone the current skeleton
  79253. * @param name defines the name of the new skeleton
  79254. * @param id defines the id of the new skeleton
  79255. * @returns the new skeleton
  79256. */
  79257. clone(name: string, id: string): Skeleton;
  79258. /**
  79259. * Enable animation blending for this skeleton
  79260. * @param blendingSpeed defines the blending speed to apply
  79261. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79262. */
  79263. enableBlending(blendingSpeed?: number): void;
  79264. /**
  79265. * Releases all resources associated with the current skeleton
  79266. */
  79267. dispose(): void;
  79268. /**
  79269. * Serialize the skeleton in a JSON object
  79270. * @returns a JSON object
  79271. */
  79272. serialize(): any;
  79273. /**
  79274. * Creates a new skeleton from serialized data
  79275. * @param parsedSkeleton defines the serialized data
  79276. * @param scene defines the hosting scene
  79277. * @returns a new skeleton
  79278. */
  79279. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79280. /**
  79281. * Compute all node absolute transforms
  79282. * @param forceUpdate defines if computation must be done even if cache is up to date
  79283. */
  79284. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79285. /**
  79286. * Gets the root pose matrix
  79287. * @returns a matrix
  79288. */
  79289. getPoseMatrix(): Nullable<Matrix>;
  79290. /**
  79291. * Sorts bones per internal index
  79292. */
  79293. sortBones(): void;
  79294. private _sortBones;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * Defines a target to use with MorphTargetManager
  79300. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79301. */
  79302. export class MorphTarget implements IAnimatable {
  79303. /** defines the name of the target */
  79304. name: string;
  79305. /**
  79306. * Gets or sets the list of animations
  79307. */
  79308. animations: Animation[];
  79309. private _scene;
  79310. private _positions;
  79311. private _normals;
  79312. private _tangents;
  79313. private _influence;
  79314. /**
  79315. * Observable raised when the influence changes
  79316. */
  79317. onInfluenceChanged: Observable<boolean>;
  79318. /** @hidden */
  79319. _onDataLayoutChanged: Observable<void>;
  79320. /**
  79321. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  79322. */
  79323. influence: number;
  79324. /**
  79325. * Gets or sets the id of the morph Target
  79326. */
  79327. id: string;
  79328. private _animationPropertiesOverride;
  79329. /**
  79330. * Gets or sets the animation properties override
  79331. */
  79332. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79333. /**
  79334. * Creates a new MorphTarget
  79335. * @param name defines the name of the target
  79336. * @param influence defines the influence to use
  79337. * @param scene defines the scene the morphtarget belongs to
  79338. */
  79339. constructor(
  79340. /** defines the name of the target */
  79341. name: string, influence?: number, scene?: Nullable<Scene>);
  79342. /**
  79343. * Gets a boolean defining if the target contains position data
  79344. */
  79345. readonly hasPositions: boolean;
  79346. /**
  79347. * Gets a boolean defining if the target contains normal data
  79348. */
  79349. readonly hasNormals: boolean;
  79350. /**
  79351. * Gets a boolean defining if the target contains tangent data
  79352. */
  79353. readonly hasTangents: boolean;
  79354. /**
  79355. * Affects position data to this target
  79356. * @param data defines the position data to use
  79357. */
  79358. setPositions(data: Nullable<FloatArray>): void;
  79359. /**
  79360. * Gets the position data stored in this target
  79361. * @returns a FloatArray containing the position data (or null if not present)
  79362. */
  79363. getPositions(): Nullable<FloatArray>;
  79364. /**
  79365. * Affects normal data to this target
  79366. * @param data defines the normal data to use
  79367. */
  79368. setNormals(data: Nullable<FloatArray>): void;
  79369. /**
  79370. * Gets the normal data stored in this target
  79371. * @returns a FloatArray containing the normal data (or null if not present)
  79372. */
  79373. getNormals(): Nullable<FloatArray>;
  79374. /**
  79375. * Affects tangent data to this target
  79376. * @param data defines the tangent data to use
  79377. */
  79378. setTangents(data: Nullable<FloatArray>): void;
  79379. /**
  79380. * Gets the tangent data stored in this target
  79381. * @returns a FloatArray containing the tangent data (or null if not present)
  79382. */
  79383. getTangents(): Nullable<FloatArray>;
  79384. /**
  79385. * Serializes the current target into a Serialization object
  79386. * @returns the serialized object
  79387. */
  79388. serialize(): any;
  79389. /**
  79390. * Returns the string "MorphTarget"
  79391. * @returns "MorphTarget"
  79392. */
  79393. getClassName(): string;
  79394. /**
  79395. * Creates a new target from serialized data
  79396. * @param serializationObject defines the serialized data to use
  79397. * @returns a new MorphTarget
  79398. */
  79399. static Parse(serializationObject: any): MorphTarget;
  79400. /**
  79401. * Creates a MorphTarget from mesh data
  79402. * @param mesh defines the source mesh
  79403. * @param name defines the name to use for the new target
  79404. * @param influence defines the influence to attach to the target
  79405. * @returns a new MorphTarget
  79406. */
  79407. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  79408. }
  79409. }
  79410. declare module BABYLON {
  79411. /**
  79412. * This class is used to deform meshes using morphing between different targets
  79413. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79414. */
  79415. export class MorphTargetManager {
  79416. private _targets;
  79417. private _targetInfluenceChangedObservers;
  79418. private _targetDataLayoutChangedObservers;
  79419. private _activeTargets;
  79420. private _scene;
  79421. private _influences;
  79422. private _supportsNormals;
  79423. private _supportsTangents;
  79424. private _vertexCount;
  79425. private _uniqueId;
  79426. private _tempInfluences;
  79427. /**
  79428. * Creates a new MorphTargetManager
  79429. * @param scene defines the current scene
  79430. */
  79431. constructor(scene?: Nullable<Scene>);
  79432. /**
  79433. * Gets the unique ID of this manager
  79434. */
  79435. readonly uniqueId: number;
  79436. /**
  79437. * Gets the number of vertices handled by this manager
  79438. */
  79439. readonly vertexCount: number;
  79440. /**
  79441. * Gets a boolean indicating if this manager supports morphing of normals
  79442. */
  79443. readonly supportsNormals: boolean;
  79444. /**
  79445. * Gets a boolean indicating if this manager supports morphing of tangents
  79446. */
  79447. readonly supportsTangents: boolean;
  79448. /**
  79449. * Gets the number of targets stored in this manager
  79450. */
  79451. readonly numTargets: number;
  79452. /**
  79453. * Gets the number of influencers (ie. the number of targets with influences > 0)
  79454. */
  79455. readonly numInfluencers: number;
  79456. /**
  79457. * Gets the list of influences (one per target)
  79458. */
  79459. readonly influences: Float32Array;
  79460. /**
  79461. * Gets the active target at specified index. An active target is a target with an influence > 0
  79462. * @param index defines the index to check
  79463. * @returns the requested target
  79464. */
  79465. getActiveTarget(index: number): MorphTarget;
  79466. /**
  79467. * Gets the target at specified index
  79468. * @param index defines the index to check
  79469. * @returns the requested target
  79470. */
  79471. getTarget(index: number): MorphTarget;
  79472. /**
  79473. * Add a new target to this manager
  79474. * @param target defines the target to add
  79475. */
  79476. addTarget(target: MorphTarget): void;
  79477. /**
  79478. * Removes a target from the manager
  79479. * @param target defines the target to remove
  79480. */
  79481. removeTarget(target: MorphTarget): void;
  79482. /**
  79483. * Serializes the current manager into a Serialization object
  79484. * @returns the serialized object
  79485. */
  79486. serialize(): any;
  79487. private _syncActiveTargets;
  79488. /**
  79489. * Syncrhonize the targets with all the meshes using this morph target manager
  79490. */
  79491. synchronize(): void;
  79492. /**
  79493. * Creates a new MorphTargetManager from serialized data
  79494. * @param serializationObject defines the serialized data
  79495. * @param scene defines the hosting scene
  79496. * @returns the new MorphTargetManager
  79497. */
  79498. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  79499. }
  79500. }
  79501. declare module BABYLON {
  79502. /**
  79503. * Class used to represent a specific level of detail of a mesh
  79504. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79505. */
  79506. export class MeshLODLevel {
  79507. /** Defines the distance where this level should star being displayed */
  79508. distance: number;
  79509. /** Defines the mesh to use to render this level */
  79510. mesh: Nullable<Mesh>;
  79511. /**
  79512. * Creates a new LOD level
  79513. * @param distance defines the distance where this level should star being displayed
  79514. * @param mesh defines the mesh to use to render this level
  79515. */
  79516. constructor(
  79517. /** Defines the distance where this level should star being displayed */
  79518. distance: number,
  79519. /** Defines the mesh to use to render this level */
  79520. mesh: Nullable<Mesh>);
  79521. }
  79522. }
  79523. declare module BABYLON {
  79524. /**
  79525. * Mesh representing the gorund
  79526. */
  79527. export class GroundMesh extends Mesh {
  79528. /** If octree should be generated */
  79529. generateOctree: boolean;
  79530. private _heightQuads;
  79531. /** @hidden */
  79532. _subdivisionsX: number;
  79533. /** @hidden */
  79534. _subdivisionsY: number;
  79535. /** @hidden */
  79536. _width: number;
  79537. /** @hidden */
  79538. _height: number;
  79539. /** @hidden */
  79540. _minX: number;
  79541. /** @hidden */
  79542. _maxX: number;
  79543. /** @hidden */
  79544. _minZ: number;
  79545. /** @hidden */
  79546. _maxZ: number;
  79547. constructor(name: string, scene: Scene);
  79548. /**
  79549. * "GroundMesh"
  79550. * @returns "GroundMesh"
  79551. */
  79552. getClassName(): string;
  79553. /**
  79554. * The minimum of x and y subdivisions
  79555. */
  79556. readonly subdivisions: number;
  79557. /**
  79558. * X subdivisions
  79559. */
  79560. readonly subdivisionsX: number;
  79561. /**
  79562. * Y subdivisions
  79563. */
  79564. readonly subdivisionsY: number;
  79565. /**
  79566. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  79567. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  79568. * @param chunksCount the number of subdivisions for x and y
  79569. * @param octreeBlocksSize (Default: 32)
  79570. */
  79571. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  79572. /**
  79573. * Returns a height (y) value in the Worl system :
  79574. * the ground altitude at the coordinates (x, z) expressed in the World system.
  79575. * @param x x coordinate
  79576. * @param z z coordinate
  79577. * @returns the ground y position if (x, z) are outside the ground surface.
  79578. */
  79579. getHeightAtCoordinates(x: number, z: number): number;
  79580. /**
  79581. * Returns a normalized vector (Vector3) orthogonal to the ground
  79582. * at the ground coordinates (x, z) expressed in the World system.
  79583. * @param x x coordinate
  79584. * @param z z coordinate
  79585. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  79586. */
  79587. getNormalAtCoordinates(x: number, z: number): Vector3;
  79588. /**
  79589. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  79590. * at the ground coordinates (x, z) expressed in the World system.
  79591. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  79592. * @param x x coordinate
  79593. * @param z z coordinate
  79594. * @param ref vector to store the result
  79595. * @returns the GroundMesh.
  79596. */
  79597. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  79598. /**
  79599. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  79600. * if the ground has been updated.
  79601. * This can be used in the render loop.
  79602. * @returns the GroundMesh.
  79603. */
  79604. updateCoordinateHeights(): GroundMesh;
  79605. private _getFacetAt;
  79606. private _initHeightQuads;
  79607. private _computeHeightQuads;
  79608. /**
  79609. * Serializes this ground mesh
  79610. * @param serializationObject object to write serialization to
  79611. */
  79612. serialize(serializationObject: any): void;
  79613. /**
  79614. * Parses a serialized ground mesh
  79615. * @param parsedMesh the serialized mesh
  79616. * @param scene the scene to create the ground mesh in
  79617. * @returns the created ground mesh
  79618. */
  79619. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  79620. }
  79621. }
  79622. declare module BABYLON {
  79623. /**
  79624. * Interface for Physics-Joint data
  79625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79626. */
  79627. export interface PhysicsJointData {
  79628. /**
  79629. * The main pivot of the joint
  79630. */
  79631. mainPivot?: Vector3;
  79632. /**
  79633. * The connected pivot of the joint
  79634. */
  79635. connectedPivot?: Vector3;
  79636. /**
  79637. * The main axis of the joint
  79638. */
  79639. mainAxis?: Vector3;
  79640. /**
  79641. * The connected axis of the joint
  79642. */
  79643. connectedAxis?: Vector3;
  79644. /**
  79645. * The collision of the joint
  79646. */
  79647. collision?: boolean;
  79648. /**
  79649. * Native Oimo/Cannon/Energy data
  79650. */
  79651. nativeParams?: any;
  79652. }
  79653. /**
  79654. * This is a holder class for the physics joint created by the physics plugin
  79655. * It holds a set of functions to control the underlying joint
  79656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79657. */
  79658. export class PhysicsJoint {
  79659. /**
  79660. * The type of the physics joint
  79661. */
  79662. type: number;
  79663. /**
  79664. * The data for the physics joint
  79665. */
  79666. jointData: PhysicsJointData;
  79667. private _physicsJoint;
  79668. protected _physicsPlugin: IPhysicsEnginePlugin;
  79669. /**
  79670. * Initializes the physics joint
  79671. * @param type The type of the physics joint
  79672. * @param jointData The data for the physics joint
  79673. */
  79674. constructor(
  79675. /**
  79676. * The type of the physics joint
  79677. */
  79678. type: number,
  79679. /**
  79680. * The data for the physics joint
  79681. */
  79682. jointData: PhysicsJointData);
  79683. /**
  79684. * Gets the physics joint
  79685. */
  79686. /**
  79687. * Sets the physics joint
  79688. */
  79689. physicsJoint: any;
  79690. /**
  79691. * Sets the physics plugin
  79692. */
  79693. physicsPlugin: IPhysicsEnginePlugin;
  79694. /**
  79695. * Execute a function that is physics-plugin specific.
  79696. * @param {Function} func the function that will be executed.
  79697. * It accepts two parameters: the physics world and the physics joint
  79698. */
  79699. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79700. /**
  79701. * Distance-Joint type
  79702. */
  79703. static DistanceJoint: number;
  79704. /**
  79705. * Hinge-Joint type
  79706. */
  79707. static HingeJoint: number;
  79708. /**
  79709. * Ball-and-Socket joint type
  79710. */
  79711. static BallAndSocketJoint: number;
  79712. /**
  79713. * Wheel-Joint type
  79714. */
  79715. static WheelJoint: number;
  79716. /**
  79717. * Slider-Joint type
  79718. */
  79719. static SliderJoint: number;
  79720. /**
  79721. * Prismatic-Joint type
  79722. */
  79723. static PrismaticJoint: number;
  79724. /**
  79725. * Universal-Joint type
  79726. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79727. */
  79728. static UniversalJoint: number;
  79729. /**
  79730. * Hinge-Joint 2 type
  79731. */
  79732. static Hinge2Joint: number;
  79733. /**
  79734. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79735. */
  79736. static PointToPointJoint: number;
  79737. /**
  79738. * Spring-Joint type
  79739. */
  79740. static SpringJoint: number;
  79741. /**
  79742. * Lock-Joint type
  79743. */
  79744. static LockJoint: number;
  79745. }
  79746. /**
  79747. * A class representing a physics distance joint
  79748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79749. */
  79750. export class DistanceJoint extends PhysicsJoint {
  79751. /**
  79752. *
  79753. * @param jointData The data for the Distance-Joint
  79754. */
  79755. constructor(jointData: DistanceJointData);
  79756. /**
  79757. * Update the predefined distance.
  79758. * @param maxDistance The maximum preferred distance
  79759. * @param minDistance The minimum preferred distance
  79760. */
  79761. updateDistance(maxDistance: number, minDistance?: number): void;
  79762. }
  79763. /**
  79764. * Represents a Motor-Enabled Joint
  79765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79766. */
  79767. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79768. /**
  79769. * Initializes the Motor-Enabled Joint
  79770. * @param type The type of the joint
  79771. * @param jointData The physica joint data for the joint
  79772. */
  79773. constructor(type: number, jointData: PhysicsJointData);
  79774. /**
  79775. * Set the motor values.
  79776. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79777. * @param force the force to apply
  79778. * @param maxForce max force for this motor.
  79779. */
  79780. setMotor(force?: number, maxForce?: number): void;
  79781. /**
  79782. * Set the motor's limits.
  79783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79784. * @param upperLimit The upper limit of the motor
  79785. * @param lowerLimit The lower limit of the motor
  79786. */
  79787. setLimit(upperLimit: number, lowerLimit?: number): void;
  79788. }
  79789. /**
  79790. * This class represents a single physics Hinge-Joint
  79791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79792. */
  79793. export class HingeJoint extends MotorEnabledJoint {
  79794. /**
  79795. * Initializes the Hinge-Joint
  79796. * @param jointData The joint data for the Hinge-Joint
  79797. */
  79798. constructor(jointData: PhysicsJointData);
  79799. /**
  79800. * Set the motor values.
  79801. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79802. * @param {number} force the force to apply
  79803. * @param {number} maxForce max force for this motor.
  79804. */
  79805. setMotor(force?: number, maxForce?: number): void;
  79806. /**
  79807. * Set the motor's limits.
  79808. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79809. * @param upperLimit The upper limit of the motor
  79810. * @param lowerLimit The lower limit of the motor
  79811. */
  79812. setLimit(upperLimit: number, lowerLimit?: number): void;
  79813. }
  79814. /**
  79815. * This class represents a dual hinge physics joint (same as wheel joint)
  79816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79817. */
  79818. export class Hinge2Joint extends MotorEnabledJoint {
  79819. /**
  79820. * Initializes the Hinge2-Joint
  79821. * @param jointData The joint data for the Hinge2-Joint
  79822. */
  79823. constructor(jointData: PhysicsJointData);
  79824. /**
  79825. * Set the motor values.
  79826. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79827. * @param {number} targetSpeed the speed the motor is to reach
  79828. * @param {number} maxForce max force for this motor.
  79829. * @param {motorIndex} the motor's index, 0 or 1.
  79830. */
  79831. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79832. /**
  79833. * Set the motor limits.
  79834. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79835. * @param {number} upperLimit the upper limit
  79836. * @param {number} lowerLimit lower limit
  79837. * @param {motorIndex} the motor's index, 0 or 1.
  79838. */
  79839. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79840. }
  79841. /**
  79842. * Interface for a motor enabled joint
  79843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79844. */
  79845. export interface IMotorEnabledJoint {
  79846. /**
  79847. * Physics joint
  79848. */
  79849. physicsJoint: any;
  79850. /**
  79851. * Sets the motor of the motor-enabled joint
  79852. * @param force The force of the motor
  79853. * @param maxForce The maximum force of the motor
  79854. * @param motorIndex The index of the motor
  79855. */
  79856. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79857. /**
  79858. * Sets the limit of the motor
  79859. * @param upperLimit The upper limit of the motor
  79860. * @param lowerLimit The lower limit of the motor
  79861. * @param motorIndex The index of the motor
  79862. */
  79863. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79864. }
  79865. /**
  79866. * Joint data for a Distance-Joint
  79867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79868. */
  79869. export interface DistanceJointData extends PhysicsJointData {
  79870. /**
  79871. * Max distance the 2 joint objects can be apart
  79872. */
  79873. maxDistance: number;
  79874. }
  79875. /**
  79876. * Joint data from a spring joint
  79877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79878. */
  79879. export interface SpringJointData extends PhysicsJointData {
  79880. /**
  79881. * Length of the spring
  79882. */
  79883. length: number;
  79884. /**
  79885. * Stiffness of the spring
  79886. */
  79887. stiffness: number;
  79888. /**
  79889. * Damping of the spring
  79890. */
  79891. damping: number;
  79892. /** this callback will be called when applying the force to the impostors. */
  79893. forceApplicationCallback: () => void;
  79894. }
  79895. }
  79896. declare module BABYLON {
  79897. /**
  79898. * Holds the data for the raycast result
  79899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79900. */
  79901. export class PhysicsRaycastResult {
  79902. private _hasHit;
  79903. private _hitDistance;
  79904. private _hitNormalWorld;
  79905. private _hitPointWorld;
  79906. private _rayFromWorld;
  79907. private _rayToWorld;
  79908. /**
  79909. * Gets if there was a hit
  79910. */
  79911. readonly hasHit: boolean;
  79912. /**
  79913. * Gets the distance from the hit
  79914. */
  79915. readonly hitDistance: number;
  79916. /**
  79917. * Gets the hit normal/direction in the world
  79918. */
  79919. readonly hitNormalWorld: Vector3;
  79920. /**
  79921. * Gets the hit point in the world
  79922. */
  79923. readonly hitPointWorld: Vector3;
  79924. /**
  79925. * Gets the ray "start point" of the ray in the world
  79926. */
  79927. readonly rayFromWorld: Vector3;
  79928. /**
  79929. * Gets the ray "end point" of the ray in the world
  79930. */
  79931. readonly rayToWorld: Vector3;
  79932. /**
  79933. * Sets the hit data (normal & point in world space)
  79934. * @param hitNormalWorld defines the normal in world space
  79935. * @param hitPointWorld defines the point in world space
  79936. */
  79937. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79938. /**
  79939. * Sets the distance from the start point to the hit point
  79940. * @param distance
  79941. */
  79942. setHitDistance(distance: number): void;
  79943. /**
  79944. * Calculates the distance manually
  79945. */
  79946. calculateHitDistance(): void;
  79947. /**
  79948. * Resets all the values to default
  79949. * @param from The from point on world space
  79950. * @param to The to point on world space
  79951. */
  79952. reset(from?: Vector3, to?: Vector3): void;
  79953. }
  79954. /**
  79955. * Interface for the size containing width and height
  79956. */
  79957. interface IXYZ {
  79958. /**
  79959. * X
  79960. */
  79961. x: number;
  79962. /**
  79963. * Y
  79964. */
  79965. y: number;
  79966. /**
  79967. * Z
  79968. */
  79969. z: number;
  79970. }
  79971. }
  79972. declare module BABYLON {
  79973. /**
  79974. * Interface used to describe a physics joint
  79975. */
  79976. export interface PhysicsImpostorJoint {
  79977. /** Defines the main impostor to which the joint is linked */
  79978. mainImpostor: PhysicsImpostor;
  79979. /** Defines the impostor that is connected to the main impostor using this joint */
  79980. connectedImpostor: PhysicsImpostor;
  79981. /** Defines the joint itself */
  79982. joint: PhysicsJoint;
  79983. }
  79984. /** @hidden */
  79985. export interface IPhysicsEnginePlugin {
  79986. world: any;
  79987. name: string;
  79988. setGravity(gravity: Vector3): void;
  79989. setTimeStep(timeStep: number): void;
  79990. getTimeStep(): number;
  79991. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79992. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79993. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79994. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79995. removePhysicsBody(impostor: PhysicsImpostor): void;
  79996. generateJoint(joint: PhysicsImpostorJoint): void;
  79997. removeJoint(joint: PhysicsImpostorJoint): void;
  79998. isSupported(): boolean;
  79999. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  80000. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  80001. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80002. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  80003. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80004. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  80005. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  80006. getBodyMass(impostor: PhysicsImpostor): number;
  80007. getBodyFriction(impostor: PhysicsImpostor): number;
  80008. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  80009. getBodyRestitution(impostor: PhysicsImpostor): number;
  80010. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  80011. getBodyPressure?(impostor: PhysicsImpostor): number;
  80012. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  80013. getBodyStiffness?(impostor: PhysicsImpostor): number;
  80014. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  80015. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  80016. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  80017. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  80018. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  80019. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80020. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  80021. sleepBody(impostor: PhysicsImpostor): void;
  80022. wakeUpBody(impostor: PhysicsImpostor): void;
  80023. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80024. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  80025. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  80026. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  80027. getRadius(impostor: PhysicsImpostor): number;
  80028. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  80029. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  80030. dispose(): void;
  80031. }
  80032. /**
  80033. * Interface used to define a physics engine
  80034. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  80035. */
  80036. export interface IPhysicsEngine {
  80037. /**
  80038. * Gets the gravity vector used by the simulation
  80039. */
  80040. gravity: Vector3;
  80041. /**
  80042. * Sets the gravity vector used by the simulation
  80043. * @param gravity defines the gravity vector to use
  80044. */
  80045. setGravity(gravity: Vector3): void;
  80046. /**
  80047. * Set the time step of the physics engine.
  80048. * Default is 1/60.
  80049. * To slow it down, enter 1/600 for example.
  80050. * To speed it up, 1/30
  80051. * @param newTimeStep the new timestep to apply to this world.
  80052. */
  80053. setTimeStep(newTimeStep: number): void;
  80054. /**
  80055. * Get the time step of the physics engine.
  80056. * @returns the current time step
  80057. */
  80058. getTimeStep(): number;
  80059. /**
  80060. * Release all resources
  80061. */
  80062. dispose(): void;
  80063. /**
  80064. * Gets the name of the current physics plugin
  80065. * @returns the name of the plugin
  80066. */
  80067. getPhysicsPluginName(): string;
  80068. /**
  80069. * Adding a new impostor for the impostor tracking.
  80070. * This will be done by the impostor itself.
  80071. * @param impostor the impostor to add
  80072. */
  80073. addImpostor(impostor: PhysicsImpostor): void;
  80074. /**
  80075. * Remove an impostor from the engine.
  80076. * This impostor and its mesh will not longer be updated by the physics engine.
  80077. * @param impostor the impostor to remove
  80078. */
  80079. removeImpostor(impostor: PhysicsImpostor): void;
  80080. /**
  80081. * Add a joint to the physics engine
  80082. * @param mainImpostor defines the main impostor to which the joint is added.
  80083. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  80084. * @param joint defines the joint that will connect both impostors.
  80085. */
  80086. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80087. /**
  80088. * Removes a joint from the simulation
  80089. * @param mainImpostor defines the impostor used with the joint
  80090. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  80091. * @param joint defines the joint to remove
  80092. */
  80093. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  80094. /**
  80095. * Gets the current plugin used to run the simulation
  80096. * @returns current plugin
  80097. */
  80098. getPhysicsPlugin(): IPhysicsEnginePlugin;
  80099. /**
  80100. * Gets the list of physic impostors
  80101. * @returns an array of PhysicsImpostor
  80102. */
  80103. getImpostors(): Array<PhysicsImpostor>;
  80104. /**
  80105. * Gets the impostor for a physics enabled object
  80106. * @param object defines the object impersonated by the impostor
  80107. * @returns the PhysicsImpostor or null if not found
  80108. */
  80109. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80110. /**
  80111. * Gets the impostor for a physics body object
  80112. * @param body defines physics body used by the impostor
  80113. * @returns the PhysicsImpostor or null if not found
  80114. */
  80115. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  80116. /**
  80117. * Does a raycast in the physics world
  80118. * @param from when should the ray start?
  80119. * @param to when should the ray end?
  80120. * @returns PhysicsRaycastResult
  80121. */
  80122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  80123. /**
  80124. * Called by the scene. No need to call it.
  80125. * @param delta defines the timespam between frames
  80126. */
  80127. _step(delta: number): void;
  80128. }
  80129. }
  80130. declare module BABYLON {
  80131. /**
  80132. * The interface for the physics imposter parameters
  80133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80134. */
  80135. export interface PhysicsImpostorParameters {
  80136. /**
  80137. * The mass of the physics imposter
  80138. */
  80139. mass: number;
  80140. /**
  80141. * The friction of the physics imposter
  80142. */
  80143. friction?: number;
  80144. /**
  80145. * The coefficient of restitution of the physics imposter
  80146. */
  80147. restitution?: number;
  80148. /**
  80149. * The native options of the physics imposter
  80150. */
  80151. nativeOptions?: any;
  80152. /**
  80153. * Specifies if the parent should be ignored
  80154. */
  80155. ignoreParent?: boolean;
  80156. /**
  80157. * Specifies if bi-directional transformations should be disabled
  80158. */
  80159. disableBidirectionalTransformation?: boolean;
  80160. /**
  80161. * The pressure inside the physics imposter, soft object only
  80162. */
  80163. pressure?: number;
  80164. /**
  80165. * The stiffness the physics imposter, soft object only
  80166. */
  80167. stiffness?: number;
  80168. /**
  80169. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  80170. */
  80171. velocityIterations?: number;
  80172. /**
  80173. * The number of iterations used in maintaining consistent vertex positions, soft object only
  80174. */
  80175. positionIterations?: number;
  80176. /**
  80177. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  80178. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  80179. * Add to fix multiple points
  80180. */
  80181. fixedPoints?: number;
  80182. /**
  80183. * The collision margin around a soft object
  80184. */
  80185. margin?: number;
  80186. /**
  80187. * The collision margin around a soft object
  80188. */
  80189. damping?: number;
  80190. /**
  80191. * The path for a rope based on an extrusion
  80192. */
  80193. path?: any;
  80194. /**
  80195. * The shape of an extrusion used for a rope based on an extrusion
  80196. */
  80197. shape?: any;
  80198. }
  80199. /**
  80200. * Interface for a physics-enabled object
  80201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80202. */
  80203. export interface IPhysicsEnabledObject {
  80204. /**
  80205. * The position of the physics-enabled object
  80206. */
  80207. position: Vector3;
  80208. /**
  80209. * The rotation of the physics-enabled object
  80210. */
  80211. rotationQuaternion: Nullable<Quaternion>;
  80212. /**
  80213. * The scale of the physics-enabled object
  80214. */
  80215. scaling: Vector3;
  80216. /**
  80217. * The rotation of the physics-enabled object
  80218. */
  80219. rotation?: Vector3;
  80220. /**
  80221. * The parent of the physics-enabled object
  80222. */
  80223. parent?: any;
  80224. /**
  80225. * The bounding info of the physics-enabled object
  80226. * @returns The bounding info of the physics-enabled object
  80227. */
  80228. getBoundingInfo(): BoundingInfo;
  80229. /**
  80230. * Computes the world matrix
  80231. * @param force Specifies if the world matrix should be computed by force
  80232. * @returns A world matrix
  80233. */
  80234. computeWorldMatrix(force: boolean): Matrix;
  80235. /**
  80236. * Gets the world matrix
  80237. * @returns A world matrix
  80238. */
  80239. getWorldMatrix?(): Matrix;
  80240. /**
  80241. * Gets the child meshes
  80242. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  80243. * @returns An array of abstract meshes
  80244. */
  80245. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  80246. /**
  80247. * Gets the vertex data
  80248. * @param kind The type of vertex data
  80249. * @returns A nullable array of numbers, or a float32 array
  80250. */
  80251. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  80252. /**
  80253. * Gets the indices from the mesh
  80254. * @returns A nullable array of index arrays
  80255. */
  80256. getIndices?(): Nullable<IndicesArray>;
  80257. /**
  80258. * Gets the scene from the mesh
  80259. * @returns the indices array or null
  80260. */
  80261. getScene?(): Scene;
  80262. /**
  80263. * Gets the absolute position from the mesh
  80264. * @returns the absolute position
  80265. */
  80266. getAbsolutePosition(): Vector3;
  80267. /**
  80268. * Gets the absolute pivot point from the mesh
  80269. * @returns the absolute pivot point
  80270. */
  80271. getAbsolutePivotPoint(): Vector3;
  80272. /**
  80273. * Rotates the mesh
  80274. * @param axis The axis of rotation
  80275. * @param amount The amount of rotation
  80276. * @param space The space of the rotation
  80277. * @returns The rotation transform node
  80278. */
  80279. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80280. /**
  80281. * Translates the mesh
  80282. * @param axis The axis of translation
  80283. * @param distance The distance of translation
  80284. * @param space The space of the translation
  80285. * @returns The transform node
  80286. */
  80287. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80288. /**
  80289. * Sets the absolute position of the mesh
  80290. * @param absolutePosition The absolute position of the mesh
  80291. * @returns The transform node
  80292. */
  80293. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80294. /**
  80295. * Gets the class name of the mesh
  80296. * @returns The class name
  80297. */
  80298. getClassName(): string;
  80299. }
  80300. /**
  80301. * Represents a physics imposter
  80302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  80303. */
  80304. export class PhysicsImpostor {
  80305. /**
  80306. * The physics-enabled object used as the physics imposter
  80307. */
  80308. object: IPhysicsEnabledObject;
  80309. /**
  80310. * The type of the physics imposter
  80311. */
  80312. type: number;
  80313. private _options;
  80314. private _scene?;
  80315. /**
  80316. * The default object size of the imposter
  80317. */
  80318. static DEFAULT_OBJECT_SIZE: Vector3;
  80319. /**
  80320. * The identity quaternion of the imposter
  80321. */
  80322. static IDENTITY_QUATERNION: Quaternion;
  80323. /** @hidden */
  80324. _pluginData: any;
  80325. private _physicsEngine;
  80326. private _physicsBody;
  80327. private _bodyUpdateRequired;
  80328. private _onBeforePhysicsStepCallbacks;
  80329. private _onAfterPhysicsStepCallbacks;
  80330. /** @hidden */
  80331. _onPhysicsCollideCallbacks: Array<{
  80332. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  80333. otherImpostors: Array<PhysicsImpostor>;
  80334. }>;
  80335. private _deltaPosition;
  80336. private _deltaRotation;
  80337. private _deltaRotationConjugated;
  80338. /** hidden */
  80339. _isFromLine: boolean;
  80340. private _parent;
  80341. private _isDisposed;
  80342. private static _tmpVecs;
  80343. private static _tmpQuat;
  80344. /**
  80345. * Specifies if the physics imposter is disposed
  80346. */
  80347. readonly isDisposed: boolean;
  80348. /**
  80349. * Gets the mass of the physics imposter
  80350. */
  80351. mass: number;
  80352. /**
  80353. * Gets the coefficient of friction
  80354. */
  80355. /**
  80356. * Sets the coefficient of friction
  80357. */
  80358. friction: number;
  80359. /**
  80360. * Gets the coefficient of restitution
  80361. */
  80362. /**
  80363. * Sets the coefficient of restitution
  80364. */
  80365. restitution: number;
  80366. /**
  80367. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  80368. */
  80369. /**
  80370. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  80371. */
  80372. pressure: number;
  80373. /**
  80374. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80375. */
  80376. /**
  80377. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  80378. */
  80379. stiffness: number;
  80380. /**
  80381. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80382. */
  80383. /**
  80384. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  80385. */
  80386. velocityIterations: number;
  80387. /**
  80388. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80389. */
  80390. /**
  80391. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  80392. */
  80393. positionIterations: number;
  80394. /**
  80395. * The unique id of the physics imposter
  80396. * set by the physics engine when adding this impostor to the array
  80397. */
  80398. uniqueId: number;
  80399. /**
  80400. * @hidden
  80401. */
  80402. soft: boolean;
  80403. /**
  80404. * @hidden
  80405. */
  80406. segments: number;
  80407. private _joints;
  80408. /**
  80409. * Initializes the physics imposter
  80410. * @param object The physics-enabled object used as the physics imposter
  80411. * @param type The type of the physics imposter
  80412. * @param _options The options for the physics imposter
  80413. * @param _scene The Babylon scene
  80414. */
  80415. constructor(
  80416. /**
  80417. * The physics-enabled object used as the physics imposter
  80418. */
  80419. object: IPhysicsEnabledObject,
  80420. /**
  80421. * The type of the physics imposter
  80422. */
  80423. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  80424. /**
  80425. * This function will completly initialize this impostor.
  80426. * It will create a new body - but only if this mesh has no parent.
  80427. * If it has, this impostor will not be used other than to define the impostor
  80428. * of the child mesh.
  80429. * @hidden
  80430. */
  80431. _init(): void;
  80432. private _getPhysicsParent;
  80433. /**
  80434. * Should a new body be generated.
  80435. * @returns boolean specifying if body initialization is required
  80436. */
  80437. isBodyInitRequired(): boolean;
  80438. /**
  80439. * Sets the updated scaling
  80440. * @param updated Specifies if the scaling is updated
  80441. */
  80442. setScalingUpdated(): void;
  80443. /**
  80444. * Force a regeneration of this or the parent's impostor's body.
  80445. * Use under cautious - This will remove all joints already implemented.
  80446. */
  80447. forceUpdate(): void;
  80448. /**
  80449. * Gets the body that holds this impostor. Either its own, or its parent.
  80450. */
  80451. /**
  80452. * Set the physics body. Used mainly by the physics engine/plugin
  80453. */
  80454. physicsBody: any;
  80455. /**
  80456. * Get the parent of the physics imposter
  80457. * @returns Physics imposter or null
  80458. */
  80459. /**
  80460. * Sets the parent of the physics imposter
  80461. */
  80462. parent: Nullable<PhysicsImpostor>;
  80463. /**
  80464. * Resets the update flags
  80465. */
  80466. resetUpdateFlags(): void;
  80467. /**
  80468. * Gets the object extend size
  80469. * @returns the object extend size
  80470. */
  80471. getObjectExtendSize(): Vector3;
  80472. /**
  80473. * Gets the object center
  80474. * @returns The object center
  80475. */
  80476. getObjectCenter(): Vector3;
  80477. /**
  80478. * Get a specific parametes from the options parameter
  80479. * @param paramName The object parameter name
  80480. * @returns The object parameter
  80481. */
  80482. getParam(paramName: string): any;
  80483. /**
  80484. * Sets a specific parameter in the options given to the physics plugin
  80485. * @param paramName The parameter name
  80486. * @param value The value of the parameter
  80487. */
  80488. setParam(paramName: string, value: number): void;
  80489. /**
  80490. * Specifically change the body's mass option. Won't recreate the physics body object
  80491. * @param mass The mass of the physics imposter
  80492. */
  80493. setMass(mass: number): void;
  80494. /**
  80495. * Gets the linear velocity
  80496. * @returns linear velocity or null
  80497. */
  80498. getLinearVelocity(): Nullable<Vector3>;
  80499. /**
  80500. * Sets the linear velocity
  80501. * @param velocity linear velocity or null
  80502. */
  80503. setLinearVelocity(velocity: Nullable<Vector3>): void;
  80504. /**
  80505. * Gets the angular velocity
  80506. * @returns angular velocity or null
  80507. */
  80508. getAngularVelocity(): Nullable<Vector3>;
  80509. /**
  80510. * Sets the angular velocity
  80511. * @param velocity The velocity or null
  80512. */
  80513. setAngularVelocity(velocity: Nullable<Vector3>): void;
  80514. /**
  80515. * Execute a function with the physics plugin native code
  80516. * Provide a function the will have two variables - the world object and the physics body object
  80517. * @param func The function to execute with the physics plugin native code
  80518. */
  80519. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  80520. /**
  80521. * Register a function that will be executed before the physics world is stepping forward
  80522. * @param func The function to execute before the physics world is stepped forward
  80523. */
  80524. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80525. /**
  80526. * Unregister a function that will be executed before the physics world is stepping forward
  80527. * @param func The function to execute before the physics world is stepped forward
  80528. */
  80529. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80530. /**
  80531. * Register a function that will be executed after the physics step
  80532. * @param func The function to execute after physics step
  80533. */
  80534. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80535. /**
  80536. * Unregisters a function that will be executed after the physics step
  80537. * @param func The function to execute after physics step
  80538. */
  80539. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  80540. /**
  80541. * register a function that will be executed when this impostor collides against a different body
  80542. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  80543. * @param func Callback that is executed on collision
  80544. */
  80545. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  80546. /**
  80547. * Unregisters the physics imposter on contact
  80548. * @param collideAgainst The physics object to collide against
  80549. * @param func Callback to execute on collision
  80550. */
  80551. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  80552. private _tmpQuat;
  80553. private _tmpQuat2;
  80554. /**
  80555. * Get the parent rotation
  80556. * @returns The parent rotation
  80557. */
  80558. getParentsRotation(): Quaternion;
  80559. /**
  80560. * this function is executed by the physics engine.
  80561. */
  80562. beforeStep: () => void;
  80563. /**
  80564. * this function is executed by the physics engine
  80565. */
  80566. afterStep: () => void;
  80567. /**
  80568. * Legacy collision detection event support
  80569. */
  80570. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  80571. /**
  80572. * event and body object due to cannon's event-based architecture.
  80573. */
  80574. onCollide: (e: {
  80575. body: any;
  80576. }) => void;
  80577. /**
  80578. * Apply a force
  80579. * @param force The force to apply
  80580. * @param contactPoint The contact point for the force
  80581. * @returns The physics imposter
  80582. */
  80583. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80584. /**
  80585. * Apply an impulse
  80586. * @param force The impulse force
  80587. * @param contactPoint The contact point for the impulse force
  80588. * @returns The physics imposter
  80589. */
  80590. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  80591. /**
  80592. * A help function to create a joint
  80593. * @param otherImpostor A physics imposter used to create a joint
  80594. * @param jointType The type of joint
  80595. * @param jointData The data for the joint
  80596. * @returns The physics imposter
  80597. */
  80598. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  80599. /**
  80600. * Add a joint to this impostor with a different impostor
  80601. * @param otherImpostor A physics imposter used to add a joint
  80602. * @param joint The joint to add
  80603. * @returns The physics imposter
  80604. */
  80605. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  80606. /**
  80607. * Add an anchor to a cloth impostor
  80608. * @param otherImpostor rigid impostor to anchor to
  80609. * @param width ratio across width from 0 to 1
  80610. * @param height ratio up height from 0 to 1
  80611. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  80612. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  80613. * @returns impostor the soft imposter
  80614. */
  80615. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80616. /**
  80617. * Add a hook to a rope impostor
  80618. * @param otherImpostor rigid impostor to anchor to
  80619. * @param length ratio across rope from 0 to 1
  80620. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  80621. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  80622. * @returns impostor the rope imposter
  80623. */
  80624. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  80625. /**
  80626. * Will keep this body still, in a sleep mode.
  80627. * @returns the physics imposter
  80628. */
  80629. sleep(): PhysicsImpostor;
  80630. /**
  80631. * Wake the body up.
  80632. * @returns The physics imposter
  80633. */
  80634. wakeUp(): PhysicsImpostor;
  80635. /**
  80636. * Clones the physics imposter
  80637. * @param newObject The physics imposter clones to this physics-enabled object
  80638. * @returns A nullable physics imposter
  80639. */
  80640. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  80641. /**
  80642. * Disposes the physics imposter
  80643. */
  80644. dispose(): void;
  80645. /**
  80646. * Sets the delta position
  80647. * @param position The delta position amount
  80648. */
  80649. setDeltaPosition(position: Vector3): void;
  80650. /**
  80651. * Sets the delta rotation
  80652. * @param rotation The delta rotation amount
  80653. */
  80654. setDeltaRotation(rotation: Quaternion): void;
  80655. /**
  80656. * Gets the box size of the physics imposter and stores the result in the input parameter
  80657. * @param result Stores the box size
  80658. * @returns The physics imposter
  80659. */
  80660. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80661. /**
  80662. * Gets the radius of the physics imposter
  80663. * @returns Radius of the physics imposter
  80664. */
  80665. getRadius(): number;
  80666. /**
  80667. * Sync a bone with this impostor
  80668. * @param bone The bone to sync to the impostor.
  80669. * @param boneMesh The mesh that the bone is influencing.
  80670. * @param jointPivot The pivot of the joint / bone in local space.
  80671. * @param distToJoint Optional distance from the impostor to the joint.
  80672. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80673. */
  80674. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80675. /**
  80676. * Sync impostor to a bone
  80677. * @param bone The bone that the impostor will be synced to.
  80678. * @param boneMesh The mesh that the bone is influencing.
  80679. * @param jointPivot The pivot of the joint / bone in local space.
  80680. * @param distToJoint Optional distance from the impostor to the joint.
  80681. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80682. * @param boneAxis Optional vector3 axis the bone is aligned with
  80683. */
  80684. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80685. /**
  80686. * No-Imposter type
  80687. */
  80688. static NoImpostor: number;
  80689. /**
  80690. * Sphere-Imposter type
  80691. */
  80692. static SphereImpostor: number;
  80693. /**
  80694. * Box-Imposter type
  80695. */
  80696. static BoxImpostor: number;
  80697. /**
  80698. * Plane-Imposter type
  80699. */
  80700. static PlaneImpostor: number;
  80701. /**
  80702. * Mesh-imposter type
  80703. */
  80704. static MeshImpostor: number;
  80705. /**
  80706. * Cylinder-Imposter type
  80707. */
  80708. static CylinderImpostor: number;
  80709. /**
  80710. * Particle-Imposter type
  80711. */
  80712. static ParticleImpostor: number;
  80713. /**
  80714. * Heightmap-Imposter type
  80715. */
  80716. static HeightmapImpostor: number;
  80717. /**
  80718. * ConvexHull-Impostor type (Ammo.js plugin only)
  80719. */
  80720. static ConvexHullImpostor: number;
  80721. /**
  80722. * Rope-Imposter type
  80723. */
  80724. static RopeImpostor: number;
  80725. /**
  80726. * Cloth-Imposter type
  80727. */
  80728. static ClothImpostor: number;
  80729. /**
  80730. * Softbody-Imposter type
  80731. */
  80732. static SoftbodyImpostor: number;
  80733. }
  80734. }
  80735. declare module BABYLON {
  80736. /**
  80737. * @hidden
  80738. **/
  80739. export class _CreationDataStorage {
  80740. closePath?: boolean;
  80741. closeArray?: boolean;
  80742. idx: number[];
  80743. dashSize: number;
  80744. gapSize: number;
  80745. path3D: Path3D;
  80746. pathArray: Vector3[][];
  80747. arc: number;
  80748. radius: number;
  80749. cap: number;
  80750. tessellation: number;
  80751. }
  80752. /**
  80753. * @hidden
  80754. **/
  80755. class _InstanceDataStorage {
  80756. visibleInstances: any;
  80757. batchCache: _InstancesBatch;
  80758. instancesBufferSize: number;
  80759. instancesBuffer: Nullable<Buffer>;
  80760. instancesData: Float32Array;
  80761. overridenInstanceCount: number;
  80762. isFrozen: boolean;
  80763. previousBatch: _InstancesBatch;
  80764. hardwareInstancedRendering: boolean;
  80765. sideOrientation: number;
  80766. }
  80767. /**
  80768. * @hidden
  80769. **/
  80770. export class _InstancesBatch {
  80771. mustReturn: boolean;
  80772. visibleInstances: Nullable<InstancedMesh[]>[];
  80773. renderSelf: boolean[];
  80774. hardwareInstancedRendering: boolean[];
  80775. }
  80776. /**
  80777. * Class used to represent renderable models
  80778. */
  80779. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80780. /**
  80781. * Mesh side orientation : usually the external or front surface
  80782. */
  80783. static readonly FRONTSIDE: number;
  80784. /**
  80785. * Mesh side orientation : usually the internal or back surface
  80786. */
  80787. static readonly BACKSIDE: number;
  80788. /**
  80789. * Mesh side orientation : both internal and external or front and back surfaces
  80790. */
  80791. static readonly DOUBLESIDE: number;
  80792. /**
  80793. * Mesh side orientation : by default, `FRONTSIDE`
  80794. */
  80795. static readonly DEFAULTSIDE: number;
  80796. /**
  80797. * Mesh cap setting : no cap
  80798. */
  80799. static readonly NO_CAP: number;
  80800. /**
  80801. * Mesh cap setting : one cap at the beginning of the mesh
  80802. */
  80803. static readonly CAP_START: number;
  80804. /**
  80805. * Mesh cap setting : one cap at the end of the mesh
  80806. */
  80807. static readonly CAP_END: number;
  80808. /**
  80809. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80810. */
  80811. static readonly CAP_ALL: number;
  80812. /**
  80813. * Gets the default side orientation.
  80814. * @param orientation the orientation to value to attempt to get
  80815. * @returns the default orientation
  80816. * @hidden
  80817. */
  80818. static _GetDefaultSideOrientation(orientation?: number): number;
  80819. private _onBeforeRenderObservable;
  80820. private _onBeforeBindObservable;
  80821. private _onAfterRenderObservable;
  80822. private _onBeforeDrawObservable;
  80823. /**
  80824. * An event triggered before rendering the mesh
  80825. */
  80826. readonly onBeforeRenderObservable: Observable<Mesh>;
  80827. /**
  80828. * An event triggered before binding the mesh
  80829. */
  80830. readonly onBeforeBindObservable: Observable<Mesh>;
  80831. /**
  80832. * An event triggered after rendering the mesh
  80833. */
  80834. readonly onAfterRenderObservable: Observable<Mesh>;
  80835. /**
  80836. * An event triggered before drawing the mesh
  80837. */
  80838. readonly onBeforeDrawObservable: Observable<Mesh>;
  80839. private _onBeforeDrawObserver;
  80840. /**
  80841. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80842. */
  80843. onBeforeDraw: () => void;
  80844. /**
  80845. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80846. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80847. */
  80848. delayLoadState: number;
  80849. /**
  80850. * Gets the list of instances created from this mesh
  80851. * it is not supposed to be modified manually.
  80852. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80853. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80854. */
  80855. instances: InstancedMesh[];
  80856. /**
  80857. * Gets the file containing delay loading data for this mesh
  80858. */
  80859. delayLoadingFile: string;
  80860. /** @hidden */
  80861. _binaryInfo: any;
  80862. private _LODLevels;
  80863. /**
  80864. * User defined function used to change how LOD level selection is done
  80865. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80866. */
  80867. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80868. private _morphTargetManager;
  80869. /**
  80870. * Gets or sets the morph target manager
  80871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80872. */
  80873. morphTargetManager: Nullable<MorphTargetManager>;
  80874. /** @hidden */
  80875. _creationDataStorage: Nullable<_CreationDataStorage>;
  80876. /** @hidden */
  80877. _geometry: Nullable<Geometry>;
  80878. /** @hidden */
  80879. _delayInfo: Array<string>;
  80880. /** @hidden */
  80881. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80882. /** @hidden */
  80883. _instanceDataStorage: _InstanceDataStorage;
  80884. private _effectiveMaterial;
  80885. /** @hidden */
  80886. _shouldGenerateFlatShading: boolean;
  80887. private _preActivateId;
  80888. /** @hidden */
  80889. _originalBuilderSideOrientation: number;
  80890. /**
  80891. * Use this property to change the original side orientation defined at construction time
  80892. */
  80893. overrideMaterialSideOrientation: Nullable<number>;
  80894. private _areNormalsFrozen;
  80895. private _sourcePositions;
  80896. private _sourceNormals;
  80897. private _source;
  80898. private meshMap;
  80899. /**
  80900. * Gets the source mesh (the one used to clone this one from)
  80901. */
  80902. readonly source: Nullable<Mesh>;
  80903. /**
  80904. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80905. */
  80906. isUnIndexed: boolean;
  80907. /**
  80908. * @constructor
  80909. * @param name The value used by scene.getMeshByName() to do a lookup.
  80910. * @param scene The scene to add this mesh to.
  80911. * @param parent The parent of this mesh, if it has one
  80912. * @param source An optional Mesh from which geometry is shared, cloned.
  80913. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80914. * When false, achieved by calling a clone(), also passing False.
  80915. * This will make creation of children, recursive.
  80916. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80917. */
  80918. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80919. /**
  80920. * Gets the class name
  80921. * @returns the string "Mesh".
  80922. */
  80923. getClassName(): string;
  80924. /** @hidden */
  80925. readonly _isMesh: boolean;
  80926. /**
  80927. * Returns a description of this mesh
  80928. * @param fullDetails define if full details about this mesh must be used
  80929. * @returns a descriptive string representing this mesh
  80930. */
  80931. toString(fullDetails?: boolean): string;
  80932. /** @hidden */
  80933. _unBindEffect(): void;
  80934. /**
  80935. * Gets a boolean indicating if this mesh has LOD
  80936. */
  80937. readonly hasLODLevels: boolean;
  80938. /**
  80939. * Gets the list of MeshLODLevel associated with the current mesh
  80940. * @returns an array of MeshLODLevel
  80941. */
  80942. getLODLevels(): MeshLODLevel[];
  80943. private _sortLODLevels;
  80944. /**
  80945. * Add a mesh as LOD level triggered at the given distance.
  80946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80947. * @param distance The distance from the center of the object to show this level
  80948. * @param mesh The mesh to be added as LOD level (can be null)
  80949. * @return This mesh (for chaining)
  80950. */
  80951. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80952. /**
  80953. * Returns the LOD level mesh at the passed distance or null if not found.
  80954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80955. * @param distance The distance from the center of the object to show this level
  80956. * @returns a Mesh or `null`
  80957. */
  80958. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80959. /**
  80960. * Remove a mesh from the LOD array
  80961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80962. * @param mesh defines the mesh to be removed
  80963. * @return This mesh (for chaining)
  80964. */
  80965. removeLODLevel(mesh: Mesh): Mesh;
  80966. /**
  80967. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80968. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80969. * @param camera defines the camera to use to compute distance
  80970. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80971. * @return This mesh (for chaining)
  80972. */
  80973. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80974. /**
  80975. * Gets the mesh internal Geometry object
  80976. */
  80977. readonly geometry: Nullable<Geometry>;
  80978. /**
  80979. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80980. * @returns the total number of vertices
  80981. */
  80982. getTotalVertices(): number;
  80983. /**
  80984. * Returns the content of an associated vertex buffer
  80985. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80986. * - VertexBuffer.PositionKind
  80987. * - VertexBuffer.UVKind
  80988. * - VertexBuffer.UV2Kind
  80989. * - VertexBuffer.UV3Kind
  80990. * - VertexBuffer.UV4Kind
  80991. * - VertexBuffer.UV5Kind
  80992. * - VertexBuffer.UV6Kind
  80993. * - VertexBuffer.ColorKind
  80994. * - VertexBuffer.MatricesIndicesKind
  80995. * - VertexBuffer.MatricesIndicesExtraKind
  80996. * - VertexBuffer.MatricesWeightsKind
  80997. * - VertexBuffer.MatricesWeightsExtraKind
  80998. * @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
  80999. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  81000. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  81001. */
  81002. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81003. /**
  81004. * Returns the mesh VertexBuffer object from the requested `kind`
  81005. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81006. * - VertexBuffer.PositionKind
  81007. * - VertexBuffer.UVKind
  81008. * - VertexBuffer.UV2Kind
  81009. * - VertexBuffer.UV3Kind
  81010. * - VertexBuffer.UV4Kind
  81011. * - VertexBuffer.UV5Kind
  81012. * - VertexBuffer.UV6Kind
  81013. * - VertexBuffer.ColorKind
  81014. * - VertexBuffer.MatricesIndicesKind
  81015. * - VertexBuffer.MatricesIndicesExtraKind
  81016. * - VertexBuffer.MatricesWeightsKind
  81017. * - VertexBuffer.MatricesWeightsExtraKind
  81018. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  81019. */
  81020. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81021. /**
  81022. * Tests if a specific vertex buffer is associated with this mesh
  81023. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81024. * - VertexBuffer.PositionKind
  81025. * - VertexBuffer.UVKind
  81026. * - VertexBuffer.UV2Kind
  81027. * - VertexBuffer.UV3Kind
  81028. * - VertexBuffer.UV4Kind
  81029. * - VertexBuffer.UV5Kind
  81030. * - VertexBuffer.UV6Kind
  81031. * - VertexBuffer.ColorKind
  81032. * - VertexBuffer.MatricesIndicesKind
  81033. * - VertexBuffer.MatricesIndicesExtraKind
  81034. * - VertexBuffer.MatricesWeightsKind
  81035. * - VertexBuffer.MatricesWeightsExtraKind
  81036. * @returns a boolean
  81037. */
  81038. isVerticesDataPresent(kind: string): boolean;
  81039. /**
  81040. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  81041. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  81042. * - VertexBuffer.PositionKind
  81043. * - VertexBuffer.UVKind
  81044. * - VertexBuffer.UV2Kind
  81045. * - VertexBuffer.UV3Kind
  81046. * - VertexBuffer.UV4Kind
  81047. * - VertexBuffer.UV5Kind
  81048. * - VertexBuffer.UV6Kind
  81049. * - VertexBuffer.ColorKind
  81050. * - VertexBuffer.MatricesIndicesKind
  81051. * - VertexBuffer.MatricesIndicesExtraKind
  81052. * - VertexBuffer.MatricesWeightsKind
  81053. * - VertexBuffer.MatricesWeightsExtraKind
  81054. * @returns a boolean
  81055. */
  81056. isVertexBufferUpdatable(kind: string): boolean;
  81057. /**
  81058. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  81059. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  81060. * - VertexBuffer.PositionKind
  81061. * - VertexBuffer.UVKind
  81062. * - VertexBuffer.UV2Kind
  81063. * - VertexBuffer.UV3Kind
  81064. * - VertexBuffer.UV4Kind
  81065. * - VertexBuffer.UV5Kind
  81066. * - VertexBuffer.UV6Kind
  81067. * - VertexBuffer.ColorKind
  81068. * - VertexBuffer.MatricesIndicesKind
  81069. * - VertexBuffer.MatricesIndicesExtraKind
  81070. * - VertexBuffer.MatricesWeightsKind
  81071. * - VertexBuffer.MatricesWeightsExtraKind
  81072. * @returns an array of strings
  81073. */
  81074. getVerticesDataKinds(): string[];
  81075. /**
  81076. * Returns a positive integer : the total number of indices in this mesh geometry.
  81077. * @returns the numner of indices or zero if the mesh has no geometry.
  81078. */
  81079. getTotalIndices(): number;
  81080. /**
  81081. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81082. * @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.
  81083. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81084. * @returns the indices array or an empty array if the mesh has no geometry
  81085. */
  81086. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81087. readonly isBlocked: boolean;
  81088. /**
  81089. * Determine if the current mesh is ready to be rendered
  81090. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81091. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  81092. * @returns true if all associated assets are ready (material, textures, shaders)
  81093. */
  81094. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  81095. /**
  81096. * 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.
  81097. */
  81098. readonly areNormalsFrozen: boolean;
  81099. /**
  81100. * 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.
  81101. * @returns the current mesh
  81102. */
  81103. freezeNormals(): Mesh;
  81104. /**
  81105. * 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
  81106. * @returns the current mesh
  81107. */
  81108. unfreezeNormals(): Mesh;
  81109. /**
  81110. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  81111. */
  81112. overridenInstanceCount: number;
  81113. /** @hidden */
  81114. _preActivate(): Mesh;
  81115. /** @hidden */
  81116. _preActivateForIntermediateRendering(renderId: number): Mesh;
  81117. /** @hidden */
  81118. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  81119. /**
  81120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81121. * This means the mesh underlying bounding box and sphere are recomputed.
  81122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81123. * @returns the current mesh
  81124. */
  81125. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  81126. /** @hidden */
  81127. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  81128. /**
  81129. * This function will subdivide the mesh into multiple submeshes
  81130. * @param count defines the expected number of submeshes
  81131. */
  81132. subdivide(count: number): void;
  81133. /**
  81134. * Copy a FloatArray into a specific associated vertex buffer
  81135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81136. * - VertexBuffer.PositionKind
  81137. * - VertexBuffer.UVKind
  81138. * - VertexBuffer.UV2Kind
  81139. * - VertexBuffer.UV3Kind
  81140. * - VertexBuffer.UV4Kind
  81141. * - VertexBuffer.UV5Kind
  81142. * - VertexBuffer.UV6Kind
  81143. * - VertexBuffer.ColorKind
  81144. * - VertexBuffer.MatricesIndicesKind
  81145. * - VertexBuffer.MatricesIndicesExtraKind
  81146. * - VertexBuffer.MatricesWeightsKind
  81147. * - VertexBuffer.MatricesWeightsExtraKind
  81148. * @param data defines the data source
  81149. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81150. * @param stride defines the data stride size (can be null)
  81151. * @returns the current mesh
  81152. */
  81153. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81154. /**
  81155. * Flags an associated vertex buffer as updatable
  81156. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  81157. * - VertexBuffer.PositionKind
  81158. * - VertexBuffer.UVKind
  81159. * - VertexBuffer.UV2Kind
  81160. * - VertexBuffer.UV3Kind
  81161. * - VertexBuffer.UV4Kind
  81162. * - VertexBuffer.UV5Kind
  81163. * - VertexBuffer.UV6Kind
  81164. * - VertexBuffer.ColorKind
  81165. * - VertexBuffer.MatricesIndicesKind
  81166. * - VertexBuffer.MatricesIndicesExtraKind
  81167. * - VertexBuffer.MatricesWeightsKind
  81168. * - VertexBuffer.MatricesWeightsExtraKind
  81169. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  81170. */
  81171. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  81172. /**
  81173. * Sets the mesh global Vertex Buffer
  81174. * @param buffer defines the buffer to use
  81175. * @returns the current mesh
  81176. */
  81177. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  81178. /**
  81179. * Update a specific associated vertex buffer
  81180. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81181. * - VertexBuffer.PositionKind
  81182. * - VertexBuffer.UVKind
  81183. * - VertexBuffer.UV2Kind
  81184. * - VertexBuffer.UV3Kind
  81185. * - VertexBuffer.UV4Kind
  81186. * - VertexBuffer.UV5Kind
  81187. * - VertexBuffer.UV6Kind
  81188. * - VertexBuffer.ColorKind
  81189. * - VertexBuffer.MatricesIndicesKind
  81190. * - VertexBuffer.MatricesIndicesExtraKind
  81191. * - VertexBuffer.MatricesWeightsKind
  81192. * - VertexBuffer.MatricesWeightsExtraKind
  81193. * @param data defines the data source
  81194. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81195. * @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)
  81196. * @returns the current mesh
  81197. */
  81198. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81199. /**
  81200. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  81201. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  81202. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  81203. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  81204. * @returns the current mesh
  81205. */
  81206. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  81207. /**
  81208. * Creates a un-shared specific occurence of the geometry for the mesh.
  81209. * @returns the current mesh
  81210. */
  81211. makeGeometryUnique(): Mesh;
  81212. /**
  81213. * Set the index buffer of this mesh
  81214. * @param indices defines the source data
  81215. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  81216. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  81217. * @returns the current mesh
  81218. */
  81219. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  81220. /**
  81221. * Update the current index buffer
  81222. * @param indices defines the source data
  81223. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81224. * @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)
  81225. * @returns the current mesh
  81226. */
  81227. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  81228. /**
  81229. * Invert the geometry to move from a right handed system to a left handed one.
  81230. * @returns the current mesh
  81231. */
  81232. toLeftHanded(): Mesh;
  81233. /** @hidden */
  81234. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  81235. /** @hidden */
  81236. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  81237. /**
  81238. * Registers for this mesh a javascript function called just before the rendering process
  81239. * @param func defines the function to call before rendering this mesh
  81240. * @returns the current mesh
  81241. */
  81242. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81243. /**
  81244. * Disposes a previously registered javascript function called before the rendering
  81245. * @param func defines the function to remove
  81246. * @returns the current mesh
  81247. */
  81248. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  81249. /**
  81250. * Registers for this mesh a javascript function called just after the rendering is complete
  81251. * @param func defines the function to call after rendering this mesh
  81252. * @returns the current mesh
  81253. */
  81254. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81255. /**
  81256. * Disposes a previously registered javascript function called after the rendering.
  81257. * @param func defines the function to remove
  81258. * @returns the current mesh
  81259. */
  81260. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  81261. /** @hidden */
  81262. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  81263. /** @hidden */
  81264. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  81265. /** @hidden */
  81266. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  81267. /** @hidden */
  81268. _freeze(): void;
  81269. /** @hidden */
  81270. _unFreeze(): void;
  81271. /**
  81272. * 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
  81273. * @param subMesh defines the subMesh to render
  81274. * @param enableAlphaMode defines if alpha mode can be changed
  81275. * @returns the current mesh
  81276. */
  81277. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  81278. private _onBeforeDraw;
  81279. /**
  81280. * Renormalize the mesh and patch it up if there are no weights
  81281. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  81282. * However in the case of zero weights then we set just a single influence to 1.
  81283. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  81284. */
  81285. cleanMatrixWeights(): void;
  81286. private normalizeSkinFourWeights;
  81287. private normalizeSkinWeightsAndExtra;
  81288. /**
  81289. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  81290. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  81291. * the user know there was an issue with importing the mesh
  81292. * @returns a validation object with skinned, valid and report string
  81293. */
  81294. validateSkinning(): {
  81295. skinned: boolean;
  81296. valid: boolean;
  81297. report: string;
  81298. };
  81299. /** @hidden */
  81300. _checkDelayState(): Mesh;
  81301. private _queueLoad;
  81302. /**
  81303. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81304. * A mesh is in the frustum if its bounding box intersects the frustum
  81305. * @param frustumPlanes defines the frustum to test
  81306. * @returns true if the mesh is in the frustum planes
  81307. */
  81308. isInFrustum(frustumPlanes: Plane[]): boolean;
  81309. /**
  81310. * Sets the mesh material by the material or multiMaterial `id` property
  81311. * @param id is a string identifying the material or the multiMaterial
  81312. * @returns the current mesh
  81313. */
  81314. setMaterialByID(id: string): Mesh;
  81315. /**
  81316. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  81317. * @returns an array of IAnimatable
  81318. */
  81319. getAnimatables(): IAnimatable[];
  81320. /**
  81321. * Modifies the mesh geometry according to the passed transformation matrix.
  81322. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  81323. * The mesh normals are modified using the same transformation.
  81324. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81325. * @param transform defines the transform matrix to use
  81326. * @see http://doc.babylonjs.com/resources/baking_transformations
  81327. * @returns the current mesh
  81328. */
  81329. bakeTransformIntoVertices(transform: Matrix): Mesh;
  81330. /**
  81331. * Modifies the mesh geometry according to its own current World Matrix.
  81332. * The mesh World Matrix is then reset.
  81333. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  81334. * Note that, under the hood, this method sets a new VertexBuffer each call.
  81335. * @see http://doc.babylonjs.com/resources/baking_transformations
  81336. * @returns the current mesh
  81337. */
  81338. bakeCurrentTransformIntoVertices(): Mesh;
  81339. /** @hidden */
  81340. readonly _positions: Nullable<Vector3[]>;
  81341. /** @hidden */
  81342. _resetPointsArrayCache(): Mesh;
  81343. /** @hidden */
  81344. _generatePointsArray(): boolean;
  81345. /**
  81346. * Returns a new Mesh object generated from the current mesh properties.
  81347. * This method must not get confused with createInstance()
  81348. * @param name is a string, the name given to the new mesh
  81349. * @param newParent can be any Node object (default `null`)
  81350. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  81351. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  81352. * @returns a new mesh
  81353. */
  81354. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  81355. /**
  81356. * Releases resources associated with this mesh.
  81357. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81358. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81359. */
  81360. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81361. /**
  81362. * Modifies the mesh geometry according to a displacement map.
  81363. * 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.
  81364. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81365. * @param url is a string, the URL from the image file is to be downloaded.
  81366. * @param minHeight is the lower limit of the displacement.
  81367. * @param maxHeight is the upper limit of the displacement.
  81368. * @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.
  81369. * @param uvOffset is an optional vector2 used to offset UV.
  81370. * @param uvScale is an optional vector2 used to scale UV.
  81371. * @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.
  81372. * @returns the Mesh.
  81373. */
  81374. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81375. /**
  81376. * Modifies the mesh geometry according to a displacementMap buffer.
  81377. * 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.
  81378. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  81379. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  81380. * @param heightMapWidth is the width of the buffer image.
  81381. * @param heightMapHeight is the height of the buffer image.
  81382. * @param minHeight is the lower limit of the displacement.
  81383. * @param maxHeight is the upper limit of the displacement.
  81384. * @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.
  81385. * @param uvOffset is an optional vector2 used to offset UV.
  81386. * @param uvScale is an optional vector2 used to scale UV.
  81387. * @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.
  81388. * @returns the Mesh.
  81389. */
  81390. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  81391. /**
  81392. * Modify the mesh to get a flat shading rendering.
  81393. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  81394. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  81395. * @returns current mesh
  81396. */
  81397. convertToFlatShadedMesh(): Mesh;
  81398. /**
  81399. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  81400. * In other words, more vertices, no more indices and a single bigger VBO.
  81401. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  81402. * @returns current mesh
  81403. */
  81404. convertToUnIndexedMesh(): Mesh;
  81405. /**
  81406. * Inverses facet orientations.
  81407. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81408. * @param flipNormals will also inverts the normals
  81409. * @returns current mesh
  81410. */
  81411. flipFaces(flipNormals?: boolean): Mesh;
  81412. /**
  81413. * Increase the number of facets and hence vertices in a mesh
  81414. * Vertex normals are interpolated from existing vertex normals
  81415. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81416. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  81417. */
  81418. increaseVertices(numberPerEdge: number): void;
  81419. /**
  81420. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  81421. * This will undo any application of covertToFlatShadedMesh
  81422. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  81423. */
  81424. forceSharedVertices(): void;
  81425. /** @hidden */
  81426. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  81427. /** @hidden */
  81428. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  81429. /**
  81430. * Creates a new InstancedMesh object from the mesh model.
  81431. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  81432. * @param name defines the name of the new instance
  81433. * @returns a new InstancedMesh
  81434. */
  81435. createInstance(name: string): InstancedMesh;
  81436. /**
  81437. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  81438. * After this call, all the mesh instances have the same submeshes than the current mesh.
  81439. * @returns the current mesh
  81440. */
  81441. synchronizeInstances(): Mesh;
  81442. /**
  81443. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  81444. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  81445. * This should be used together with the simplification to avoid disappearing triangles.
  81446. * @param successCallback an optional success callback to be called after the optimization finished.
  81447. * @returns the current mesh
  81448. */
  81449. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  81450. /**
  81451. * Serialize current mesh
  81452. * @param serializationObject defines the object which will receive the serialization data
  81453. */
  81454. serialize(serializationObject: any): void;
  81455. /** @hidden */
  81456. _syncGeometryWithMorphTargetManager(): void;
  81457. /** @hidden */
  81458. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  81459. /**
  81460. * Returns a new Mesh object parsed from the source provided.
  81461. * @param parsedMesh is the source
  81462. * @param scene defines the hosting scene
  81463. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  81464. * @returns a new Mesh
  81465. */
  81466. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  81467. /**
  81468. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  81469. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81470. * @param name defines the name of the mesh to create
  81471. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  81472. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  81473. * @param closePath creates a seam between the first and the last points of each path of the path array
  81474. * @param offset is taken in account only if the `pathArray` is containing a single path
  81475. * @param scene defines the hosting scene
  81476. * @param updatable defines if the mesh must be flagged as updatable
  81477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81478. * @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)
  81479. * @returns a new Mesh
  81480. */
  81481. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81482. /**
  81483. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  81484. * @param name defines the name of the mesh to create
  81485. * @param radius sets the radius size (float) of the polygon (default 0.5)
  81486. * @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
  81487. * @param scene defines the hosting scene
  81488. * @param updatable defines if the mesh must be flagged as updatable
  81489. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81490. * @returns a new Mesh
  81491. */
  81492. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81493. /**
  81494. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  81495. * @param name defines the name of the mesh to create
  81496. * @param size sets the size (float) of each box side (default 1)
  81497. * @param scene defines the hosting scene
  81498. * @param updatable defines if the mesh must be flagged as updatable
  81499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81500. * @returns a new Mesh
  81501. */
  81502. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  81503. /**
  81504. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  81505. * @param name defines the name of the mesh to create
  81506. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81507. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81508. * @param scene defines the hosting scene
  81509. * @param updatable defines if the mesh must be flagged as updatable
  81510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81511. * @returns a new Mesh
  81512. */
  81513. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81514. /**
  81515. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  81516. * @param name defines the name of the mesh to create
  81517. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  81518. * @param diameter sets the diameter size (float) of the sphere (default 1)
  81519. * @param scene defines the hosting scene
  81520. * @returns a new Mesh
  81521. */
  81522. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  81523. /**
  81524. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  81525. * @param name defines the name of the mesh to create
  81526. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  81527. * @param diameterTop set the top cap diameter (floats, default 1)
  81528. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  81529. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  81530. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  81531. * @param scene defines the hosting scene
  81532. * @param updatable defines if the mesh must be flagged as updatable
  81533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81534. * @returns a new Mesh
  81535. */
  81536. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  81537. /**
  81538. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  81539. * @param name defines the name of the mesh to create
  81540. * @param diameter sets the diameter size (float) of the torus (default 1)
  81541. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  81542. * @param tessellation sets the number of torus sides (postive integer, default 16)
  81543. * @param scene defines the hosting scene
  81544. * @param updatable defines if the mesh must be flagged as updatable
  81545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81546. * @returns a new Mesh
  81547. */
  81548. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81549. /**
  81550. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  81551. * @param name defines the name of the mesh to create
  81552. * @param radius sets the global radius size (float) of the torus knot (default 2)
  81553. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  81554. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  81555. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  81556. * @param p the number of windings on X axis (positive integers, default 2)
  81557. * @param q the number of windings on Y axis (positive integers, default 3)
  81558. * @param scene defines the hosting scene
  81559. * @param updatable defines if the mesh must be flagged as updatable
  81560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81561. * @returns a new Mesh
  81562. */
  81563. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81564. /**
  81565. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  81566. * @param name defines the name of the mesh to create
  81567. * @param points is an array successive Vector3
  81568. * @param scene defines the hosting scene
  81569. * @param updatable defines if the mesh must be flagged as updatable
  81570. * @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).
  81571. * @returns a new Mesh
  81572. */
  81573. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  81574. /**
  81575. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  81576. * @param name defines the name of the mesh to create
  81577. * @param points is an array successive Vector3
  81578. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  81579. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  81580. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  81581. * @param scene defines the hosting scene
  81582. * @param updatable defines if the mesh must be flagged as updatable
  81583. * @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)
  81584. * @returns a new Mesh
  81585. */
  81586. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  81587. /**
  81588. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  81589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  81590. * 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.
  81591. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81592. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81593. * Remember you can only change the shape positions, not their number when updating a polygon.
  81594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  81595. * @param name defines the name of the mesh to create
  81596. * @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
  81597. * @param scene defines the hosting scene
  81598. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81599. * @param updatable defines if the mesh must be flagged as updatable
  81600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81601. * @param earcutInjection can be used to inject your own earcut reference
  81602. * @returns a new Mesh
  81603. */
  81604. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81605. /**
  81606. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  81607. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  81608. * @param name defines the name of the mesh to create
  81609. * @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
  81610. * @param depth defines the height of extrusion
  81611. * @param scene defines the hosting scene
  81612. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  81613. * @param updatable defines if the mesh must be flagged as updatable
  81614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81615. * @param earcutInjection can be used to inject your own earcut reference
  81616. * @returns a new Mesh
  81617. */
  81618. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  81619. /**
  81620. * Creates an extruded shape mesh.
  81621. * 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
  81622. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81624. * @param name defines the name of the mesh to create
  81625. * @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
  81626. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81627. * @param scale is the value to scale the shape
  81628. * @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
  81629. * @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
  81630. * @param scene defines the hosting scene
  81631. * @param updatable defines if the mesh must be flagged as updatable
  81632. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81633. * @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)
  81634. * @returns a new Mesh
  81635. */
  81636. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81637. /**
  81638. * Creates an custom extruded shape mesh.
  81639. * The custom extrusion is a parametric shape.
  81640. * It has no predefined shape. Its final shape will depend on the input parameters.
  81641. * Please consider using the same method from the MeshBuilder class instead
  81642. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81643. * @param name defines the name of the mesh to create
  81644. * @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
  81645. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81646. * @param scaleFunction is a custom Javascript function called on each path point
  81647. * @param rotationFunction is a custom Javascript function called on each path point
  81648. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81649. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81650. * @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
  81651. * @param scene defines the hosting scene
  81652. * @param updatable defines if the mesh must be flagged as updatable
  81653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81654. * @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)
  81655. * @returns a new Mesh
  81656. */
  81657. 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;
  81658. /**
  81659. * Creates lathe mesh.
  81660. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81661. * Please consider using the same method from the MeshBuilder class instead
  81662. * @param name defines the name of the mesh to create
  81663. * @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
  81664. * @param radius is the radius value of the lathe
  81665. * @param tessellation is the side number of the lathe.
  81666. * @param scene defines the hosting scene
  81667. * @param updatable defines if the mesh must be flagged as updatable
  81668. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81669. * @returns a new Mesh
  81670. */
  81671. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81672. /**
  81673. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81674. * @param name defines the name of the mesh to create
  81675. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81676. * @param scene defines the hosting scene
  81677. * @param updatable defines if the mesh must be flagged as updatable
  81678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81679. * @returns a new Mesh
  81680. */
  81681. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81682. /**
  81683. * Creates a ground mesh.
  81684. * Please consider using the same method from the MeshBuilder class instead
  81685. * @param name defines the name of the mesh to create
  81686. * @param width set the width of the ground
  81687. * @param height set the height of the ground
  81688. * @param subdivisions sets the number of subdivisions per side
  81689. * @param scene defines the hosting scene
  81690. * @param updatable defines if the mesh must be flagged as updatable
  81691. * @returns a new Mesh
  81692. */
  81693. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81694. /**
  81695. * Creates a tiled ground mesh.
  81696. * Please consider using the same method from the MeshBuilder class instead
  81697. * @param name defines the name of the mesh to create
  81698. * @param xmin set the ground minimum X coordinate
  81699. * @param zmin set the ground minimum Y coordinate
  81700. * @param xmax set the ground maximum X coordinate
  81701. * @param zmax set the ground maximum Z coordinate
  81702. * @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
  81703. * @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
  81704. * @param scene defines the hosting scene
  81705. * @param updatable defines if the mesh must be flagged as updatable
  81706. * @returns a new Mesh
  81707. */
  81708. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81709. w: number;
  81710. h: number;
  81711. }, precision: {
  81712. w: number;
  81713. h: number;
  81714. }, scene: Scene, updatable?: boolean): Mesh;
  81715. /**
  81716. * Creates a ground mesh from a height map.
  81717. * Please consider using the same method from the MeshBuilder class instead
  81718. * @see http://doc.babylonjs.com/babylon101/height_map
  81719. * @param name defines the name of the mesh to create
  81720. * @param url sets the URL of the height map image resource
  81721. * @param width set the ground width size
  81722. * @param height set the ground height size
  81723. * @param subdivisions sets the number of subdivision per side
  81724. * @param minHeight is the minimum altitude on the ground
  81725. * @param maxHeight is the maximum altitude on the ground
  81726. * @param scene defines the hosting scene
  81727. * @param updatable defines if the mesh must be flagged as updatable
  81728. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81729. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81730. * @returns a new Mesh
  81731. */
  81732. 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;
  81733. /**
  81734. * Creates a tube mesh.
  81735. * The tube is a parametric shape.
  81736. * It has no predefined shape. Its final shape will depend on the input parameters.
  81737. * Please consider using the same method from the MeshBuilder class instead
  81738. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81739. * @param name defines the name of the mesh to create
  81740. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81741. * @param radius sets the tube radius size
  81742. * @param tessellation is the number of sides on the tubular surface
  81743. * @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
  81744. * @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
  81745. * @param scene defines the hosting scene
  81746. * @param updatable defines if the mesh must be flagged as updatable
  81747. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81748. * @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)
  81749. * @returns a new Mesh
  81750. */
  81751. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81752. (i: number, distance: number): number;
  81753. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81754. /**
  81755. * Creates a polyhedron mesh.
  81756. * Please consider using the same method from the MeshBuilder class instead.
  81757. * * 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
  81758. * * The parameter `size` (positive float, default 1) sets the polygon size
  81759. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81760. * * 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`
  81761. * * 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
  81762. * * 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)`)
  81763. * * 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
  81764. * * 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
  81765. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81766. * * If you create a double-sided mesh, you can choose what parts of 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
  81767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81768. * @param name defines the name of the mesh to create
  81769. * @param options defines the options used to create the mesh
  81770. * @param scene defines the hosting scene
  81771. * @returns a new Mesh
  81772. */
  81773. static CreatePolyhedron(name: string, options: {
  81774. type?: number;
  81775. size?: number;
  81776. sizeX?: number;
  81777. sizeY?: number;
  81778. sizeZ?: number;
  81779. custom?: any;
  81780. faceUV?: Vector4[];
  81781. faceColors?: Color4[];
  81782. updatable?: boolean;
  81783. sideOrientation?: number;
  81784. }, scene: Scene): Mesh;
  81785. /**
  81786. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81787. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81788. * * 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`)
  81789. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81790. * * 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
  81791. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81792. * * If you create a double-sided mesh, you can choose what parts of 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
  81793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81794. * @param name defines the name of the mesh
  81795. * @param options defines the options used to create the mesh
  81796. * @param scene defines the hosting scene
  81797. * @returns a new Mesh
  81798. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81799. */
  81800. static CreateIcoSphere(name: string, options: {
  81801. radius?: number;
  81802. flat?: boolean;
  81803. subdivisions?: number;
  81804. sideOrientation?: number;
  81805. updatable?: boolean;
  81806. }, scene: Scene): Mesh;
  81807. /**
  81808. * Creates a decal mesh.
  81809. * Please consider using the same method from the MeshBuilder class instead.
  81810. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81811. * @param name defines the name of the mesh
  81812. * @param sourceMesh defines the mesh receiving the decal
  81813. * @param position sets the position of the decal in world coordinates
  81814. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81815. * @param size sets the decal scaling
  81816. * @param angle sets the angle to rotate the decal
  81817. * @returns a new Mesh
  81818. */
  81819. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81820. /**
  81821. * Prepare internal position array for software CPU skinning
  81822. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81823. */
  81824. setPositionsForCPUSkinning(): Float32Array;
  81825. /**
  81826. * Prepare internal normal array for software CPU skinning
  81827. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81828. */
  81829. setNormalsForCPUSkinning(): Float32Array;
  81830. /**
  81831. * Updates the vertex buffer by applying transformation from the bones
  81832. * @param skeleton defines the skeleton to apply to current mesh
  81833. * @returns the current mesh
  81834. */
  81835. applySkeleton(skeleton: Skeleton): Mesh;
  81836. /**
  81837. * 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
  81838. * @param meshes defines the list of meshes to scan
  81839. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81840. */
  81841. static MinMax(meshes: AbstractMesh[]): {
  81842. min: Vector3;
  81843. max: Vector3;
  81844. };
  81845. /**
  81846. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81847. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81848. * @returns a vector3
  81849. */
  81850. static Center(meshesOrMinMaxVector: {
  81851. min: Vector3;
  81852. max: Vector3;
  81853. } | AbstractMesh[]): Vector3;
  81854. /**
  81855. * Merge the array of meshes into a single mesh for performance reasons.
  81856. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81857. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81858. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81859. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81860. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81861. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81862. * @returns a new mesh
  81863. */
  81864. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81865. /** @hidden */
  81866. addInstance(instance: InstancedMesh): void;
  81867. /** @hidden */
  81868. removeInstance(instance: InstancedMesh): void;
  81869. }
  81870. }
  81871. declare module BABYLON {
  81872. /**
  81873. * Base class for the main features of a material in Babylon.js
  81874. */
  81875. export class Material implements IAnimatable {
  81876. /**
  81877. * Returns the triangle fill mode
  81878. */
  81879. static readonly TriangleFillMode: number;
  81880. /**
  81881. * Returns the wireframe mode
  81882. */
  81883. static readonly WireFrameFillMode: number;
  81884. /**
  81885. * Returns the point fill mode
  81886. */
  81887. static readonly PointFillMode: number;
  81888. /**
  81889. * Returns the point list draw mode
  81890. */
  81891. static readonly PointListDrawMode: number;
  81892. /**
  81893. * Returns the line list draw mode
  81894. */
  81895. static readonly LineListDrawMode: number;
  81896. /**
  81897. * Returns the line loop draw mode
  81898. */
  81899. static readonly LineLoopDrawMode: number;
  81900. /**
  81901. * Returns the line strip draw mode
  81902. */
  81903. static readonly LineStripDrawMode: number;
  81904. /**
  81905. * Returns the triangle strip draw mode
  81906. */
  81907. static readonly TriangleStripDrawMode: number;
  81908. /**
  81909. * Returns the triangle fan draw mode
  81910. */
  81911. static readonly TriangleFanDrawMode: number;
  81912. /**
  81913. * Stores the clock-wise side orientation
  81914. */
  81915. static readonly ClockWiseSideOrientation: number;
  81916. /**
  81917. * Stores the counter clock-wise side orientation
  81918. */
  81919. static readonly CounterClockWiseSideOrientation: number;
  81920. /**
  81921. * The dirty texture flag value
  81922. */
  81923. static readonly TextureDirtyFlag: number;
  81924. /**
  81925. * The dirty light flag value
  81926. */
  81927. static readonly LightDirtyFlag: number;
  81928. /**
  81929. * The dirty fresnel flag value
  81930. */
  81931. static readonly FresnelDirtyFlag: number;
  81932. /**
  81933. * The dirty attribute flag value
  81934. */
  81935. static readonly AttributesDirtyFlag: number;
  81936. /**
  81937. * The dirty misc flag value
  81938. */
  81939. static readonly MiscDirtyFlag: number;
  81940. /**
  81941. * The all dirty flag value
  81942. */
  81943. static readonly AllDirtyFlag: number;
  81944. /**
  81945. * The ID of the material
  81946. */
  81947. id: string;
  81948. /**
  81949. * Gets or sets the unique id of the material
  81950. */
  81951. uniqueId: number;
  81952. /**
  81953. * The name of the material
  81954. */
  81955. name: string;
  81956. /**
  81957. * Gets or sets user defined metadata
  81958. */
  81959. metadata: any;
  81960. /**
  81961. * For internal use only. Please do not use.
  81962. */
  81963. reservedDataStore: any;
  81964. /**
  81965. * Specifies if the ready state should be checked on each call
  81966. */
  81967. checkReadyOnEveryCall: boolean;
  81968. /**
  81969. * Specifies if the ready state should be checked once
  81970. */
  81971. checkReadyOnlyOnce: boolean;
  81972. /**
  81973. * The state of the material
  81974. */
  81975. state: string;
  81976. /**
  81977. * The alpha value of the material
  81978. */
  81979. protected _alpha: number;
  81980. /**
  81981. * List of inspectable custom properties (used by the Inspector)
  81982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81983. */
  81984. inspectableCustomProperties: IInspectable[];
  81985. /**
  81986. * Sets the alpha value of the material
  81987. */
  81988. /**
  81989. * Gets the alpha value of the material
  81990. */
  81991. alpha: number;
  81992. /**
  81993. * Specifies if back face culling is enabled
  81994. */
  81995. protected _backFaceCulling: boolean;
  81996. /**
  81997. * Sets the back-face culling state
  81998. */
  81999. /**
  82000. * Gets the back-face culling state
  82001. */
  82002. backFaceCulling: boolean;
  82003. /**
  82004. * Stores the value for side orientation
  82005. */
  82006. sideOrientation: number;
  82007. /**
  82008. * Callback triggered when the material is compiled
  82009. */
  82010. onCompiled: Nullable<(effect: Effect) => void>;
  82011. /**
  82012. * Callback triggered when an error occurs
  82013. */
  82014. onError: Nullable<(effect: Effect, errors: string) => void>;
  82015. /**
  82016. * Callback triggered to get the render target textures
  82017. */
  82018. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  82019. /**
  82020. * Gets a boolean indicating that current material needs to register RTT
  82021. */
  82022. readonly hasRenderTargetTextures: boolean;
  82023. /**
  82024. * Specifies if the material should be serialized
  82025. */
  82026. doNotSerialize: boolean;
  82027. /**
  82028. * @hidden
  82029. */
  82030. _storeEffectOnSubMeshes: boolean;
  82031. /**
  82032. * Stores the animations for the material
  82033. */
  82034. animations: Nullable<Array<Animation>>;
  82035. /**
  82036. * An event triggered when the material is disposed
  82037. */
  82038. onDisposeObservable: Observable<Material>;
  82039. /**
  82040. * An observer which watches for dispose events
  82041. */
  82042. private _onDisposeObserver;
  82043. private _onUnBindObservable;
  82044. /**
  82045. * Called during a dispose event
  82046. */
  82047. onDispose: () => void;
  82048. private _onBindObservable;
  82049. /**
  82050. * An event triggered when the material is bound
  82051. */
  82052. readonly onBindObservable: Observable<AbstractMesh>;
  82053. /**
  82054. * An observer which watches for bind events
  82055. */
  82056. private _onBindObserver;
  82057. /**
  82058. * Called during a bind event
  82059. */
  82060. onBind: (Mesh: AbstractMesh) => void;
  82061. /**
  82062. * An event triggered when the material is unbound
  82063. */
  82064. readonly onUnBindObservable: Observable<Material>;
  82065. /**
  82066. * Stores the value of the alpha mode
  82067. */
  82068. private _alphaMode;
  82069. /**
  82070. * Sets the value of the alpha mode.
  82071. *
  82072. * | Value | Type | Description |
  82073. * | --- | --- | --- |
  82074. * | 0 | ALPHA_DISABLE | |
  82075. * | 1 | ALPHA_ADD | |
  82076. * | 2 | ALPHA_COMBINE | |
  82077. * | 3 | ALPHA_SUBTRACT | |
  82078. * | 4 | ALPHA_MULTIPLY | |
  82079. * | 5 | ALPHA_MAXIMIZED | |
  82080. * | 6 | ALPHA_ONEONE | |
  82081. * | 7 | ALPHA_PREMULTIPLIED | |
  82082. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  82083. * | 9 | ALPHA_INTERPOLATE | |
  82084. * | 10 | ALPHA_SCREENMODE | |
  82085. *
  82086. */
  82087. /**
  82088. * Gets the value of the alpha mode
  82089. */
  82090. alphaMode: number;
  82091. /**
  82092. * Stores the state of the need depth pre-pass value
  82093. */
  82094. private _needDepthPrePass;
  82095. /**
  82096. * Sets the need depth pre-pass value
  82097. */
  82098. /**
  82099. * Gets the depth pre-pass value
  82100. */
  82101. needDepthPrePass: boolean;
  82102. /**
  82103. * Specifies if depth writing should be disabled
  82104. */
  82105. disableDepthWrite: boolean;
  82106. /**
  82107. * Specifies if depth writing should be forced
  82108. */
  82109. forceDepthWrite: boolean;
  82110. /**
  82111. * Specifies if there should be a separate pass for culling
  82112. */
  82113. separateCullingPass: boolean;
  82114. /**
  82115. * Stores the state specifing if fog should be enabled
  82116. */
  82117. private _fogEnabled;
  82118. /**
  82119. * Sets the state for enabling fog
  82120. */
  82121. /**
  82122. * Gets the value of the fog enabled state
  82123. */
  82124. fogEnabled: boolean;
  82125. /**
  82126. * Stores the size of points
  82127. */
  82128. pointSize: number;
  82129. /**
  82130. * Stores the z offset value
  82131. */
  82132. zOffset: number;
  82133. /**
  82134. * Gets a value specifying if wireframe mode is enabled
  82135. */
  82136. /**
  82137. * Sets the state of wireframe mode
  82138. */
  82139. wireframe: boolean;
  82140. /**
  82141. * Gets the value specifying if point clouds are enabled
  82142. */
  82143. /**
  82144. * Sets the state of point cloud mode
  82145. */
  82146. pointsCloud: boolean;
  82147. /**
  82148. * Gets the material fill mode
  82149. */
  82150. /**
  82151. * Sets the material fill mode
  82152. */
  82153. fillMode: number;
  82154. /**
  82155. * @hidden
  82156. * Stores the effects for the material
  82157. */
  82158. _effect: Nullable<Effect>;
  82159. /**
  82160. * @hidden
  82161. * Specifies if the material was previously ready
  82162. */
  82163. _wasPreviouslyReady: boolean;
  82164. /**
  82165. * Specifies if uniform buffers should be used
  82166. */
  82167. private _useUBO;
  82168. /**
  82169. * Stores a reference to the scene
  82170. */
  82171. private _scene;
  82172. /**
  82173. * Stores the fill mode state
  82174. */
  82175. private _fillMode;
  82176. /**
  82177. * Specifies if the depth write state should be cached
  82178. */
  82179. private _cachedDepthWriteState;
  82180. /**
  82181. * Stores the uniform buffer
  82182. */
  82183. protected _uniformBuffer: UniformBuffer;
  82184. /** @hidden */
  82185. _indexInSceneMaterialArray: number;
  82186. /** @hidden */
  82187. meshMap: Nullable<{
  82188. [id: string]: AbstractMesh | undefined;
  82189. }>;
  82190. /**
  82191. * Creates a material instance
  82192. * @param name defines the name of the material
  82193. * @param scene defines the scene to reference
  82194. * @param doNotAdd specifies if the material should be added to the scene
  82195. */
  82196. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  82197. /**
  82198. * Returns a string representation of the current material
  82199. * @param fullDetails defines a boolean indicating which levels of logging is desired
  82200. * @returns a string with material information
  82201. */
  82202. toString(fullDetails?: boolean): string;
  82203. /**
  82204. * Gets the class name of the material
  82205. * @returns a string with the class name of the material
  82206. */
  82207. getClassName(): string;
  82208. /**
  82209. * Specifies if updates for the material been locked
  82210. */
  82211. readonly isFrozen: boolean;
  82212. /**
  82213. * Locks updates for the material
  82214. */
  82215. freeze(): void;
  82216. /**
  82217. * Unlocks updates for the material
  82218. */
  82219. unfreeze(): void;
  82220. /**
  82221. * Specifies if the material is ready to be used
  82222. * @param mesh defines the mesh to check
  82223. * @param useInstances specifies if instances should be used
  82224. * @returns a boolean indicating if the material is ready to be used
  82225. */
  82226. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82227. /**
  82228. * Specifies that the submesh is ready to be used
  82229. * @param mesh defines the mesh to check
  82230. * @param subMesh defines which submesh to check
  82231. * @param useInstances specifies that instances should be used
  82232. * @returns a boolean indicating that the submesh is ready or not
  82233. */
  82234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82235. /**
  82236. * Returns the material effect
  82237. * @returns the effect associated with the material
  82238. */
  82239. getEffect(): Nullable<Effect>;
  82240. /**
  82241. * Returns the current scene
  82242. * @returns a Scene
  82243. */
  82244. getScene(): Scene;
  82245. /**
  82246. * Specifies if the material will require alpha blending
  82247. * @returns a boolean specifying if alpha blending is needed
  82248. */
  82249. needAlphaBlending(): boolean;
  82250. /**
  82251. * Specifies if the mesh will require alpha blending
  82252. * @param mesh defines the mesh to check
  82253. * @returns a boolean specifying if alpha blending is needed for the mesh
  82254. */
  82255. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  82256. /**
  82257. * Specifies if this material should be rendered in alpha test mode
  82258. * @returns a boolean specifying if an alpha test is needed.
  82259. */
  82260. needAlphaTesting(): boolean;
  82261. /**
  82262. * Gets the texture used for the alpha test
  82263. * @returns the texture to use for alpha testing
  82264. */
  82265. getAlphaTestTexture(): Nullable<BaseTexture>;
  82266. /**
  82267. * Marks the material to indicate that it needs to be re-calculated
  82268. */
  82269. markDirty(): void;
  82270. /** @hidden */
  82271. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  82272. /**
  82273. * Binds the material to the mesh
  82274. * @param world defines the world transformation matrix
  82275. * @param mesh defines the mesh to bind the material to
  82276. */
  82277. bind(world: Matrix, mesh?: Mesh): void;
  82278. /**
  82279. * Binds the submesh to the material
  82280. * @param world defines the world transformation matrix
  82281. * @param mesh defines the mesh containing the submesh
  82282. * @param subMesh defines the submesh to bind the material to
  82283. */
  82284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  82285. /**
  82286. * Binds the world matrix to the material
  82287. * @param world defines the world transformation matrix
  82288. */
  82289. bindOnlyWorldMatrix(world: Matrix): void;
  82290. /**
  82291. * Binds the scene's uniform buffer to the effect.
  82292. * @param effect defines the effect to bind to the scene uniform buffer
  82293. * @param sceneUbo defines the uniform buffer storing scene data
  82294. */
  82295. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  82296. /**
  82297. * Binds the view matrix to the effect
  82298. * @param effect defines the effect to bind the view matrix to
  82299. */
  82300. bindView(effect: Effect): void;
  82301. /**
  82302. * Binds the view projection matrix to the effect
  82303. * @param effect defines the effect to bind the view projection matrix to
  82304. */
  82305. bindViewProjection(effect: Effect): void;
  82306. /**
  82307. * Specifies if material alpha testing should be turned on for the mesh
  82308. * @param mesh defines the mesh to check
  82309. */
  82310. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  82311. /**
  82312. * Processes to execute after binding the material to a mesh
  82313. * @param mesh defines the rendered mesh
  82314. */
  82315. protected _afterBind(mesh?: Mesh): void;
  82316. /**
  82317. * Unbinds the material from the mesh
  82318. */
  82319. unbind(): void;
  82320. /**
  82321. * Gets the active textures from the material
  82322. * @returns an array of textures
  82323. */
  82324. getActiveTextures(): BaseTexture[];
  82325. /**
  82326. * Specifies if the material uses a texture
  82327. * @param texture defines the texture to check against the material
  82328. * @returns a boolean specifying if the material uses the texture
  82329. */
  82330. hasTexture(texture: BaseTexture): boolean;
  82331. /**
  82332. * Makes a duplicate of the material, and gives it a new name
  82333. * @param name defines the new name for the duplicated material
  82334. * @returns the cloned material
  82335. */
  82336. clone(name: string): Nullable<Material>;
  82337. /**
  82338. * Gets the meshes bound to the material
  82339. * @returns an array of meshes bound to the material
  82340. */
  82341. getBindedMeshes(): AbstractMesh[];
  82342. /**
  82343. * Force shader compilation
  82344. * @param mesh defines the mesh associated with this material
  82345. * @param onCompiled defines a function to execute once the material is compiled
  82346. * @param options defines the options to configure the compilation
  82347. */
  82348. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  82349. clipPlane: boolean;
  82350. }>): void;
  82351. /**
  82352. * Force shader compilation
  82353. * @param mesh defines the mesh that will use this material
  82354. * @param options defines additional options for compiling the shaders
  82355. * @returns a promise that resolves when the compilation completes
  82356. */
  82357. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  82358. clipPlane: boolean;
  82359. }>): Promise<void>;
  82360. private static readonly _ImageProcessingDirtyCallBack;
  82361. private static readonly _TextureDirtyCallBack;
  82362. private static readonly _FresnelDirtyCallBack;
  82363. private static readonly _MiscDirtyCallBack;
  82364. private static readonly _LightsDirtyCallBack;
  82365. private static readonly _AttributeDirtyCallBack;
  82366. private static _FresnelAndMiscDirtyCallBack;
  82367. private static _TextureAndMiscDirtyCallBack;
  82368. private static readonly _DirtyCallbackArray;
  82369. private static readonly _RunDirtyCallBacks;
  82370. /**
  82371. * Marks a define in the material to indicate that it needs to be re-computed
  82372. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  82373. */
  82374. markAsDirty(flag: number): void;
  82375. /**
  82376. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  82377. * @param func defines a function which checks material defines against the submeshes
  82378. */
  82379. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  82380. /**
  82381. * Indicates that image processing needs to be re-calculated for all submeshes
  82382. */
  82383. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  82384. /**
  82385. * Indicates that textures need to be re-calculated for all submeshes
  82386. */
  82387. protected _markAllSubMeshesAsTexturesDirty(): void;
  82388. /**
  82389. * Indicates that fresnel needs to be re-calculated for all submeshes
  82390. */
  82391. protected _markAllSubMeshesAsFresnelDirty(): void;
  82392. /**
  82393. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  82394. */
  82395. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  82396. /**
  82397. * Indicates that lights need to be re-calculated for all submeshes
  82398. */
  82399. protected _markAllSubMeshesAsLightsDirty(): void;
  82400. /**
  82401. * Indicates that attributes need to be re-calculated for all submeshes
  82402. */
  82403. protected _markAllSubMeshesAsAttributesDirty(): void;
  82404. /**
  82405. * Indicates that misc needs to be re-calculated for all submeshes
  82406. */
  82407. protected _markAllSubMeshesAsMiscDirty(): void;
  82408. /**
  82409. * Indicates that textures and misc need to be re-calculated for all submeshes
  82410. */
  82411. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  82412. /**
  82413. * Disposes the material
  82414. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82415. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82416. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82417. */
  82418. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82419. /** @hidden */
  82420. private releaseVertexArrayObject;
  82421. /**
  82422. * Serializes this material
  82423. * @returns the serialized material object
  82424. */
  82425. serialize(): any;
  82426. /**
  82427. * Creates a material from parsed material data
  82428. * @param parsedMaterial defines parsed material data
  82429. * @param scene defines the hosting scene
  82430. * @param rootUrl defines the root URL to use to load textures
  82431. * @returns a new material
  82432. */
  82433. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  82434. }
  82435. }
  82436. declare module BABYLON {
  82437. /**
  82438. * Base class for submeshes
  82439. */
  82440. export class BaseSubMesh {
  82441. /** @hidden */
  82442. _materialDefines: Nullable<MaterialDefines>;
  82443. /** @hidden */
  82444. _materialEffect: Nullable<Effect>;
  82445. /**
  82446. * Gets associated effect
  82447. */
  82448. readonly effect: Nullable<Effect>;
  82449. /**
  82450. * Sets associated effect (effect used to render this submesh)
  82451. * @param effect defines the effect to associate with
  82452. * @param defines defines the set of defines used to compile this effect
  82453. */
  82454. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  82455. }
  82456. /**
  82457. * Defines a subdivision inside a mesh
  82458. */
  82459. export class SubMesh extends BaseSubMesh implements ICullable {
  82460. /** the material index to use */
  82461. materialIndex: number;
  82462. /** vertex index start */
  82463. verticesStart: number;
  82464. /** vertices count */
  82465. verticesCount: number;
  82466. /** index start */
  82467. indexStart: number;
  82468. /** indices count */
  82469. indexCount: number;
  82470. /** @hidden */
  82471. _linesIndexCount: number;
  82472. private _mesh;
  82473. private _renderingMesh;
  82474. private _boundingInfo;
  82475. private _linesIndexBuffer;
  82476. /** @hidden */
  82477. _lastColliderWorldVertices: Nullable<Vector3[]>;
  82478. /** @hidden */
  82479. _trianglePlanes: Plane[];
  82480. /** @hidden */
  82481. _lastColliderTransformMatrix: Nullable<Matrix>;
  82482. /** @hidden */
  82483. _renderId: number;
  82484. /** @hidden */
  82485. _alphaIndex: number;
  82486. /** @hidden */
  82487. _distanceToCamera: number;
  82488. /** @hidden */
  82489. _id: number;
  82490. private _currentMaterial;
  82491. /**
  82492. * Add a new submesh to a mesh
  82493. * @param materialIndex defines the material index to use
  82494. * @param verticesStart defines vertex index start
  82495. * @param verticesCount defines vertices count
  82496. * @param indexStart defines index start
  82497. * @param indexCount defines indices count
  82498. * @param mesh defines the parent mesh
  82499. * @param renderingMesh defines an optional rendering mesh
  82500. * @param createBoundingBox defines if bounding box should be created for this submesh
  82501. * @returns the new submesh
  82502. */
  82503. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  82504. /**
  82505. * Creates a new submesh
  82506. * @param materialIndex defines the material index to use
  82507. * @param verticesStart defines vertex index start
  82508. * @param verticesCount defines vertices count
  82509. * @param indexStart defines index start
  82510. * @param indexCount defines indices count
  82511. * @param mesh defines the parent mesh
  82512. * @param renderingMesh defines an optional rendering mesh
  82513. * @param createBoundingBox defines if bounding box should be created for this submesh
  82514. */
  82515. constructor(
  82516. /** the material index to use */
  82517. materialIndex: number,
  82518. /** vertex index start */
  82519. verticesStart: number,
  82520. /** vertices count */
  82521. verticesCount: number,
  82522. /** index start */
  82523. indexStart: number,
  82524. /** indices count */
  82525. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  82526. /**
  82527. * Returns true if this submesh covers the entire parent mesh
  82528. * @ignorenaming
  82529. */
  82530. readonly IsGlobal: boolean;
  82531. /**
  82532. * Returns the submesh BoudingInfo object
  82533. * @returns current bounding info (or mesh's one if the submesh is global)
  82534. */
  82535. getBoundingInfo(): BoundingInfo;
  82536. /**
  82537. * Sets the submesh BoundingInfo
  82538. * @param boundingInfo defines the new bounding info to use
  82539. * @returns the SubMesh
  82540. */
  82541. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  82542. /**
  82543. * Returns the mesh of the current submesh
  82544. * @return the parent mesh
  82545. */
  82546. getMesh(): AbstractMesh;
  82547. /**
  82548. * Returns the rendering mesh of the submesh
  82549. * @returns the rendering mesh (could be different from parent mesh)
  82550. */
  82551. getRenderingMesh(): Mesh;
  82552. /**
  82553. * Returns the submesh material
  82554. * @returns null or the current material
  82555. */
  82556. getMaterial(): Nullable<Material>;
  82557. /**
  82558. * Sets a new updated BoundingInfo object to the submesh
  82559. * @param data defines an optional position array to use to determine the bounding info
  82560. * @returns the SubMesh
  82561. */
  82562. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  82563. /** @hidden */
  82564. _checkCollision(collider: Collider): boolean;
  82565. /**
  82566. * Updates the submesh BoundingInfo
  82567. * @param world defines the world matrix to use to update the bounding info
  82568. * @returns the submesh
  82569. */
  82570. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  82571. /**
  82572. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  82573. * @param frustumPlanes defines the frustum planes
  82574. * @returns true if the submesh is intersecting with the frustum
  82575. */
  82576. isInFrustum(frustumPlanes: Plane[]): boolean;
  82577. /**
  82578. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  82579. * @param frustumPlanes defines the frustum planes
  82580. * @returns true if the submesh is inside the frustum
  82581. */
  82582. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82583. /**
  82584. * Renders the submesh
  82585. * @param enableAlphaMode defines if alpha needs to be used
  82586. * @returns the submesh
  82587. */
  82588. render(enableAlphaMode: boolean): SubMesh;
  82589. /**
  82590. * @hidden
  82591. */
  82592. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  82593. /**
  82594. * Checks if the submesh intersects with a ray
  82595. * @param ray defines the ray to test
  82596. * @returns true is the passed ray intersects the submesh bounding box
  82597. */
  82598. canIntersects(ray: Ray): boolean;
  82599. /**
  82600. * Intersects current submesh with a ray
  82601. * @param ray defines the ray to test
  82602. * @param positions defines mesh's positions array
  82603. * @param indices defines mesh's indices array
  82604. * @param fastCheck defines if only bounding info should be used
  82605. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82606. * @returns intersection info or null if no intersection
  82607. */
  82608. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  82609. /** @hidden */
  82610. private _intersectLines;
  82611. /** @hidden */
  82612. private _intersectTriangles;
  82613. /** @hidden */
  82614. _rebuild(): void;
  82615. /**
  82616. * Creates a new submesh from the passed mesh
  82617. * @param newMesh defines the new hosting mesh
  82618. * @param newRenderingMesh defines an optional rendering mesh
  82619. * @returns the new submesh
  82620. */
  82621. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  82622. /**
  82623. * Release associated resources
  82624. */
  82625. dispose(): void;
  82626. /**
  82627. * Gets the class name
  82628. * @returns the string "SubMesh".
  82629. */
  82630. getClassName(): string;
  82631. /**
  82632. * Creates a new submesh from indices data
  82633. * @param materialIndex the index of the main mesh material
  82634. * @param startIndex the index where to start the copy in the mesh indices array
  82635. * @param indexCount the number of indices to copy then from the startIndex
  82636. * @param mesh the main mesh to create the submesh from
  82637. * @param renderingMesh the optional rendering mesh
  82638. * @returns a new submesh
  82639. */
  82640. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82641. }
  82642. }
  82643. declare module BABYLON {
  82644. /**
  82645. * Class used to store geometry data (vertex buffers + index buffer)
  82646. */
  82647. export class Geometry implements IGetSetVerticesData {
  82648. /**
  82649. * Gets or sets the ID of the geometry
  82650. */
  82651. id: string;
  82652. /**
  82653. * Gets or sets the unique ID of the geometry
  82654. */
  82655. uniqueId: number;
  82656. /**
  82657. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82658. */
  82659. delayLoadState: number;
  82660. /**
  82661. * Gets the file containing the data to load when running in delay load state
  82662. */
  82663. delayLoadingFile: Nullable<string>;
  82664. /**
  82665. * Callback called when the geometry is updated
  82666. */
  82667. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82668. private _scene;
  82669. private _engine;
  82670. private _meshes;
  82671. private _totalVertices;
  82672. /** @hidden */
  82673. _indices: IndicesArray;
  82674. /** @hidden */
  82675. _vertexBuffers: {
  82676. [key: string]: VertexBuffer;
  82677. };
  82678. private _isDisposed;
  82679. private _extend;
  82680. private _boundingBias;
  82681. /** @hidden */
  82682. _delayInfo: Array<string>;
  82683. private _indexBuffer;
  82684. private _indexBufferIsUpdatable;
  82685. /** @hidden */
  82686. _boundingInfo: Nullable<BoundingInfo>;
  82687. /** @hidden */
  82688. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82689. /** @hidden */
  82690. _softwareSkinningFrameId: number;
  82691. private _vertexArrayObjects;
  82692. private _updatable;
  82693. /** @hidden */
  82694. _positions: Nullable<Vector3[]>;
  82695. /**
  82696. * 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
  82697. */
  82698. /**
  82699. * 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
  82700. */
  82701. boundingBias: Vector2;
  82702. /**
  82703. * Static function used to attach a new empty geometry to a mesh
  82704. * @param mesh defines the mesh to attach the geometry to
  82705. * @returns the new Geometry
  82706. */
  82707. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82708. /**
  82709. * Creates a new geometry
  82710. * @param id defines the unique ID
  82711. * @param scene defines the hosting scene
  82712. * @param vertexData defines the VertexData used to get geometry data
  82713. * @param updatable defines if geometry must be updatable (false by default)
  82714. * @param mesh defines the mesh that will be associated with the geometry
  82715. */
  82716. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82717. /**
  82718. * Gets the current extend of the geometry
  82719. */
  82720. readonly extend: {
  82721. minimum: Vector3;
  82722. maximum: Vector3;
  82723. };
  82724. /**
  82725. * Gets the hosting scene
  82726. * @returns the hosting Scene
  82727. */
  82728. getScene(): Scene;
  82729. /**
  82730. * Gets the hosting engine
  82731. * @returns the hosting Engine
  82732. */
  82733. getEngine(): Engine;
  82734. /**
  82735. * Defines if the geometry is ready to use
  82736. * @returns true if the geometry is ready to be used
  82737. */
  82738. isReady(): boolean;
  82739. /**
  82740. * Gets a value indicating that the geometry should not be serialized
  82741. */
  82742. readonly doNotSerialize: boolean;
  82743. /** @hidden */
  82744. _rebuild(): void;
  82745. /**
  82746. * Affects all geometry data in one call
  82747. * @param vertexData defines the geometry data
  82748. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82749. */
  82750. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82751. /**
  82752. * Set specific vertex data
  82753. * @param kind defines the data kind (Position, normal, etc...)
  82754. * @param data defines the vertex data to use
  82755. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82756. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82757. */
  82758. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82759. /**
  82760. * Removes a specific vertex data
  82761. * @param kind defines the data kind (Position, normal, etc...)
  82762. */
  82763. removeVerticesData(kind: string): void;
  82764. /**
  82765. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82766. * @param buffer defines the vertex buffer to use
  82767. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82768. */
  82769. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82770. /**
  82771. * Update a specific vertex buffer
  82772. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  82773. * It will do nothing if the buffer is not updatable
  82774. * @param kind defines the data kind (Position, normal, etc...)
  82775. * @param data defines the data to use
  82776. * @param offset defines the offset in the target buffer where to store the data
  82777. * @param useBytes set to true if the offset is in bytes
  82778. */
  82779. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82780. /**
  82781. * Update a specific vertex buffer
  82782. * This function will create a new buffer if the current one is not updatable
  82783. * @param kind defines the data kind (Position, normal, etc...)
  82784. * @param data defines the data to use
  82785. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82786. */
  82787. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82788. private _updateBoundingInfo;
  82789. /** @hidden */
  82790. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  82791. /**
  82792. * Gets total number of vertices
  82793. * @returns the total number of vertices
  82794. */
  82795. getTotalVertices(): number;
  82796. /**
  82797. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82798. * @param kind defines the data kind (Position, normal, etc...)
  82799. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82801. * @returns a float array containing vertex data
  82802. */
  82803. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82804. /**
  82805. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82806. * @param kind defines the data kind (Position, normal, etc...)
  82807. * @returns true if the vertex buffer with the specified kind is updatable
  82808. */
  82809. isVertexBufferUpdatable(kind: string): boolean;
  82810. /**
  82811. * Gets a specific vertex buffer
  82812. * @param kind defines the data kind (Position, normal, etc...)
  82813. * @returns a VertexBuffer
  82814. */
  82815. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82816. /**
  82817. * Returns all vertex buffers
  82818. * @return an object holding all vertex buffers indexed by kind
  82819. */
  82820. getVertexBuffers(): Nullable<{
  82821. [key: string]: VertexBuffer;
  82822. }>;
  82823. /**
  82824. * Gets a boolean indicating if specific vertex buffer is present
  82825. * @param kind defines the data kind (Position, normal, etc...)
  82826. * @returns true if data is present
  82827. */
  82828. isVerticesDataPresent(kind: string): boolean;
  82829. /**
  82830. * Gets a list of all attached data kinds (Position, normal, etc...)
  82831. * @returns a list of string containing all kinds
  82832. */
  82833. getVerticesDataKinds(): string[];
  82834. /**
  82835. * Update index buffer
  82836. * @param indices defines the indices to store in the index buffer
  82837. * @param offset defines the offset in the target buffer where to store the data
  82838. * @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)
  82839. */
  82840. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82841. /**
  82842. * Creates a new index buffer
  82843. * @param indices defines the indices to store in the index buffer
  82844. * @param totalVertices defines the total number of vertices (could be null)
  82845. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82846. */
  82847. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82848. /**
  82849. * Return the total number of indices
  82850. * @returns the total number of indices
  82851. */
  82852. getTotalIndices(): number;
  82853. /**
  82854. * Gets the index buffer array
  82855. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82856. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82857. * @returns the index buffer array
  82858. */
  82859. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82860. /**
  82861. * Gets the index buffer
  82862. * @return the index buffer
  82863. */
  82864. getIndexBuffer(): Nullable<DataBuffer>;
  82865. /** @hidden */
  82866. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82867. /**
  82868. * Release the associated resources for a specific mesh
  82869. * @param mesh defines the source mesh
  82870. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82871. */
  82872. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82873. /**
  82874. * Apply current geometry to a given mesh
  82875. * @param mesh defines the mesh to apply geometry to
  82876. */
  82877. applyToMesh(mesh: Mesh): void;
  82878. private _updateExtend;
  82879. private _applyToMesh;
  82880. private notifyUpdate;
  82881. /**
  82882. * Load the geometry if it was flagged as delay loaded
  82883. * @param scene defines the hosting scene
  82884. * @param onLoaded defines a callback called when the geometry is loaded
  82885. */
  82886. load(scene: Scene, onLoaded?: () => void): void;
  82887. private _queueLoad;
  82888. /**
  82889. * Invert the geometry to move from a right handed system to a left handed one.
  82890. */
  82891. toLeftHanded(): void;
  82892. /** @hidden */
  82893. _resetPointsArrayCache(): void;
  82894. /** @hidden */
  82895. _generatePointsArray(): boolean;
  82896. /**
  82897. * Gets a value indicating if the geometry is disposed
  82898. * @returns true if the geometry was disposed
  82899. */
  82900. isDisposed(): boolean;
  82901. private _disposeVertexArrayObjects;
  82902. /**
  82903. * Free all associated resources
  82904. */
  82905. dispose(): void;
  82906. /**
  82907. * Clone the current geometry into a new geometry
  82908. * @param id defines the unique ID of the new geometry
  82909. * @returns a new geometry object
  82910. */
  82911. copy(id: string): Geometry;
  82912. /**
  82913. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82914. * @return a JSON representation of the current geometry data (without the vertices data)
  82915. */
  82916. serialize(): any;
  82917. private toNumberArray;
  82918. /**
  82919. * Serialize all vertices data into a JSON oject
  82920. * @returns a JSON representation of the current geometry data
  82921. */
  82922. serializeVerticeData(): any;
  82923. /**
  82924. * Extracts a clone of a mesh geometry
  82925. * @param mesh defines the source mesh
  82926. * @param id defines the unique ID of the new geometry object
  82927. * @returns the new geometry object
  82928. */
  82929. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82930. /**
  82931. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82932. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82933. * Be aware Math.random() could cause collisions, but:
  82934. * "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"
  82935. * @returns a string containing a new GUID
  82936. */
  82937. static RandomId(): string;
  82938. /** @hidden */
  82939. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82940. private static _CleanMatricesWeights;
  82941. /**
  82942. * Create a new geometry from persisted data (Using .babylon file format)
  82943. * @param parsedVertexData defines the persisted data
  82944. * @param scene defines the hosting scene
  82945. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82946. * @returns the new geometry object
  82947. */
  82948. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82949. }
  82950. }
  82951. declare module BABYLON {
  82952. /**
  82953. * Define an interface for all classes that will get and set the data on vertices
  82954. */
  82955. export interface IGetSetVerticesData {
  82956. /**
  82957. * Gets a boolean indicating if specific vertex data is present
  82958. * @param kind defines the vertex data kind to use
  82959. * @returns true is data kind is present
  82960. */
  82961. isVerticesDataPresent(kind: string): boolean;
  82962. /**
  82963. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82964. * @param kind defines the data kind (Position, normal, etc...)
  82965. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82966. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82967. * @returns a float array containing vertex data
  82968. */
  82969. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82970. /**
  82971. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82972. * @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.
  82973. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82974. * @returns the indices array or an empty array if the mesh has no geometry
  82975. */
  82976. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82977. /**
  82978. * Set specific vertex data
  82979. * @param kind defines the data kind (Position, normal, etc...)
  82980. * @param data defines the vertex data to use
  82981. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82982. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82983. */
  82984. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82985. /**
  82986. * Update a specific associated vertex buffer
  82987. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82988. * - VertexBuffer.PositionKind
  82989. * - VertexBuffer.UVKind
  82990. * - VertexBuffer.UV2Kind
  82991. * - VertexBuffer.UV3Kind
  82992. * - VertexBuffer.UV4Kind
  82993. * - VertexBuffer.UV5Kind
  82994. * - VertexBuffer.UV6Kind
  82995. * - VertexBuffer.ColorKind
  82996. * - VertexBuffer.MatricesIndicesKind
  82997. * - VertexBuffer.MatricesIndicesExtraKind
  82998. * - VertexBuffer.MatricesWeightsKind
  82999. * - VertexBuffer.MatricesWeightsExtraKind
  83000. * @param data defines the data source
  83001. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83002. * @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)
  83003. */
  83004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  83005. /**
  83006. * Creates a new index buffer
  83007. * @param indices defines the indices to store in the index buffer
  83008. * @param totalVertices defines the total number of vertices (could be null)
  83009. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  83010. */
  83011. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  83012. }
  83013. /**
  83014. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  83015. */
  83016. export class VertexData {
  83017. /**
  83018. * Mesh side orientation : usually the external or front surface
  83019. */
  83020. static readonly FRONTSIDE: number;
  83021. /**
  83022. * Mesh side orientation : usually the internal or back surface
  83023. */
  83024. static readonly BACKSIDE: number;
  83025. /**
  83026. * Mesh side orientation : both internal and external or front and back surfaces
  83027. */
  83028. static readonly DOUBLESIDE: number;
  83029. /**
  83030. * Mesh side orientation : by default, `FRONTSIDE`
  83031. */
  83032. static readonly DEFAULTSIDE: number;
  83033. /**
  83034. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  83035. */
  83036. positions: Nullable<FloatArray>;
  83037. /**
  83038. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  83039. */
  83040. normals: Nullable<FloatArray>;
  83041. /**
  83042. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  83043. */
  83044. tangents: Nullable<FloatArray>;
  83045. /**
  83046. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83047. */
  83048. uvs: Nullable<FloatArray>;
  83049. /**
  83050. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83051. */
  83052. uvs2: Nullable<FloatArray>;
  83053. /**
  83054. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83055. */
  83056. uvs3: Nullable<FloatArray>;
  83057. /**
  83058. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83059. */
  83060. uvs4: Nullable<FloatArray>;
  83061. /**
  83062. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83063. */
  83064. uvs5: Nullable<FloatArray>;
  83065. /**
  83066. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  83067. */
  83068. uvs6: Nullable<FloatArray>;
  83069. /**
  83070. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  83071. */
  83072. colors: Nullable<FloatArray>;
  83073. /**
  83074. * 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).
  83075. */
  83076. matricesIndices: Nullable<FloatArray>;
  83077. /**
  83078. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  83079. */
  83080. matricesWeights: Nullable<FloatArray>;
  83081. /**
  83082. * An array extending the number of possible indices
  83083. */
  83084. matricesIndicesExtra: Nullable<FloatArray>;
  83085. /**
  83086. * An array extending the number of possible weights when the number of indices is extended
  83087. */
  83088. matricesWeightsExtra: Nullable<FloatArray>;
  83089. /**
  83090. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  83091. */
  83092. indices: Nullable<IndicesArray>;
  83093. /**
  83094. * Uses the passed data array to set the set the values for the specified kind of data
  83095. * @param data a linear array of floating numbers
  83096. * @param kind the type of data that is being set, eg positions, colors etc
  83097. */
  83098. set(data: FloatArray, kind: string): void;
  83099. /**
  83100. * Associates the vertexData to the passed Mesh.
  83101. * Sets it as updatable or not (default `false`)
  83102. * @param mesh the mesh the vertexData is applied to
  83103. * @param updatable when used and having the value true allows new data to update the vertexData
  83104. * @returns the VertexData
  83105. */
  83106. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  83107. /**
  83108. * Associates the vertexData to the passed Geometry.
  83109. * Sets it as updatable or not (default `false`)
  83110. * @param geometry the geometry the vertexData is applied to
  83111. * @param updatable when used and having the value true allows new data to update the vertexData
  83112. * @returns VertexData
  83113. */
  83114. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  83115. /**
  83116. * Updates the associated mesh
  83117. * @param mesh the mesh to be updated
  83118. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83119. * @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
  83120. * @returns VertexData
  83121. */
  83122. updateMesh(mesh: Mesh): VertexData;
  83123. /**
  83124. * Updates the associated geometry
  83125. * @param geometry the geometry to be updated
  83126. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  83127. * @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
  83128. * @returns VertexData.
  83129. */
  83130. updateGeometry(geometry: Geometry): VertexData;
  83131. private _applyTo;
  83132. private _update;
  83133. /**
  83134. * Transforms each position and each normal of the vertexData according to the passed Matrix
  83135. * @param matrix the transforming matrix
  83136. * @returns the VertexData
  83137. */
  83138. transform(matrix: Matrix): VertexData;
  83139. /**
  83140. * Merges the passed VertexData into the current one
  83141. * @param other the VertexData to be merged into the current one
  83142. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  83143. * @returns the modified VertexData
  83144. */
  83145. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  83146. private _mergeElement;
  83147. private _validate;
  83148. /**
  83149. * Serializes the VertexData
  83150. * @returns a serialized object
  83151. */
  83152. serialize(): any;
  83153. /**
  83154. * Extracts the vertexData from a mesh
  83155. * @param mesh the mesh from which to extract the VertexData
  83156. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  83157. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83158. * @returns the object VertexData associated to the passed mesh
  83159. */
  83160. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83161. /**
  83162. * Extracts the vertexData from the geometry
  83163. * @param geometry the geometry from which to extract the VertexData
  83164. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  83165. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  83166. * @returns the object VertexData associated to the passed mesh
  83167. */
  83168. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  83169. private static _ExtractFrom;
  83170. /**
  83171. * Creates the VertexData for a Ribbon
  83172. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  83173. * * pathArray array of paths, each of which an array of successive Vector3
  83174. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  83175. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  83176. * * 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
  83177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83178. * * 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)
  83179. * * 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)
  83180. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  83181. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  83182. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  83183. * @returns the VertexData of the ribbon
  83184. */
  83185. static CreateRibbon(options: {
  83186. pathArray: Vector3[][];
  83187. closeArray?: boolean;
  83188. closePath?: boolean;
  83189. offset?: number;
  83190. sideOrientation?: number;
  83191. frontUVs?: Vector4;
  83192. backUVs?: Vector4;
  83193. invertUV?: boolean;
  83194. uvs?: Vector2[];
  83195. colors?: Color4[];
  83196. }): VertexData;
  83197. /**
  83198. * Creates the VertexData for a box
  83199. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83200. * * size sets the width, height and depth of the box to the value of size, optional default 1
  83201. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  83202. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  83203. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  83204. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  83205. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  83206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83207. * * 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)
  83208. * * 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)
  83209. * @returns the VertexData of the box
  83210. */
  83211. static CreateBox(options: {
  83212. size?: number;
  83213. width?: number;
  83214. height?: number;
  83215. depth?: number;
  83216. faceUV?: Vector4[];
  83217. faceColors?: Color4[];
  83218. sideOrientation?: number;
  83219. frontUVs?: Vector4;
  83220. backUVs?: Vector4;
  83221. }): VertexData;
  83222. /**
  83223. * Creates the VertexData for an ellipsoid, defaults to a sphere
  83224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83225. * * segments sets the number of horizontal strips optional, default 32
  83226. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  83227. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  83228. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  83229. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  83230. * * 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
  83231. * * 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
  83232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83233. * * 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)
  83234. * * 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)
  83235. * @returns the VertexData of the ellipsoid
  83236. */
  83237. static CreateSphere(options: {
  83238. segments?: number;
  83239. diameter?: number;
  83240. diameterX?: number;
  83241. diameterY?: number;
  83242. diameterZ?: number;
  83243. arc?: number;
  83244. slice?: number;
  83245. sideOrientation?: number;
  83246. frontUVs?: Vector4;
  83247. backUVs?: Vector4;
  83248. }): VertexData;
  83249. /**
  83250. * Creates the VertexData for a cylinder, cone or prism
  83251. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83252. * * height sets the height (y direction) of the cylinder, optional, default 2
  83253. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  83254. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  83255. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  83256. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83257. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  83258. * * 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
  83259. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83260. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83261. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  83262. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  83263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83264. * * 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)
  83265. * * 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)
  83266. * @returns the VertexData of the cylinder, cone or prism
  83267. */
  83268. static CreateCylinder(options: {
  83269. height?: number;
  83270. diameterTop?: number;
  83271. diameterBottom?: number;
  83272. diameter?: number;
  83273. tessellation?: number;
  83274. subdivisions?: number;
  83275. arc?: number;
  83276. faceColors?: Color4[];
  83277. faceUV?: Vector4[];
  83278. hasRings?: boolean;
  83279. enclose?: boolean;
  83280. sideOrientation?: number;
  83281. frontUVs?: Vector4;
  83282. backUVs?: Vector4;
  83283. }): VertexData;
  83284. /**
  83285. * Creates the VertexData for a torus
  83286. * @param options an object used to set the following optional parameters for the box, required but can be empty
  83287. * * diameter the diameter of the torus, optional default 1
  83288. * * thickness the diameter of the tube forming the torus, optional default 0.5
  83289. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  83290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83291. * * 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)
  83292. * * 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)
  83293. * @returns the VertexData of the torus
  83294. */
  83295. static CreateTorus(options: {
  83296. diameter?: number;
  83297. thickness?: number;
  83298. tessellation?: number;
  83299. sideOrientation?: number;
  83300. frontUVs?: Vector4;
  83301. backUVs?: Vector4;
  83302. }): VertexData;
  83303. /**
  83304. * Creates the VertexData of the LineSystem
  83305. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  83306. * - lines an array of lines, each line being an array of successive Vector3
  83307. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  83308. * @returns the VertexData of the LineSystem
  83309. */
  83310. static CreateLineSystem(options: {
  83311. lines: Vector3[][];
  83312. colors?: Nullable<Color4[][]>;
  83313. }): VertexData;
  83314. /**
  83315. * Create the VertexData for a DashedLines
  83316. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  83317. * - points an array successive Vector3
  83318. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  83319. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  83320. * - dashNb the intended total number of dashes, optional, default 200
  83321. * @returns the VertexData for the DashedLines
  83322. */
  83323. static CreateDashedLines(options: {
  83324. points: Vector3[];
  83325. dashSize?: number;
  83326. gapSize?: number;
  83327. dashNb?: number;
  83328. }): VertexData;
  83329. /**
  83330. * Creates the VertexData for a Ground
  83331. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83332. * - width the width (x direction) of the ground, optional, default 1
  83333. * - height the height (z direction) of the ground, optional, default 1
  83334. * - subdivisions the number of subdivisions per side, optional, default 1
  83335. * @returns the VertexData of the Ground
  83336. */
  83337. static CreateGround(options: {
  83338. width?: number;
  83339. height?: number;
  83340. subdivisions?: number;
  83341. subdivisionsX?: number;
  83342. subdivisionsY?: number;
  83343. }): VertexData;
  83344. /**
  83345. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  83346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  83347. * * xmin the ground minimum X coordinate, optional, default -1
  83348. * * zmin the ground minimum Z coordinate, optional, default -1
  83349. * * xmax the ground maximum X coordinate, optional, default 1
  83350. * * zmax the ground maximum Z coordinate, optional, default 1
  83351. * * 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}
  83352. * * 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}
  83353. * @returns the VertexData of the TiledGround
  83354. */
  83355. static CreateTiledGround(options: {
  83356. xmin: number;
  83357. zmin: number;
  83358. xmax: number;
  83359. zmax: number;
  83360. subdivisions?: {
  83361. w: number;
  83362. h: number;
  83363. };
  83364. precision?: {
  83365. w: number;
  83366. h: number;
  83367. };
  83368. }): VertexData;
  83369. /**
  83370. * Creates the VertexData of the Ground designed from a heightmap
  83371. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  83372. * * width the width (x direction) of the ground
  83373. * * height the height (z direction) of the ground
  83374. * * subdivisions the number of subdivisions per side
  83375. * * minHeight the minimum altitude on the ground, optional, default 0
  83376. * * maxHeight the maximum altitude on the ground, optional default 1
  83377. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  83378. * * buffer the array holding the image color data
  83379. * * bufferWidth the width of image
  83380. * * bufferHeight the height of image
  83381. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  83382. * @returns the VertexData of the Ground designed from a heightmap
  83383. */
  83384. static CreateGroundFromHeightMap(options: {
  83385. width: number;
  83386. height: number;
  83387. subdivisions: number;
  83388. minHeight: number;
  83389. maxHeight: number;
  83390. colorFilter: Color3;
  83391. buffer: Uint8Array;
  83392. bufferWidth: number;
  83393. bufferHeight: number;
  83394. alphaFilter: number;
  83395. }): VertexData;
  83396. /**
  83397. * Creates the VertexData for a Plane
  83398. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  83399. * * size sets the width and height of the plane to the value of size, optional default 1
  83400. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  83401. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  83402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83403. * * 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)
  83404. * * 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)
  83405. * @returns the VertexData of the box
  83406. */
  83407. static CreatePlane(options: {
  83408. size?: number;
  83409. width?: number;
  83410. height?: number;
  83411. sideOrientation?: number;
  83412. frontUVs?: Vector4;
  83413. backUVs?: Vector4;
  83414. }): VertexData;
  83415. /**
  83416. * Creates the VertexData of the Disc or regular Polygon
  83417. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  83418. * * radius the radius of the disc, optional default 0.5
  83419. * * tessellation the number of polygon sides, optional, default 64
  83420. * * 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
  83421. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83422. * * 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)
  83423. * * 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)
  83424. * @returns the VertexData of the box
  83425. */
  83426. static CreateDisc(options: {
  83427. radius?: number;
  83428. tessellation?: number;
  83429. arc?: number;
  83430. sideOrientation?: number;
  83431. frontUVs?: Vector4;
  83432. backUVs?: Vector4;
  83433. }): VertexData;
  83434. /**
  83435. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  83436. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  83437. * @param polygon a mesh built from polygonTriangulation.build()
  83438. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83439. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83440. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83441. * @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)
  83442. * @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)
  83443. * @returns the VertexData of the Polygon
  83444. */
  83445. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  83446. /**
  83447. * Creates the VertexData of the IcoSphere
  83448. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  83449. * * radius the radius of the IcoSphere, optional default 1
  83450. * * radiusX allows stretching in the x direction, optional, default radius
  83451. * * radiusY allows stretching in the y direction, optional, default radius
  83452. * * radiusZ allows stretching in the z direction, optional, default radius
  83453. * * flat when true creates a flat shaded mesh, optional, default true
  83454. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83456. * * 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)
  83457. * * 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)
  83458. * @returns the VertexData of the IcoSphere
  83459. */
  83460. static CreateIcoSphere(options: {
  83461. radius?: number;
  83462. radiusX?: number;
  83463. radiusY?: number;
  83464. radiusZ?: number;
  83465. flat?: boolean;
  83466. subdivisions?: number;
  83467. sideOrientation?: number;
  83468. frontUVs?: Vector4;
  83469. backUVs?: Vector4;
  83470. }): VertexData;
  83471. /**
  83472. * Creates the VertexData for a Polyhedron
  83473. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  83474. * * type provided types are:
  83475. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  83476. * * 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)
  83477. * * size the size of the IcoSphere, optional default 1
  83478. * * sizeX allows stretching in the x direction, optional, default size
  83479. * * sizeY allows stretching in the y direction, optional, default size
  83480. * * sizeZ allows stretching in the z direction, optional, default size
  83481. * * 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
  83482. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  83483. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  83484. * * flat when true creates a flat shaded mesh, optional, default true
  83485. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  83486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83487. * * 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)
  83488. * * 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)
  83489. * @returns the VertexData of the Polyhedron
  83490. */
  83491. static CreatePolyhedron(options: {
  83492. type?: number;
  83493. size?: number;
  83494. sizeX?: number;
  83495. sizeY?: number;
  83496. sizeZ?: number;
  83497. custom?: any;
  83498. faceUV?: Vector4[];
  83499. faceColors?: Color4[];
  83500. flat?: boolean;
  83501. sideOrientation?: number;
  83502. frontUVs?: Vector4;
  83503. backUVs?: Vector4;
  83504. }): VertexData;
  83505. /**
  83506. * Creates the VertexData for a TorusKnot
  83507. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  83508. * * radius the radius of the torus knot, optional, default 2
  83509. * * tube the thickness of the tube, optional, default 0.5
  83510. * * radialSegments the number of sides on each tube segments, optional, default 32
  83511. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  83512. * * p the number of windings around the z axis, optional, default 2
  83513. * * q the number of windings around the x axis, optional, default 3
  83514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83515. * * 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)
  83516. * * 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)
  83517. * @returns the VertexData of the Torus Knot
  83518. */
  83519. static CreateTorusKnot(options: {
  83520. radius?: number;
  83521. tube?: number;
  83522. radialSegments?: number;
  83523. tubularSegments?: number;
  83524. p?: number;
  83525. q?: number;
  83526. sideOrientation?: number;
  83527. frontUVs?: Vector4;
  83528. backUVs?: Vector4;
  83529. }): VertexData;
  83530. /**
  83531. * Compute normals for given positions and indices
  83532. * @param positions an array of vertex positions, [...., x, y, z, ......]
  83533. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  83534. * @param normals an array of vertex normals, [...., x, y, z, ......]
  83535. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  83536. * * facetNormals : optional array of facet normals (vector3)
  83537. * * facetPositions : optional array of facet positions (vector3)
  83538. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  83539. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  83540. * * bInfo : optional bounding info, required for facetPartitioning computation
  83541. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  83542. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  83543. * * useRightHandedSystem: optional boolean to for right handed system computation
  83544. * * depthSort : optional boolean to enable the facet depth sort computation
  83545. * * distanceTo : optional Vector3 to compute the facet depth from this location
  83546. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  83547. */
  83548. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  83549. facetNormals?: any;
  83550. facetPositions?: any;
  83551. facetPartitioning?: any;
  83552. ratio?: number;
  83553. bInfo?: any;
  83554. bbSize?: Vector3;
  83555. subDiv?: any;
  83556. useRightHandedSystem?: boolean;
  83557. depthSort?: boolean;
  83558. distanceTo?: Vector3;
  83559. depthSortedFacets?: any;
  83560. }): void;
  83561. /** @hidden */
  83562. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  83563. /**
  83564. * Applies VertexData created from the imported parameters to the geometry
  83565. * @param parsedVertexData the parsed data from an imported file
  83566. * @param geometry the geometry to apply the VertexData to
  83567. */
  83568. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  83569. }
  83570. }
  83571. declare module BABYLON {
  83572. /**
  83573. * Class containing static functions to help procedurally build meshes
  83574. */
  83575. export class DiscBuilder {
  83576. /**
  83577. * Creates a plane polygonal mesh. By default, this is a disc
  83578. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  83579. * * 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
  83580. * * 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
  83581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  83582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  83583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83584. * @param name defines the name of the mesh
  83585. * @param options defines the options used to create the mesh
  83586. * @param scene defines the hosting scene
  83587. * @returns the plane polygonal mesh
  83588. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  83589. */
  83590. static CreateDisc(name: string, options: {
  83591. radius?: number;
  83592. tessellation?: number;
  83593. arc?: number;
  83594. updatable?: boolean;
  83595. sideOrientation?: number;
  83596. frontUVs?: Vector4;
  83597. backUVs?: Vector4;
  83598. }, scene?: Nullable<Scene>): Mesh;
  83599. }
  83600. }
  83601. declare module BABYLON {
  83602. /**
  83603. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  83604. *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.
  83605. * The SPS is also a particle system. It provides some methods to manage the particles.
  83606. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  83607. *
  83608. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  83609. */
  83610. export class SolidParticleSystem implements IDisposable {
  83611. /**
  83612. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  83613. * Example : var p = SPS.particles[i];
  83614. */
  83615. particles: SolidParticle[];
  83616. /**
  83617. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  83618. */
  83619. nbParticles: number;
  83620. /**
  83621. * If the particles must ever face the camera (default false). Useful for planar particles.
  83622. */
  83623. billboard: boolean;
  83624. /**
  83625. * Recompute normals when adding a shape
  83626. */
  83627. recomputeNormals: boolean;
  83628. /**
  83629. * This a counter ofr your own usage. It's not set by any SPS functions.
  83630. */
  83631. counter: number;
  83632. /**
  83633. * The SPS name. This name is also given to the underlying mesh.
  83634. */
  83635. name: string;
  83636. /**
  83637. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83638. */
  83639. mesh: Mesh;
  83640. /**
  83641. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83642. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83643. */
  83644. vars: any;
  83645. /**
  83646. * This array is populated when the SPS is set as 'pickable'.
  83647. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83648. * Each element of this array is an object `{idx: int, faceId: int}`.
  83649. * `idx` is the picked particle index in the `SPS.particles` array
  83650. * `faceId` is the picked face index counted within this particle.
  83651. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83652. */
  83653. pickedParticles: {
  83654. idx: number;
  83655. faceId: number;
  83656. }[];
  83657. /**
  83658. * This array is populated when `enableDepthSort` is set to true.
  83659. * Each element of this array is an instance of the class DepthSortedParticle.
  83660. */
  83661. depthSortedParticles: DepthSortedParticle[];
  83662. /**
  83663. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83664. * @hidden
  83665. */
  83666. _bSphereOnly: boolean;
  83667. /**
  83668. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83669. * @hidden
  83670. */
  83671. _bSphereRadiusFactor: number;
  83672. private _scene;
  83673. private _positions;
  83674. private _indices;
  83675. private _normals;
  83676. private _colors;
  83677. private _uvs;
  83678. private _indices32;
  83679. private _positions32;
  83680. private _normals32;
  83681. private _fixedNormal32;
  83682. private _colors32;
  83683. private _uvs32;
  83684. private _index;
  83685. private _updatable;
  83686. private _pickable;
  83687. private _isVisibilityBoxLocked;
  83688. private _alwaysVisible;
  83689. private _depthSort;
  83690. private _shapeCounter;
  83691. private _copy;
  83692. private _color;
  83693. private _computeParticleColor;
  83694. private _computeParticleTexture;
  83695. private _computeParticleRotation;
  83696. private _computeParticleVertex;
  83697. private _computeBoundingBox;
  83698. private _depthSortParticles;
  83699. private _camera;
  83700. private _mustUnrotateFixedNormals;
  83701. private _particlesIntersect;
  83702. private _needs32Bits;
  83703. /**
  83704. * Creates a SPS (Solid Particle System) object.
  83705. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83706. * @param scene (Scene) is the scene in which the SPS is added.
  83707. * @param options defines the options of the sps e.g.
  83708. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83709. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83710. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83711. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83712. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83713. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83714. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83715. */
  83716. constructor(name: string, scene: Scene, options?: {
  83717. updatable?: boolean;
  83718. isPickable?: boolean;
  83719. enableDepthSort?: boolean;
  83720. particleIntersection?: boolean;
  83721. boundingSphereOnly?: boolean;
  83722. bSphereRadiusFactor?: number;
  83723. });
  83724. /**
  83725. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83726. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83727. * @returns the created mesh
  83728. */
  83729. buildMesh(): Mesh;
  83730. /**
  83731. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83732. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83733. * Thus the particles generated from `digest()` have their property `position` set yet.
  83734. * @param mesh ( Mesh ) is the mesh to be digested
  83735. * @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
  83736. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83737. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83738. * @returns the current SPS
  83739. */
  83740. digest(mesh: Mesh, options?: {
  83741. facetNb?: number;
  83742. number?: number;
  83743. delta?: number;
  83744. }): SolidParticleSystem;
  83745. private _unrotateFixedNormals;
  83746. private _resetCopy;
  83747. private _meshBuilder;
  83748. private _posToShape;
  83749. private _uvsToShapeUV;
  83750. private _addParticle;
  83751. /**
  83752. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83753. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83754. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83755. * @param nb (positive integer) the number of particles to be created from this model
  83756. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83757. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83758. * @returns the number of shapes in the system
  83759. */
  83760. addShape(mesh: Mesh, nb: number, options?: {
  83761. positionFunction?: any;
  83762. vertexFunction?: any;
  83763. }): number;
  83764. private _rebuildParticle;
  83765. /**
  83766. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83767. * @returns the SPS.
  83768. */
  83769. rebuildMesh(): SolidParticleSystem;
  83770. /**
  83771. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83772. * This method calls `updateParticle()` for each particle of the SPS.
  83773. * For an animated SPS, it is usually called within the render loop.
  83774. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83775. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83776. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83777. * @returns the SPS.
  83778. */
  83779. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83780. /**
  83781. * Disposes the SPS.
  83782. */
  83783. dispose(): void;
  83784. /**
  83785. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83787. * @returns the SPS.
  83788. */
  83789. refreshVisibleSize(): SolidParticleSystem;
  83790. /**
  83791. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83792. * @param size the size (float) of the visibility box
  83793. * note : this doesn't lock the SPS mesh bounding box.
  83794. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83795. */
  83796. setVisibilityBox(size: number): void;
  83797. /**
  83798. * Gets whether the SPS as always visible or not
  83799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83800. */
  83801. /**
  83802. * Sets the SPS as always visible or not
  83803. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83804. */
  83805. isAlwaysVisible: boolean;
  83806. /**
  83807. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83808. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83809. */
  83810. /**
  83811. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83812. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83813. */
  83814. isVisibilityBoxLocked: boolean;
  83815. /**
  83816. * Tells to `setParticles()` to compute the particle rotations or not.
  83817. * Default value : true. The SPS is faster when it's set to false.
  83818. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83819. */
  83820. /**
  83821. * Gets if `setParticles()` computes the particle rotations or not.
  83822. * Default value : true. The SPS is faster when it's set to false.
  83823. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83824. */
  83825. computeParticleRotation: boolean;
  83826. /**
  83827. * Tells to `setParticles()` to compute the particle colors or not.
  83828. * Default value : true. The SPS is faster when it's set to false.
  83829. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83830. */
  83831. /**
  83832. * Gets if `setParticles()` computes the particle colors or not.
  83833. * Default value : true. The SPS is faster when it's set to false.
  83834. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83835. */
  83836. computeParticleColor: boolean;
  83837. /**
  83838. * Gets if `setParticles()` computes the particle textures or not.
  83839. * Default value : true. The SPS is faster when it's set to false.
  83840. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83841. */
  83842. computeParticleTexture: boolean;
  83843. /**
  83844. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83845. * Default value : false. The SPS is faster when it's set to false.
  83846. * Note : the particle custom vertex positions aren't stored values.
  83847. */
  83848. /**
  83849. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83850. * Default value : false. The SPS is faster when it's set to false.
  83851. * Note : the particle custom vertex positions aren't stored values.
  83852. */
  83853. computeParticleVertex: boolean;
  83854. /**
  83855. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83856. */
  83857. /**
  83858. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83859. */
  83860. computeBoundingBox: boolean;
  83861. /**
  83862. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83863. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83864. * Default : `true`
  83865. */
  83866. /**
  83867. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83868. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83869. * Default : `true`
  83870. */
  83871. depthSortParticles: boolean;
  83872. /**
  83873. * This function does nothing. It may be overwritten to set all the particle first values.
  83874. * The SPS doesn't call this function, you may have to call it by your own.
  83875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83876. */
  83877. initParticles(): void;
  83878. /**
  83879. * This function does nothing. It may be overwritten to recycle a particle.
  83880. * The SPS doesn't call this function, you may have to call it by your own.
  83881. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83882. * @param particle The particle to recycle
  83883. * @returns the recycled particle
  83884. */
  83885. recycleParticle(particle: SolidParticle): SolidParticle;
  83886. /**
  83887. * Updates a particle : this function should be overwritten by the user.
  83888. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83889. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83890. * @example : just set a particle position or velocity and recycle conditions
  83891. * @param particle The particle to update
  83892. * @returns the updated particle
  83893. */
  83894. updateParticle(particle: SolidParticle): SolidParticle;
  83895. /**
  83896. * Updates a vertex of a particle : it can be overwritten by the user.
  83897. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83898. * @param particle the current particle
  83899. * @param vertex the current index of the current particle
  83900. * @param pt the index of the current vertex in the particle shape
  83901. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83902. * @example : just set a vertex particle position
  83903. * @returns the updated vertex
  83904. */
  83905. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83906. /**
  83907. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83908. * This does nothing and may be overwritten by the user.
  83909. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83910. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83911. * @param update the boolean update value actually passed to setParticles()
  83912. */
  83913. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83914. /**
  83915. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83916. * This will be passed three parameters.
  83917. * This does nothing and may be overwritten by the user.
  83918. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83919. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83920. * @param update the boolean update value actually passed to setParticles()
  83921. */
  83922. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83923. }
  83924. }
  83925. declare module BABYLON {
  83926. /**
  83927. * Represents one particle of a solid particle system.
  83928. */
  83929. export class SolidParticle {
  83930. /**
  83931. * particle global index
  83932. */
  83933. idx: number;
  83934. /**
  83935. * The color of the particle
  83936. */
  83937. color: Nullable<Color4>;
  83938. /**
  83939. * The world space position of the particle.
  83940. */
  83941. position: Vector3;
  83942. /**
  83943. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83944. */
  83945. rotation: Vector3;
  83946. /**
  83947. * The world space rotation quaternion of the particle.
  83948. */
  83949. rotationQuaternion: Nullable<Quaternion>;
  83950. /**
  83951. * The scaling of the particle.
  83952. */
  83953. scaling: Vector3;
  83954. /**
  83955. * The uvs of the particle.
  83956. */
  83957. uvs: Vector4;
  83958. /**
  83959. * The current speed of the particle.
  83960. */
  83961. velocity: Vector3;
  83962. /**
  83963. * The pivot point in the particle local space.
  83964. */
  83965. pivot: Vector3;
  83966. /**
  83967. * Must the particle be translated from its pivot point in its local space ?
  83968. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83969. * Default : false
  83970. */
  83971. translateFromPivot: boolean;
  83972. /**
  83973. * Is the particle active or not ?
  83974. */
  83975. alive: boolean;
  83976. /**
  83977. * Is the particle visible or not ?
  83978. */
  83979. isVisible: boolean;
  83980. /**
  83981. * Index of this particle in the global "positions" array (Internal use)
  83982. * @hidden
  83983. */
  83984. _pos: number;
  83985. /**
  83986. * @hidden Index of this particle in the global "indices" array (Internal use)
  83987. */
  83988. _ind: number;
  83989. /**
  83990. * @hidden ModelShape of this particle (Internal use)
  83991. */
  83992. _model: ModelShape;
  83993. /**
  83994. * ModelShape id of this particle
  83995. */
  83996. shapeId: number;
  83997. /**
  83998. * Index of the particle in its shape id (Internal use)
  83999. */
  84000. idxInShape: number;
  84001. /**
  84002. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  84003. */
  84004. _modelBoundingInfo: BoundingInfo;
  84005. /**
  84006. * @hidden Particle BoundingInfo object (Internal use)
  84007. */
  84008. _boundingInfo: BoundingInfo;
  84009. /**
  84010. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  84011. */
  84012. _sps: SolidParticleSystem;
  84013. /**
  84014. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  84015. */
  84016. _stillInvisible: boolean;
  84017. /**
  84018. * @hidden Last computed particle rotation matrix
  84019. */
  84020. _rotationMatrix: number[];
  84021. /**
  84022. * Parent particle Id, if any.
  84023. * Default null.
  84024. */
  84025. parentId: Nullable<number>;
  84026. /**
  84027. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  84028. * The possible values are :
  84029. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84030. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84033. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84034. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  84035. * */
  84036. cullingStrategy: number;
  84037. /**
  84038. * @hidden Internal global position in the SPS.
  84039. */
  84040. _globalPosition: Vector3;
  84041. /**
  84042. * Creates a Solid Particle object.
  84043. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  84044. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  84045. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  84046. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  84047. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  84048. * @param shapeId (integer) is the model shape identifier in the SPS.
  84049. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  84050. * @param sps defines the sps it is associated to
  84051. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  84052. */
  84053. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  84054. /**
  84055. * Legacy support, changed scale to scaling
  84056. */
  84057. /**
  84058. * Legacy support, changed scale to scaling
  84059. */
  84060. scale: Vector3;
  84061. /**
  84062. * Legacy support, changed quaternion to rotationQuaternion
  84063. */
  84064. /**
  84065. * Legacy support, changed quaternion to rotationQuaternion
  84066. */
  84067. quaternion: Nullable<Quaternion>;
  84068. /**
  84069. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  84070. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  84071. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  84072. * @returns true if it intersects
  84073. */
  84074. intersectsMesh(target: Mesh | SolidParticle): boolean;
  84075. /**
  84076. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  84077. * A particle is in the frustum if its bounding box intersects the frustum
  84078. * @param frustumPlanes defines the frustum to test
  84079. * @returns true if the particle is in the frustum planes
  84080. */
  84081. isInFrustum(frustumPlanes: Plane[]): boolean;
  84082. /**
  84083. * get the rotation matrix of the particle
  84084. * @hidden
  84085. */
  84086. getRotationMatrix(m: Matrix): void;
  84087. }
  84088. /**
  84089. * Represents the shape of the model used by one particle of a solid particle system.
  84090. * SPS internal tool, don't use it manually.
  84091. */
  84092. export class ModelShape {
  84093. /**
  84094. * The shape id
  84095. * @hidden
  84096. */
  84097. shapeID: number;
  84098. /**
  84099. * flat array of model positions (internal use)
  84100. * @hidden
  84101. */
  84102. _shape: Vector3[];
  84103. /**
  84104. * flat array of model UVs (internal use)
  84105. * @hidden
  84106. */
  84107. _shapeUV: number[];
  84108. /**
  84109. * length of the shape in the model indices array (internal use)
  84110. * @hidden
  84111. */
  84112. _indicesLength: number;
  84113. /**
  84114. * Custom position function (internal use)
  84115. * @hidden
  84116. */
  84117. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  84118. /**
  84119. * Custom vertex function (internal use)
  84120. * @hidden
  84121. */
  84122. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  84123. /**
  84124. * 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.
  84125. * SPS internal tool, don't use it manually.
  84126. * @hidden
  84127. */
  84128. 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>);
  84129. }
  84130. /**
  84131. * Represents a Depth Sorted Particle in the solid particle system.
  84132. */
  84133. export class DepthSortedParticle {
  84134. /**
  84135. * Index of the particle in the "indices" array
  84136. */
  84137. ind: number;
  84138. /**
  84139. * Length of the particle shape in the "indices" array
  84140. */
  84141. indicesLength: number;
  84142. /**
  84143. * Squared distance from the particle to the camera
  84144. */
  84145. sqDistance: number;
  84146. }
  84147. }
  84148. declare module BABYLON {
  84149. /**
  84150. * Class used to store all common mesh properties
  84151. */
  84152. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  84153. /** No occlusion */
  84154. static OCCLUSION_TYPE_NONE: number;
  84155. /** Occlusion set to optimisitic */
  84156. static OCCLUSION_TYPE_OPTIMISTIC: number;
  84157. /** Occlusion set to strict */
  84158. static OCCLUSION_TYPE_STRICT: number;
  84159. /** Use an accurante occlusion algorithm */
  84160. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  84161. /** Use a conservative occlusion algorithm */
  84162. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  84163. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84164. * Test order :
  84165. * Is the bounding sphere outside the frustum ?
  84166. * If not, are the bounding box vertices outside the frustum ?
  84167. * It not, then the cullable object is in the frustum.
  84168. */
  84169. static readonly CULLINGSTRATEGY_STANDARD: number;
  84170. /** Culling strategy : Bounding Sphere Only.
  84171. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84172. * It's also less accurate than the standard because some not visible objects can still be selected.
  84173. * Test : is the bounding sphere outside the frustum ?
  84174. * If not, then the cullable object is in the frustum.
  84175. */
  84176. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  84177. /** Culling strategy : Optimistic Inclusion.
  84178. * This in an inclusion test first, then the standard exclusion test.
  84179. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84180. * 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.
  84181. * Anyway, it's as accurate as the standard strategy.
  84182. * Test :
  84183. * Is the cullable object bounding sphere center in the frustum ?
  84184. * If not, apply the default culling strategy.
  84185. */
  84186. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  84187. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84188. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84189. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84190. * 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.
  84191. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84192. * Test :
  84193. * Is the cullable object bounding sphere center in the frustum ?
  84194. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84195. */
  84196. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  84197. /**
  84198. * No billboard
  84199. */
  84200. static readonly BILLBOARDMODE_NONE: number;
  84201. /** Billboard on X axis */
  84202. static readonly BILLBOARDMODE_X: number;
  84203. /** Billboard on Y axis */
  84204. static readonly BILLBOARDMODE_Y: number;
  84205. /** Billboard on Z axis */
  84206. static readonly BILLBOARDMODE_Z: number;
  84207. /** Billboard on all axes */
  84208. static readonly BILLBOARDMODE_ALL: number;
  84209. private _facetData;
  84210. /**
  84211. * The culling strategy to use to check whether the mesh must be rendered or not.
  84212. * This value can be changed at any time and will be used on the next render mesh selection.
  84213. * The possible values are :
  84214. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  84215. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  84216. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  84217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  84218. * Please read each static variable documentation to get details about the culling process.
  84219. * */
  84220. cullingStrategy: number;
  84221. /**
  84222. * Gets the number of facets in the mesh
  84223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84224. */
  84225. readonly facetNb: number;
  84226. /**
  84227. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  84228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84229. */
  84230. partitioningSubdivisions: number;
  84231. /**
  84232. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  84233. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  84234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  84235. */
  84236. partitioningBBoxRatio: number;
  84237. /**
  84238. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  84239. * Works only for updatable meshes.
  84240. * Doesn't work with multi-materials
  84241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84242. */
  84243. mustDepthSortFacets: boolean;
  84244. /**
  84245. * The location (Vector3) where the facet depth sort must be computed from.
  84246. * By default, the active camera position.
  84247. * Used only when facet depth sort is enabled
  84248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  84249. */
  84250. facetDepthSortFrom: Vector3;
  84251. /**
  84252. * gets a boolean indicating if facetData is enabled
  84253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  84254. */
  84255. readonly isFacetDataEnabled: boolean;
  84256. /** @hidden */
  84257. _updateNonUniformScalingState(value: boolean): boolean;
  84258. /**
  84259. * An event triggered when this mesh collides with another one
  84260. */
  84261. onCollideObservable: Observable<AbstractMesh>;
  84262. private _onCollideObserver;
  84263. /** Set a function to call when this mesh collides with another one */
  84264. onCollide: () => void;
  84265. /**
  84266. * An event triggered when the collision's position changes
  84267. */
  84268. onCollisionPositionChangeObservable: Observable<Vector3>;
  84269. private _onCollisionPositionChangeObserver;
  84270. /** Set a function to call when the collision's position changes */
  84271. onCollisionPositionChange: () => void;
  84272. /**
  84273. * An event triggered when material is changed
  84274. */
  84275. onMaterialChangedObservable: Observable<AbstractMesh>;
  84276. /**
  84277. * Gets or sets the orientation for POV movement & rotation
  84278. */
  84279. definedFacingForward: boolean;
  84280. /** @hidden */
  84281. _occlusionQuery: Nullable<WebGLQuery>;
  84282. private _visibility;
  84283. /** @hidden */
  84284. _isActive: boolean;
  84285. /** @hidden */
  84286. _onlyForInstances: boolean;
  84287. /** @hidden */
  84288. _renderingGroup: Nullable<RenderingGroup>;
  84289. /**
  84290. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84291. */
  84292. /**
  84293. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  84294. */
  84295. visibility: number;
  84296. /** Gets or sets the alpha index used to sort transparent meshes
  84297. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  84298. */
  84299. alphaIndex: number;
  84300. /**
  84301. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  84302. */
  84303. isVisible: boolean;
  84304. /**
  84305. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84306. */
  84307. isPickable: boolean;
  84308. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  84309. showSubMeshesBoundingBox: boolean;
  84310. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  84311. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  84312. */
  84313. isBlocker: boolean;
  84314. /**
  84315. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  84316. */
  84317. enablePointerMoveEvents: boolean;
  84318. /**
  84319. * Specifies the rendering group id for this mesh (0 by default)
  84320. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84321. */
  84322. renderingGroupId: number;
  84323. private _material;
  84324. /** Gets or sets current material */
  84325. material: Nullable<Material>;
  84326. private _receiveShadows;
  84327. /**
  84328. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  84329. * @see http://doc.babylonjs.com/babylon101/shadows
  84330. */
  84331. receiveShadows: boolean;
  84332. /** Defines color to use when rendering outline */
  84333. outlineColor: Color3;
  84334. /** Define width to use when rendering outline */
  84335. outlineWidth: number;
  84336. /** Defines color to use when rendering overlay */
  84337. overlayColor: Color3;
  84338. /** Defines alpha to use when rendering overlay */
  84339. overlayAlpha: number;
  84340. private _hasVertexAlpha;
  84341. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  84342. hasVertexAlpha: boolean;
  84343. private _useVertexColors;
  84344. /** 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) */
  84345. useVertexColors: boolean;
  84346. private _computeBonesUsingShaders;
  84347. /**
  84348. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  84349. */
  84350. computeBonesUsingShaders: boolean;
  84351. private _numBoneInfluencers;
  84352. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  84353. numBoneInfluencers: number;
  84354. private _applyFog;
  84355. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  84356. applyFog: boolean;
  84357. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  84358. useOctreeForRenderingSelection: boolean;
  84359. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  84360. useOctreeForPicking: boolean;
  84361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  84362. useOctreeForCollisions: boolean;
  84363. private _layerMask;
  84364. /**
  84365. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  84366. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  84367. */
  84368. layerMask: number;
  84369. /**
  84370. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  84371. */
  84372. alwaysSelectAsActiveMesh: boolean;
  84373. /**
  84374. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  84375. */
  84376. doNotSyncBoundingInfo: boolean;
  84377. /**
  84378. * Gets or sets the current action manager
  84379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84380. */
  84381. actionManager: Nullable<AbstractActionManager>;
  84382. private _checkCollisions;
  84383. private _collisionMask;
  84384. private _collisionGroup;
  84385. /**
  84386. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  84387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84388. */
  84389. ellipsoid: Vector3;
  84390. /**
  84391. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  84392. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84393. */
  84394. ellipsoidOffset: Vector3;
  84395. private _collider;
  84396. private _oldPositionForCollisions;
  84397. private _diffPositionForCollisions;
  84398. /**
  84399. * Gets or sets a collision mask used to mask collisions (default is -1).
  84400. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84401. */
  84402. collisionMask: number;
  84403. /**
  84404. * Gets or sets the current collision group mask (-1 by default).
  84405. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  84406. */
  84407. collisionGroup: number;
  84408. /**
  84409. * Defines edge width used when edgesRenderer is enabled
  84410. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84411. */
  84412. edgesWidth: number;
  84413. /**
  84414. * Defines edge color used when edgesRenderer is enabled
  84415. * @see https://www.babylonjs-playground.com/#10OJSG#13
  84416. */
  84417. edgesColor: Color4;
  84418. /** @hidden */
  84419. _edgesRenderer: Nullable<IEdgesRenderer>;
  84420. /** @hidden */
  84421. _masterMesh: Nullable<AbstractMesh>;
  84422. /** @hidden */
  84423. _boundingInfo: Nullable<BoundingInfo>;
  84424. /** @hidden */
  84425. _renderId: number;
  84426. /**
  84427. * Gets or sets the list of subMeshes
  84428. * @see http://doc.babylonjs.com/how_to/multi_materials
  84429. */
  84430. subMeshes: SubMesh[];
  84431. /** @hidden */
  84432. _intersectionsInProgress: AbstractMesh[];
  84433. /** @hidden */
  84434. _unIndexed: boolean;
  84435. /** @hidden */
  84436. _lightSources: Light[];
  84437. /** Gets the list of lights affecting that mesh */
  84438. readonly lightSources: Light[];
  84439. /** @hidden */
  84440. readonly _positions: Nullable<Vector3[]>;
  84441. /** @hidden */
  84442. _waitingData: {
  84443. lods: Nullable<any>;
  84444. actions: Nullable<any>;
  84445. freezeWorldMatrix: Nullable<boolean>;
  84446. };
  84447. private _skeleton;
  84448. /** @hidden */
  84449. _bonesTransformMatrices: Nullable<Float32Array>;
  84450. /**
  84451. * Gets or sets a skeleton to apply skining transformations
  84452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84453. */
  84454. skeleton: Nullable<Skeleton>;
  84455. /**
  84456. * An event triggered when the mesh is rebuilt.
  84457. */
  84458. onRebuildObservable: Observable<AbstractMesh>;
  84459. /**
  84460. * Creates a new AbstractMesh
  84461. * @param name defines the name of the mesh
  84462. * @param scene defines the hosting scene
  84463. */
  84464. constructor(name: string, scene?: Nullable<Scene>);
  84465. /**
  84466. * Returns the string "AbstractMesh"
  84467. * @returns "AbstractMesh"
  84468. */
  84469. getClassName(): string;
  84470. /**
  84471. * Gets a string representation of the current mesh
  84472. * @param fullDetails defines a boolean indicating if full details must be included
  84473. * @returns a string representation of the current mesh
  84474. */
  84475. toString(fullDetails?: boolean): string;
  84476. /**
  84477. * @hidden
  84478. */
  84479. protected _getEffectiveParent(): Nullable<Node>;
  84480. /** @hidden */
  84481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84482. /** @hidden */
  84483. _rebuild(): void;
  84484. /** @hidden */
  84485. _resyncLightSources(): void;
  84486. /** @hidden */
  84487. _resyncLighSource(light: Light): void;
  84488. /** @hidden */
  84489. _unBindEffect(): void;
  84490. /** @hidden */
  84491. _removeLightSource(light: Light): void;
  84492. private _markSubMeshesAsDirty;
  84493. /** @hidden */
  84494. _markSubMeshesAsLightDirty(): void;
  84495. /** @hidden */
  84496. _markSubMeshesAsAttributesDirty(): void;
  84497. /** @hidden */
  84498. _markSubMeshesAsMiscDirty(): void;
  84499. /**
  84500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  84501. */
  84502. scaling: Vector3;
  84503. /**
  84504. * Returns true if the mesh is blocked. Implemented by child classes
  84505. */
  84506. readonly isBlocked: boolean;
  84507. /**
  84508. * Returns the mesh itself by default. Implemented by child classes
  84509. * @param camera defines the camera to use to pick the right LOD level
  84510. * @returns the currentAbstractMesh
  84511. */
  84512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  84513. /**
  84514. * Returns 0 by default. Implemented by child classes
  84515. * @returns an integer
  84516. */
  84517. getTotalVertices(): number;
  84518. /**
  84519. * Returns a positive integer : the total number of indices in this mesh geometry.
  84520. * @returns the numner of indices or zero if the mesh has no geometry.
  84521. */
  84522. getTotalIndices(): number;
  84523. /**
  84524. * Returns null by default. Implemented by child classes
  84525. * @returns null
  84526. */
  84527. getIndices(): Nullable<IndicesArray>;
  84528. /**
  84529. * Returns the array of the requested vertex data kind. Implemented by child classes
  84530. * @param kind defines the vertex data kind to use
  84531. * @returns null
  84532. */
  84533. getVerticesData(kind: string): Nullable<FloatArray>;
  84534. /**
  84535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84537. * Note that a new underlying VertexBuffer object is created each call.
  84538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84539. * @param kind defines vertex data kind:
  84540. * * VertexBuffer.PositionKind
  84541. * * VertexBuffer.UVKind
  84542. * * VertexBuffer.UV2Kind
  84543. * * VertexBuffer.UV3Kind
  84544. * * VertexBuffer.UV4Kind
  84545. * * VertexBuffer.UV5Kind
  84546. * * VertexBuffer.UV6Kind
  84547. * * VertexBuffer.ColorKind
  84548. * * VertexBuffer.MatricesIndicesKind
  84549. * * VertexBuffer.MatricesIndicesExtraKind
  84550. * * VertexBuffer.MatricesWeightsKind
  84551. * * VertexBuffer.MatricesWeightsExtraKind
  84552. * @param data defines the data source
  84553. * @param updatable defines if the data must be flagged as updatable (or static)
  84554. * @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
  84555. * @returns the current mesh
  84556. */
  84557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84558. /**
  84559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84560. * If the mesh has no geometry, it is simply returned as it is.
  84561. * @param kind defines vertex data kind:
  84562. * * VertexBuffer.PositionKind
  84563. * * VertexBuffer.UVKind
  84564. * * VertexBuffer.UV2Kind
  84565. * * VertexBuffer.UV3Kind
  84566. * * VertexBuffer.UV4Kind
  84567. * * VertexBuffer.UV5Kind
  84568. * * VertexBuffer.UV6Kind
  84569. * * VertexBuffer.ColorKind
  84570. * * VertexBuffer.MatricesIndicesKind
  84571. * * VertexBuffer.MatricesIndicesExtraKind
  84572. * * VertexBuffer.MatricesWeightsKind
  84573. * * VertexBuffer.MatricesWeightsExtraKind
  84574. * @param data defines the data source
  84575. * @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
  84576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  84577. * @returns the current mesh
  84578. */
  84579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  84580. /**
  84581. * Sets the mesh indices,
  84582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  84584. * @param totalVertices Defines the total number of vertices
  84585. * @returns the current mesh
  84586. */
  84587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  84588. /**
  84589. * Gets a boolean indicating if specific vertex data is present
  84590. * @param kind defines the vertex data kind to use
  84591. * @returns true is data kind is present
  84592. */
  84593. isVerticesDataPresent(kind: string): boolean;
  84594. /**
  84595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  84596. * @returns a BoundingInfo
  84597. */
  84598. getBoundingInfo(): BoundingInfo;
  84599. /**
  84600. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  84601. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  84602. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  84603. * @returns the current mesh
  84604. */
  84605. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  84606. /**
  84607. * Overwrite the current bounding info
  84608. * @param boundingInfo defines the new bounding info
  84609. * @returns the current mesh
  84610. */
  84611. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  84612. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  84613. readonly useBones: boolean;
  84614. /** @hidden */
  84615. _preActivate(): void;
  84616. /** @hidden */
  84617. _preActivateForIntermediateRendering(renderId: number): void;
  84618. /** @hidden */
  84619. _activate(renderId: number): boolean;
  84620. /** @hidden */
  84621. _postActivate(): void;
  84622. /** @hidden */
  84623. _freeze(): void;
  84624. /** @hidden */
  84625. _unFreeze(): void;
  84626. /**
  84627. * Gets the current world matrix
  84628. * @returns a Matrix
  84629. */
  84630. getWorldMatrix(): Matrix;
  84631. /** @hidden */
  84632. _getWorldMatrixDeterminant(): number;
  84633. /**
  84634. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  84635. */
  84636. readonly isAnInstance: boolean;
  84637. /**
  84638. * Perform relative position change from the point of view of behind the front of the mesh.
  84639. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84640. * Supports definition of mesh facing forward or backward
  84641. * @param amountRight defines the distance on the right axis
  84642. * @param amountUp defines the distance on the up axis
  84643. * @param amountForward defines the distance on the forward axis
  84644. * @returns the current mesh
  84645. */
  84646. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  84647. /**
  84648. * Calculate relative position change from the point of view of behind the front of the mesh.
  84649. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84650. * Supports definition of mesh facing forward or backward
  84651. * @param amountRight defines the distance on the right axis
  84652. * @param amountUp defines the distance on the up axis
  84653. * @param amountForward defines the distance on the forward axis
  84654. * @returns the new displacement vector
  84655. */
  84656. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84657. /**
  84658. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84659. * Supports definition of mesh facing forward or backward
  84660. * @param flipBack defines the flip
  84661. * @param twirlClockwise defines the twirl
  84662. * @param tiltRight defines the tilt
  84663. * @returns the current mesh
  84664. */
  84665. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84666. /**
  84667. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84668. * Supports definition of mesh facing forward or backward.
  84669. * @param flipBack defines the flip
  84670. * @param twirlClockwise defines the twirl
  84671. * @param tiltRight defines the tilt
  84672. * @returns the new rotation vector
  84673. */
  84674. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84675. /**
  84676. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84677. * This means the mesh underlying bounding box and sphere are recomputed.
  84678. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84679. * @returns the current mesh
  84680. */
  84681. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84682. /** @hidden */
  84683. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84684. /** @hidden */
  84685. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84686. /** @hidden */
  84687. _updateBoundingInfo(): AbstractMesh;
  84688. /** @hidden */
  84689. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84690. /** @hidden */
  84691. protected _afterComputeWorldMatrix(): void;
  84692. /** @hidden */
  84693. readonly _effectiveMesh: AbstractMesh;
  84694. /**
  84695. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84696. * A mesh is in the frustum if its bounding box intersects the frustum
  84697. * @param frustumPlanes defines the frustum to test
  84698. * @returns true if the mesh is in the frustum planes
  84699. */
  84700. isInFrustum(frustumPlanes: Plane[]): boolean;
  84701. /**
  84702. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84703. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84704. * @param frustumPlanes defines the frustum to test
  84705. * @returns true if the mesh is completely in the frustum planes
  84706. */
  84707. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84708. /**
  84709. * True if the mesh intersects another mesh or a SolidParticle object
  84710. * @param mesh defines a target mesh or SolidParticle to test
  84711. * @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)
  84712. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84713. * @returns true if there is an intersection
  84714. */
  84715. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84716. /**
  84717. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84718. * @param point defines the point to test
  84719. * @returns true if there is an intersection
  84720. */
  84721. intersectsPoint(point: Vector3): boolean;
  84722. /**
  84723. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84725. */
  84726. checkCollisions: boolean;
  84727. /**
  84728. * Gets Collider object used to compute collisions (not physics)
  84729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84730. */
  84731. readonly collider: Nullable<Collider>;
  84732. /**
  84733. * Move the mesh using collision engine
  84734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84735. * @param displacement defines the requested displacement vector
  84736. * @returns the current mesh
  84737. */
  84738. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84739. private _onCollisionPositionChange;
  84740. /** @hidden */
  84741. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84742. /** @hidden */
  84743. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84744. /** @hidden */
  84745. _checkCollision(collider: Collider): AbstractMesh;
  84746. /** @hidden */
  84747. _generatePointsArray(): boolean;
  84748. /**
  84749. * Checks if the passed Ray intersects with the mesh
  84750. * @param ray defines the ray to use
  84751. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84752. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84753. * @returns the picking info
  84754. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84755. */
  84756. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84757. /**
  84758. * Clones the current mesh
  84759. * @param name defines the mesh name
  84760. * @param newParent defines the new mesh parent
  84761. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84762. * @returns the new mesh
  84763. */
  84764. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84765. /**
  84766. * Disposes all the submeshes of the current meshnp
  84767. * @returns the current mesh
  84768. */
  84769. releaseSubMeshes(): AbstractMesh;
  84770. /**
  84771. * Releases resources associated with this abstract mesh.
  84772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84774. */
  84775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84776. /**
  84777. * Adds the passed mesh as a child to the current mesh
  84778. * @param mesh defines the child mesh
  84779. * @returns the current mesh
  84780. */
  84781. addChild(mesh: AbstractMesh): AbstractMesh;
  84782. /**
  84783. * Removes the passed mesh from the current mesh children list
  84784. * @param mesh defines the child mesh
  84785. * @returns the current mesh
  84786. */
  84787. removeChild(mesh: AbstractMesh): AbstractMesh;
  84788. /** @hidden */
  84789. private _initFacetData;
  84790. /**
  84791. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84792. * This method can be called within the render loop.
  84793. * 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
  84794. * @returns the current mesh
  84795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84796. */
  84797. updateFacetData(): AbstractMesh;
  84798. /**
  84799. * Returns the facetLocalNormals array.
  84800. * The normals are expressed in the mesh local spac
  84801. * @returns an array of Vector3
  84802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84803. */
  84804. getFacetLocalNormals(): Vector3[];
  84805. /**
  84806. * Returns the facetLocalPositions array.
  84807. * The facet positions are expressed in the mesh local space
  84808. * @returns an array of Vector3
  84809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84810. */
  84811. getFacetLocalPositions(): Vector3[];
  84812. /**
  84813. * Returns the facetLocalPartioning array
  84814. * @returns an array of array of numbers
  84815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84816. */
  84817. getFacetLocalPartitioning(): number[][];
  84818. /**
  84819. * Returns the i-th facet position in the world system.
  84820. * This method allocates a new Vector3 per call
  84821. * @param i defines the facet index
  84822. * @returns a new Vector3
  84823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84824. */
  84825. getFacetPosition(i: number): Vector3;
  84826. /**
  84827. * Sets the reference Vector3 with the i-th facet position in the world system
  84828. * @param i defines the facet index
  84829. * @param ref defines the target vector
  84830. * @returns the current mesh
  84831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84832. */
  84833. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84834. /**
  84835. * Returns the i-th facet normal in the world system.
  84836. * This method allocates a new Vector3 per call
  84837. * @param i defines the facet index
  84838. * @returns a new Vector3
  84839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84840. */
  84841. getFacetNormal(i: number): Vector3;
  84842. /**
  84843. * Sets the reference Vector3 with the i-th facet normal in the world system
  84844. * @param i defines the facet index
  84845. * @param ref defines the target vector
  84846. * @returns the current mesh
  84847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84848. */
  84849. getFacetNormalToRef(i: number, ref: Vector3): this;
  84850. /**
  84851. * 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)
  84852. * @param x defines x coordinate
  84853. * @param y defines y coordinate
  84854. * @param z defines z coordinate
  84855. * @returns the array of facet indexes
  84856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84857. */
  84858. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84859. /**
  84860. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84861. * @param projected sets as the (x,y,z) world projection on the facet
  84862. * @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
  84863. * @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
  84864. * @param x defines x coordinate
  84865. * @param y defines y coordinate
  84866. * @param z defines z coordinate
  84867. * @returns the face index if found (or null instead)
  84868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84869. */
  84870. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84871. /**
  84872. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84873. * @param projected sets as the (x,y,z) local projection on the facet
  84874. * @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
  84875. * @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
  84876. * @param x defines x coordinate
  84877. * @param y defines y coordinate
  84878. * @param z defines z coordinate
  84879. * @returns the face index if found (or null instead)
  84880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84881. */
  84882. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84883. /**
  84884. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84885. * @returns the parameters
  84886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84887. */
  84888. getFacetDataParameters(): any;
  84889. /**
  84890. * Disables the feature FacetData and frees the related memory
  84891. * @returns the current mesh
  84892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84893. */
  84894. disableFacetData(): AbstractMesh;
  84895. /**
  84896. * Updates the AbstractMesh indices array
  84897. * @param indices defines the data source
  84898. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84899. * @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)
  84900. * @returns the current mesh
  84901. */
  84902. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84903. /**
  84904. * Creates new normals data for the mesh
  84905. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84906. * @returns the current mesh
  84907. */
  84908. createNormals(updatable: boolean): AbstractMesh;
  84909. /**
  84910. * Align the mesh with a normal
  84911. * @param normal defines the normal to use
  84912. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84913. * @returns the current mesh
  84914. */
  84915. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84916. /** @hidden */
  84917. _checkOcclusionQuery(): boolean;
  84918. }
  84919. }
  84920. declare module BABYLON {
  84921. /**
  84922. * Interface used to define ActionEvent
  84923. */
  84924. export interface IActionEvent {
  84925. /** The mesh or sprite that triggered the action */
  84926. source: any;
  84927. /** The X mouse cursor position at the time of the event */
  84928. pointerX: number;
  84929. /** The Y mouse cursor position at the time of the event */
  84930. pointerY: number;
  84931. /** The mesh that is currently pointed at (can be null) */
  84932. meshUnderPointer: Nullable<AbstractMesh>;
  84933. /** the original (browser) event that triggered the ActionEvent */
  84934. sourceEvent?: any;
  84935. /** additional data for the event */
  84936. additionalData?: any;
  84937. }
  84938. /**
  84939. * ActionEvent is the event being sent when an action is triggered.
  84940. */
  84941. export class ActionEvent implements IActionEvent {
  84942. /** The mesh or sprite that triggered the action */
  84943. source: any;
  84944. /** The X mouse cursor position at the time of the event */
  84945. pointerX: number;
  84946. /** The Y mouse cursor position at the time of the event */
  84947. pointerY: number;
  84948. /** The mesh that is currently pointed at (can be null) */
  84949. meshUnderPointer: Nullable<AbstractMesh>;
  84950. /** the original (browser) event that triggered the ActionEvent */
  84951. sourceEvent?: any;
  84952. /** additional data for the event */
  84953. additionalData?: any;
  84954. /**
  84955. * Creates a new ActionEvent
  84956. * @param source The mesh or sprite that triggered the action
  84957. * @param pointerX The X mouse cursor position at the time of the event
  84958. * @param pointerY The Y mouse cursor position at the time of the event
  84959. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84960. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84961. * @param additionalData additional data for the event
  84962. */
  84963. constructor(
  84964. /** The mesh or sprite that triggered the action */
  84965. source: any,
  84966. /** The X mouse cursor position at the time of the event */
  84967. pointerX: number,
  84968. /** The Y mouse cursor position at the time of the event */
  84969. pointerY: number,
  84970. /** The mesh that is currently pointed at (can be null) */
  84971. meshUnderPointer: Nullable<AbstractMesh>,
  84972. /** the original (browser) event that triggered the ActionEvent */
  84973. sourceEvent?: any,
  84974. /** additional data for the event */
  84975. additionalData?: any);
  84976. /**
  84977. * Helper function to auto-create an ActionEvent from a source mesh.
  84978. * @param source The source mesh that triggered the event
  84979. * @param evt The original (browser) event
  84980. * @param additionalData additional data for the event
  84981. * @returns the new ActionEvent
  84982. */
  84983. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84984. /**
  84985. * Helper function to auto-create an ActionEvent from a source sprite
  84986. * @param source The source sprite that triggered the event
  84987. * @param scene Scene associated with the sprite
  84988. * @param evt The original (browser) event
  84989. * @param additionalData additional data for the event
  84990. * @returns the new ActionEvent
  84991. */
  84992. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84993. /**
  84994. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84995. * @param scene the scene where the event occurred
  84996. * @param evt The original (browser) event
  84997. * @returns the new ActionEvent
  84998. */
  84999. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  85000. /**
  85001. * Helper function to auto-create an ActionEvent from a primitive
  85002. * @param prim defines the target primitive
  85003. * @param pointerPos defines the pointer position
  85004. * @param evt The original (browser) event
  85005. * @param additionalData additional data for the event
  85006. * @returns the new ActionEvent
  85007. */
  85008. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  85009. }
  85010. }
  85011. declare module BABYLON {
  85012. /**
  85013. * Abstract class used to decouple action Manager from scene and meshes.
  85014. * Do not instantiate.
  85015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  85016. */
  85017. export abstract class AbstractActionManager implements IDisposable {
  85018. /** Gets the list of active triggers */
  85019. static Triggers: {
  85020. [key: string]: number;
  85021. };
  85022. /** Gets the cursor to use when hovering items */
  85023. hoverCursor: string;
  85024. /** Gets the list of actions */
  85025. actions: IAction[];
  85026. /**
  85027. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  85028. */
  85029. isRecursive: boolean;
  85030. /**
  85031. * Releases all associated resources
  85032. */
  85033. abstract dispose(): void;
  85034. /**
  85035. * Does this action manager has pointer triggers
  85036. */
  85037. abstract readonly hasPointerTriggers: boolean;
  85038. /**
  85039. * Does this action manager has pick triggers
  85040. */
  85041. abstract readonly hasPickTriggers: boolean;
  85042. /**
  85043. * Process a specific trigger
  85044. * @param trigger defines the trigger to process
  85045. * @param evt defines the event details to be processed
  85046. */
  85047. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  85048. /**
  85049. * Does this action manager handles actions of any of the given triggers
  85050. * @param triggers defines the triggers to be tested
  85051. * @return a boolean indicating whether one (or more) of the triggers is handled
  85052. */
  85053. abstract hasSpecificTriggers(triggers: number[]): boolean;
  85054. /**
  85055. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  85056. * speed.
  85057. * @param triggerA defines the trigger to be tested
  85058. * @param triggerB defines the trigger to be tested
  85059. * @return a boolean indicating whether one (or more) of the triggers is handled
  85060. */
  85061. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  85062. /**
  85063. * Does this action manager handles actions of a given trigger
  85064. * @param trigger defines the trigger to be tested
  85065. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  85066. * @return whether the trigger is handled
  85067. */
  85068. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  85069. /**
  85070. * Serialize this manager to a JSON object
  85071. * @param name defines the property name to store this manager
  85072. * @returns a JSON representation of this manager
  85073. */
  85074. abstract serialize(name: string): any;
  85075. /**
  85076. * Registers an action to this action manager
  85077. * @param action defines the action to be registered
  85078. * @return the action amended (prepared) after registration
  85079. */
  85080. abstract registerAction(action: IAction): Nullable<IAction>;
  85081. /**
  85082. * Unregisters an action to this action manager
  85083. * @param action defines the action to be unregistered
  85084. * @return a boolean indicating whether the action has been unregistered
  85085. */
  85086. abstract unregisterAction(action: IAction): Boolean;
  85087. /**
  85088. * Does exist one action manager with at least one trigger
  85089. **/
  85090. static readonly HasTriggers: boolean;
  85091. /**
  85092. * Does exist one action manager with at least one pick trigger
  85093. **/
  85094. static readonly HasPickTriggers: boolean;
  85095. /**
  85096. * Does exist one action manager that handles actions of a given trigger
  85097. * @param trigger defines the trigger to be tested
  85098. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  85099. **/
  85100. static HasSpecificTrigger(trigger: number): boolean;
  85101. }
  85102. }
  85103. declare module BABYLON {
  85104. /**
  85105. * Defines how a node can be built from a string name.
  85106. */
  85107. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  85108. /**
  85109. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  85110. */
  85111. export class Node implements IBehaviorAware<Node> {
  85112. /** @hidden */
  85113. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  85114. private static _NodeConstructors;
  85115. /**
  85116. * Add a new node constructor
  85117. * @param type defines the type name of the node to construct
  85118. * @param constructorFunc defines the constructor function
  85119. */
  85120. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  85121. /**
  85122. * Returns a node constructor based on type name
  85123. * @param type defines the type name
  85124. * @param name defines the new node name
  85125. * @param scene defines the hosting scene
  85126. * @param options defines optional options to transmit to constructors
  85127. * @returns the new constructor or null
  85128. */
  85129. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  85130. /**
  85131. * Gets or sets the name of the node
  85132. */
  85133. name: string;
  85134. /**
  85135. * Gets or sets the id of the node
  85136. */
  85137. id: string;
  85138. /**
  85139. * Gets or sets the unique id of the node
  85140. */
  85141. uniqueId: number;
  85142. /**
  85143. * Gets or sets a string used to store user defined state for the node
  85144. */
  85145. state: string;
  85146. /**
  85147. * Gets or sets an object used to store user defined information for the node
  85148. */
  85149. metadata: any;
  85150. /**
  85151. * For internal use only. Please do not use.
  85152. */
  85153. reservedDataStore: any;
  85154. /**
  85155. * List of inspectable custom properties (used by the Inspector)
  85156. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85157. */
  85158. inspectableCustomProperties: IInspectable[];
  85159. /**
  85160. * Gets or sets a boolean used to define if the node must be serialized
  85161. */
  85162. doNotSerialize: boolean;
  85163. /** @hidden */
  85164. _isDisposed: boolean;
  85165. /**
  85166. * Gets a list of Animations associated with the node
  85167. */
  85168. animations: Animation[];
  85169. protected _ranges: {
  85170. [name: string]: Nullable<AnimationRange>;
  85171. };
  85172. /**
  85173. * Callback raised when the node is ready to be used
  85174. */
  85175. onReady: Nullable<(node: Node) => void>;
  85176. private _isEnabled;
  85177. private _isParentEnabled;
  85178. private _isReady;
  85179. /** @hidden */
  85180. _currentRenderId: number;
  85181. private _parentUpdateId;
  85182. /** @hidden */
  85183. _childUpdateId: number;
  85184. /** @hidden */
  85185. _waitingParentId: Nullable<string>;
  85186. /** @hidden */
  85187. _scene: Scene;
  85188. /** @hidden */
  85189. _cache: any;
  85190. private _parentNode;
  85191. private _children;
  85192. /** @hidden */
  85193. _worldMatrix: Matrix;
  85194. /** @hidden */
  85195. _worldMatrixDeterminant: number;
  85196. /** @hidden */
  85197. _worldMatrixDeterminantIsDirty: boolean;
  85198. /** @hidden */
  85199. private _sceneRootNodesIndex;
  85200. /**
  85201. * Gets a boolean indicating if the node has been disposed
  85202. * @returns true if the node was disposed
  85203. */
  85204. isDisposed(): boolean;
  85205. /**
  85206. * Gets or sets the parent of the node (without keeping the current position in the scene)
  85207. * @see https://doc.babylonjs.com/how_to/parenting
  85208. */
  85209. parent: Nullable<Node>;
  85210. private addToSceneRootNodes;
  85211. private removeFromSceneRootNodes;
  85212. private _animationPropertiesOverride;
  85213. /**
  85214. * Gets or sets the animation properties override
  85215. */
  85216. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85217. /**
  85218. * Gets a string idenfifying the name of the class
  85219. * @returns "Node" string
  85220. */
  85221. getClassName(): string;
  85222. /** @hidden */
  85223. readonly _isNode: boolean;
  85224. /**
  85225. * An event triggered when the mesh is disposed
  85226. */
  85227. onDisposeObservable: Observable<Node>;
  85228. private _onDisposeObserver;
  85229. /**
  85230. * Sets a callback that will be raised when the node will be disposed
  85231. */
  85232. onDispose: () => void;
  85233. /**
  85234. * Creates a new Node
  85235. * @param name the name and id to be given to this node
  85236. * @param scene the scene this node will be added to
  85237. * @param addToRootNodes the node will be added to scene.rootNodes
  85238. */
  85239. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  85240. /**
  85241. * Gets the scene of the node
  85242. * @returns a scene
  85243. */
  85244. getScene(): Scene;
  85245. /**
  85246. * Gets the engine of the node
  85247. * @returns a Engine
  85248. */
  85249. getEngine(): Engine;
  85250. private _behaviors;
  85251. /**
  85252. * Attach a behavior to the node
  85253. * @see http://doc.babylonjs.com/features/behaviour
  85254. * @param behavior defines the behavior to attach
  85255. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  85256. * @returns the current Node
  85257. */
  85258. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  85259. /**
  85260. * Remove an attached behavior
  85261. * @see http://doc.babylonjs.com/features/behaviour
  85262. * @param behavior defines the behavior to attach
  85263. * @returns the current Node
  85264. */
  85265. removeBehavior(behavior: Behavior<Node>): Node;
  85266. /**
  85267. * Gets the list of attached behaviors
  85268. * @see http://doc.babylonjs.com/features/behaviour
  85269. */
  85270. readonly behaviors: Behavior<Node>[];
  85271. /**
  85272. * Gets an attached behavior by name
  85273. * @param name defines the name of the behavior to look for
  85274. * @see http://doc.babylonjs.com/features/behaviour
  85275. * @returns null if behavior was not found else the requested behavior
  85276. */
  85277. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  85278. /**
  85279. * Returns the latest update of the World matrix
  85280. * @returns a Matrix
  85281. */
  85282. getWorldMatrix(): Matrix;
  85283. /** @hidden */
  85284. _getWorldMatrixDeterminant(): number;
  85285. /**
  85286. * Returns directly the latest state of the mesh World matrix.
  85287. * A Matrix is returned.
  85288. */
  85289. readonly worldMatrixFromCache: Matrix;
  85290. /** @hidden */
  85291. _initCache(): void;
  85292. /** @hidden */
  85293. updateCache(force?: boolean): void;
  85294. /** @hidden */
  85295. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  85296. /** @hidden */
  85297. _updateCache(ignoreParentClass?: boolean): void;
  85298. /** @hidden */
  85299. _isSynchronized(): boolean;
  85300. /** @hidden */
  85301. _markSyncedWithParent(): void;
  85302. /** @hidden */
  85303. isSynchronizedWithParent(): boolean;
  85304. /** @hidden */
  85305. isSynchronized(): boolean;
  85306. /**
  85307. * Is this node ready to be used/rendered
  85308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85309. * @return true if the node is ready
  85310. */
  85311. isReady(completeCheck?: boolean): boolean;
  85312. /**
  85313. * Is this node enabled?
  85314. * 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
  85315. * @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
  85316. * @return whether this node (and its parent) is enabled
  85317. */
  85318. isEnabled(checkAncestors?: boolean): boolean;
  85319. /** @hidden */
  85320. protected _syncParentEnabledState(): void;
  85321. /**
  85322. * Set the enabled state of this node
  85323. * @param value defines the new enabled state
  85324. */
  85325. setEnabled(value: boolean): void;
  85326. /**
  85327. * Is this node a descendant of the given node?
  85328. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  85329. * @param ancestor defines the parent node to inspect
  85330. * @returns a boolean indicating if this node is a descendant of the given node
  85331. */
  85332. isDescendantOf(ancestor: Node): boolean;
  85333. /** @hidden */
  85334. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  85335. /**
  85336. * Will return all nodes that have this node as ascendant
  85337. * @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
  85338. * @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
  85339. * @return all children nodes of all types
  85340. */
  85341. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  85342. /**
  85343. * Get all child-meshes of this node
  85344. * @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)
  85345. * @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
  85346. * @returns an array of AbstractMesh
  85347. */
  85348. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  85349. /**
  85350. * Get all direct children of this node
  85351. * @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
  85352. * @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)
  85353. * @returns an array of Node
  85354. */
  85355. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  85356. /** @hidden */
  85357. _setReady(state: boolean): void;
  85358. /**
  85359. * Get an animation by name
  85360. * @param name defines the name of the animation to look for
  85361. * @returns null if not found else the requested animation
  85362. */
  85363. getAnimationByName(name: string): Nullable<Animation>;
  85364. /**
  85365. * Creates an animation range for this node
  85366. * @param name defines the name of the range
  85367. * @param from defines the starting key
  85368. * @param to defines the end key
  85369. */
  85370. createAnimationRange(name: string, from: number, to: number): void;
  85371. /**
  85372. * Delete a specific animation range
  85373. * @param name defines the name of the range to delete
  85374. * @param deleteFrames defines if animation frames from the range must be deleted as well
  85375. */
  85376. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  85377. /**
  85378. * Get an animation range by name
  85379. * @param name defines the name of the animation range to look for
  85380. * @returns null if not found else the requested animation range
  85381. */
  85382. getAnimationRange(name: string): Nullable<AnimationRange>;
  85383. /**
  85384. * Gets the list of all animation ranges defined on this node
  85385. * @returns an array
  85386. */
  85387. getAnimationRanges(): Nullable<AnimationRange>[];
  85388. /**
  85389. * Will start the animation sequence
  85390. * @param name defines the range frames for animation sequence
  85391. * @param loop defines if the animation should loop (false by default)
  85392. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  85393. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  85394. * @returns the object created for this animation. If range does not exist, it will return null
  85395. */
  85396. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85397. /**
  85398. * Serialize animation ranges into a JSON compatible object
  85399. * @returns serialization object
  85400. */
  85401. serializeAnimationRanges(): any;
  85402. /**
  85403. * Computes the world matrix of the node
  85404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85405. * @returns the world matrix
  85406. */
  85407. computeWorldMatrix(force?: boolean): Matrix;
  85408. /**
  85409. * Releases resources associated with this node.
  85410. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85411. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85412. */
  85413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85414. /**
  85415. * Parse animation range data from a serialization object and store them into a given node
  85416. * @param node defines where to store the animation ranges
  85417. * @param parsedNode defines the serialization object to read data from
  85418. * @param scene defines the hosting scene
  85419. */
  85420. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  85421. /**
  85422. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  85423. * @param includeDescendants Include bounding info from descendants as well (true by default)
  85424. * @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
  85425. * @returns the new bounding vectors
  85426. */
  85427. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  85428. min: Vector3;
  85429. max: Vector3;
  85430. };
  85431. }
  85432. }
  85433. declare module BABYLON {
  85434. /**
  85435. * @hidden
  85436. */
  85437. export class _IAnimationState {
  85438. key: number;
  85439. repeatCount: number;
  85440. workValue?: any;
  85441. loopMode?: number;
  85442. offsetValue?: any;
  85443. highLimitValue?: any;
  85444. }
  85445. /**
  85446. * Class used to store any kind of animation
  85447. */
  85448. export class Animation {
  85449. /**Name of the animation */
  85450. name: string;
  85451. /**Property to animate */
  85452. targetProperty: string;
  85453. /**The frames per second of the animation */
  85454. framePerSecond: number;
  85455. /**The data type of the animation */
  85456. dataType: number;
  85457. /**The loop mode of the animation */
  85458. loopMode?: number | undefined;
  85459. /**Specifies if blending should be enabled */
  85460. enableBlending?: boolean | undefined;
  85461. /**
  85462. * Use matrix interpolation instead of using direct key value when animating matrices
  85463. */
  85464. static AllowMatricesInterpolation: boolean;
  85465. /**
  85466. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  85467. */
  85468. static AllowMatrixDecomposeForInterpolation: boolean;
  85469. /**
  85470. * Stores the key frames of the animation
  85471. */
  85472. private _keys;
  85473. /**
  85474. * Stores the easing function of the animation
  85475. */
  85476. private _easingFunction;
  85477. /**
  85478. * @hidden Internal use only
  85479. */
  85480. _runtimeAnimations: RuntimeAnimation[];
  85481. /**
  85482. * The set of event that will be linked to this animation
  85483. */
  85484. private _events;
  85485. /**
  85486. * Stores an array of target property paths
  85487. */
  85488. targetPropertyPath: string[];
  85489. /**
  85490. * Stores the blending speed of the animation
  85491. */
  85492. blendingSpeed: number;
  85493. /**
  85494. * Stores the animation ranges for the animation
  85495. */
  85496. private _ranges;
  85497. /**
  85498. * @hidden Internal use
  85499. */
  85500. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  85501. /**
  85502. * Sets up an animation
  85503. * @param property The property to animate
  85504. * @param animationType The animation type to apply
  85505. * @param framePerSecond The frames per second of the animation
  85506. * @param easingFunction The easing function used in the animation
  85507. * @returns The created animation
  85508. */
  85509. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  85510. /**
  85511. * Create and start an animation on a node
  85512. * @param name defines the name of the global animation that will be run on all nodes
  85513. * @param node defines the root node where the animation will take place
  85514. * @param targetProperty defines property to animate
  85515. * @param framePerSecond defines the number of frame per second yo use
  85516. * @param totalFrame defines the number of frames in total
  85517. * @param from defines the initial value
  85518. * @param to defines the final value
  85519. * @param loopMode defines which loop mode you want to use (off by default)
  85520. * @param easingFunction defines the easing function to use (linear by default)
  85521. * @param onAnimationEnd defines the callback to call when animation end
  85522. * @returns the animatable created for this animation
  85523. */
  85524. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85525. /**
  85526. * Create and start an animation on a node and its descendants
  85527. * @param name defines the name of the global animation that will be run on all nodes
  85528. * @param node defines the root node where the animation will take place
  85529. * @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
  85530. * @param targetProperty defines property to animate
  85531. * @param framePerSecond defines the number of frame per second to use
  85532. * @param totalFrame defines the number of frames in total
  85533. * @param from defines the initial value
  85534. * @param to defines the final value
  85535. * @param loopMode defines which loop mode you want to use (off by default)
  85536. * @param easingFunction defines the easing function to use (linear by default)
  85537. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  85538. * @returns the list of animatables created for all nodes
  85539. * @example https://www.babylonjs-playground.com/#MH0VLI
  85540. */
  85541. 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[]>;
  85542. /**
  85543. * Creates a new animation, merges it with the existing animations and starts it
  85544. * @param name Name of the animation
  85545. * @param node Node which contains the scene that begins the animations
  85546. * @param targetProperty Specifies which property to animate
  85547. * @param framePerSecond The frames per second of the animation
  85548. * @param totalFrame The total number of frames
  85549. * @param from The frame at the beginning of the animation
  85550. * @param to The frame at the end of the animation
  85551. * @param loopMode Specifies the loop mode of the animation
  85552. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  85553. * @param onAnimationEnd Callback to run once the animation is complete
  85554. * @returns Nullable animation
  85555. */
  85556. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  85557. /**
  85558. * Transition property of an host to the target Value
  85559. * @param property The property to transition
  85560. * @param targetValue The target Value of the property
  85561. * @param host The object where the property to animate belongs
  85562. * @param scene Scene used to run the animation
  85563. * @param frameRate Framerate (in frame/s) to use
  85564. * @param transition The transition type we want to use
  85565. * @param duration The duration of the animation, in milliseconds
  85566. * @param onAnimationEnd Callback trigger at the end of the animation
  85567. * @returns Nullable animation
  85568. */
  85569. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  85570. /**
  85571. * Return the array of runtime animations currently using this animation
  85572. */
  85573. readonly runtimeAnimations: RuntimeAnimation[];
  85574. /**
  85575. * Specifies if any of the runtime animations are currently running
  85576. */
  85577. readonly hasRunningRuntimeAnimations: boolean;
  85578. /**
  85579. * Initializes the animation
  85580. * @param name Name of the animation
  85581. * @param targetProperty Property to animate
  85582. * @param framePerSecond The frames per second of the animation
  85583. * @param dataType The data type of the animation
  85584. * @param loopMode The loop mode of the animation
  85585. * @param enableBlending Specifies if blending should be enabled
  85586. */
  85587. constructor(
  85588. /**Name of the animation */
  85589. name: string,
  85590. /**Property to animate */
  85591. targetProperty: string,
  85592. /**The frames per second of the animation */
  85593. framePerSecond: number,
  85594. /**The data type of the animation */
  85595. dataType: number,
  85596. /**The loop mode of the animation */
  85597. loopMode?: number | undefined,
  85598. /**Specifies if blending should be enabled */
  85599. enableBlending?: boolean | undefined);
  85600. /**
  85601. * Converts the animation to a string
  85602. * @param fullDetails support for multiple levels of logging within scene loading
  85603. * @returns String form of the animation
  85604. */
  85605. toString(fullDetails?: boolean): string;
  85606. /**
  85607. * Add an event to this animation
  85608. * @param event Event to add
  85609. */
  85610. addEvent(event: AnimationEvent): void;
  85611. /**
  85612. * Remove all events found at the given frame
  85613. * @param frame The frame to remove events from
  85614. */
  85615. removeEvents(frame: number): void;
  85616. /**
  85617. * Retrieves all the events from the animation
  85618. * @returns Events from the animation
  85619. */
  85620. getEvents(): AnimationEvent[];
  85621. /**
  85622. * Creates an animation range
  85623. * @param name Name of the animation range
  85624. * @param from Starting frame of the animation range
  85625. * @param to Ending frame of the animation
  85626. */
  85627. createRange(name: string, from: number, to: number): void;
  85628. /**
  85629. * Deletes an animation range by name
  85630. * @param name Name of the animation range to delete
  85631. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  85632. */
  85633. deleteRange(name: string, deleteFrames?: boolean): void;
  85634. /**
  85635. * Gets the animation range by name, or null if not defined
  85636. * @param name Name of the animation range
  85637. * @returns Nullable animation range
  85638. */
  85639. getRange(name: string): Nullable<AnimationRange>;
  85640. /**
  85641. * Gets the key frames from the animation
  85642. * @returns The key frames of the animation
  85643. */
  85644. getKeys(): Array<IAnimationKey>;
  85645. /**
  85646. * Gets the highest frame rate of the animation
  85647. * @returns Highest frame rate of the animation
  85648. */
  85649. getHighestFrame(): number;
  85650. /**
  85651. * Gets the easing function of the animation
  85652. * @returns Easing function of the animation
  85653. */
  85654. getEasingFunction(): IEasingFunction;
  85655. /**
  85656. * Sets the easing function of the animation
  85657. * @param easingFunction A custom mathematical formula for animation
  85658. */
  85659. setEasingFunction(easingFunction: EasingFunction): void;
  85660. /**
  85661. * Interpolates a scalar linearly
  85662. * @param startValue Start value of the animation curve
  85663. * @param endValue End value of the animation curve
  85664. * @param gradient Scalar amount to interpolate
  85665. * @returns Interpolated scalar value
  85666. */
  85667. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85668. /**
  85669. * Interpolates a scalar cubically
  85670. * @param startValue Start value of the animation curve
  85671. * @param outTangent End tangent of the animation
  85672. * @param endValue End value of the animation curve
  85673. * @param inTangent Start tangent of the animation curve
  85674. * @param gradient Scalar amount to interpolate
  85675. * @returns Interpolated scalar value
  85676. */
  85677. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85678. /**
  85679. * Interpolates a quaternion using a spherical linear interpolation
  85680. * @param startValue Start value of the animation curve
  85681. * @param endValue End value of the animation curve
  85682. * @param gradient Scalar amount to interpolate
  85683. * @returns Interpolated quaternion value
  85684. */
  85685. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85686. /**
  85687. * Interpolates a quaternion cubically
  85688. * @param startValue Start value of the animation curve
  85689. * @param outTangent End tangent of the animation curve
  85690. * @param endValue End value of the animation curve
  85691. * @param inTangent Start tangent of the animation curve
  85692. * @param gradient Scalar amount to interpolate
  85693. * @returns Interpolated quaternion value
  85694. */
  85695. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85696. /**
  85697. * Interpolates a Vector3 linearl
  85698. * @param startValue Start value of the animation curve
  85699. * @param endValue End value of the animation curve
  85700. * @param gradient Scalar amount to interpolate
  85701. * @returns Interpolated scalar value
  85702. */
  85703. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85704. /**
  85705. * Interpolates a Vector3 cubically
  85706. * @param startValue Start value of the animation curve
  85707. * @param outTangent End tangent of the animation
  85708. * @param endValue End value of the animation curve
  85709. * @param inTangent Start tangent of the animation curve
  85710. * @param gradient Scalar amount to interpolate
  85711. * @returns InterpolatedVector3 value
  85712. */
  85713. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85714. /**
  85715. * Interpolates a Vector2 linearly
  85716. * @param startValue Start value of the animation curve
  85717. * @param endValue End value of the animation curve
  85718. * @param gradient Scalar amount to interpolate
  85719. * @returns Interpolated Vector2 value
  85720. */
  85721. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85722. /**
  85723. * Interpolates a Vector2 cubically
  85724. * @param startValue Start value of the animation curve
  85725. * @param outTangent End tangent of the animation
  85726. * @param endValue End value of the animation curve
  85727. * @param inTangent Start tangent of the animation curve
  85728. * @param gradient Scalar amount to interpolate
  85729. * @returns Interpolated Vector2 value
  85730. */
  85731. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85732. /**
  85733. * Interpolates a size linearly
  85734. * @param startValue Start value of the animation curve
  85735. * @param endValue End value of the animation curve
  85736. * @param gradient Scalar amount to interpolate
  85737. * @returns Interpolated Size value
  85738. */
  85739. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85740. /**
  85741. * Interpolates a Color3 linearly
  85742. * @param startValue Start value of the animation curve
  85743. * @param endValue End value of the animation curve
  85744. * @param gradient Scalar amount to interpolate
  85745. * @returns Interpolated Color3 value
  85746. */
  85747. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85748. /**
  85749. * @hidden Internal use only
  85750. */
  85751. _getKeyValue(value: any): any;
  85752. /**
  85753. * @hidden Internal use only
  85754. */
  85755. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85756. /**
  85757. * Defines the function to use to interpolate matrices
  85758. * @param startValue defines the start matrix
  85759. * @param endValue defines the end matrix
  85760. * @param gradient defines the gradient between both matrices
  85761. * @param result defines an optional target matrix where to store the interpolation
  85762. * @returns the interpolated matrix
  85763. */
  85764. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85765. /**
  85766. * Makes a copy of the animation
  85767. * @returns Cloned animation
  85768. */
  85769. clone(): Animation;
  85770. /**
  85771. * Sets the key frames of the animation
  85772. * @param values The animation key frames to set
  85773. */
  85774. setKeys(values: Array<IAnimationKey>): void;
  85775. /**
  85776. * Serializes the animation to an object
  85777. * @returns Serialized object
  85778. */
  85779. serialize(): any;
  85780. /**
  85781. * Float animation type
  85782. */
  85783. private static _ANIMATIONTYPE_FLOAT;
  85784. /**
  85785. * Vector3 animation type
  85786. */
  85787. private static _ANIMATIONTYPE_VECTOR3;
  85788. /**
  85789. * Quaternion animation type
  85790. */
  85791. private static _ANIMATIONTYPE_QUATERNION;
  85792. /**
  85793. * Matrix animation type
  85794. */
  85795. private static _ANIMATIONTYPE_MATRIX;
  85796. /**
  85797. * Color3 animation type
  85798. */
  85799. private static _ANIMATIONTYPE_COLOR3;
  85800. /**
  85801. * Vector2 animation type
  85802. */
  85803. private static _ANIMATIONTYPE_VECTOR2;
  85804. /**
  85805. * Size animation type
  85806. */
  85807. private static _ANIMATIONTYPE_SIZE;
  85808. /**
  85809. * Relative Loop Mode
  85810. */
  85811. private static _ANIMATIONLOOPMODE_RELATIVE;
  85812. /**
  85813. * Cycle Loop Mode
  85814. */
  85815. private static _ANIMATIONLOOPMODE_CYCLE;
  85816. /**
  85817. * Constant Loop Mode
  85818. */
  85819. private static _ANIMATIONLOOPMODE_CONSTANT;
  85820. /**
  85821. * Get the float animation type
  85822. */
  85823. static readonly ANIMATIONTYPE_FLOAT: number;
  85824. /**
  85825. * Get the Vector3 animation type
  85826. */
  85827. static readonly ANIMATIONTYPE_VECTOR3: number;
  85828. /**
  85829. * Get the Vector2 animation type
  85830. */
  85831. static readonly ANIMATIONTYPE_VECTOR2: number;
  85832. /**
  85833. * Get the Size animation type
  85834. */
  85835. static readonly ANIMATIONTYPE_SIZE: number;
  85836. /**
  85837. * Get the Quaternion animation type
  85838. */
  85839. static readonly ANIMATIONTYPE_QUATERNION: number;
  85840. /**
  85841. * Get the Matrix animation type
  85842. */
  85843. static readonly ANIMATIONTYPE_MATRIX: number;
  85844. /**
  85845. * Get the Color3 animation type
  85846. */
  85847. static readonly ANIMATIONTYPE_COLOR3: number;
  85848. /**
  85849. * Get the Relative Loop Mode
  85850. */
  85851. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85852. /**
  85853. * Get the Cycle Loop Mode
  85854. */
  85855. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85856. /**
  85857. * Get the Constant Loop Mode
  85858. */
  85859. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85860. /** @hidden */
  85861. static _UniversalLerp(left: any, right: any, amount: number): any;
  85862. /**
  85863. * Parses an animation object and creates an animation
  85864. * @param parsedAnimation Parsed animation object
  85865. * @returns Animation object
  85866. */
  85867. static Parse(parsedAnimation: any): Animation;
  85868. /**
  85869. * Appends the serialized animations from the source animations
  85870. * @param source Source containing the animations
  85871. * @param destination Target to store the animations
  85872. */
  85873. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85874. }
  85875. }
  85876. declare module BABYLON {
  85877. /**
  85878. * Base class of all the textures in babylon.
  85879. * It groups all the common properties the materials, post process, lights... might need
  85880. * in order to make a correct use of the texture.
  85881. */
  85882. export class BaseTexture implements IAnimatable {
  85883. /**
  85884. * Default anisotropic filtering level for the application.
  85885. * It is set to 4 as a good tradeoff between perf and quality.
  85886. */
  85887. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85888. /**
  85889. * Gets or sets the unique id of the texture
  85890. */
  85891. uniqueId: number;
  85892. /**
  85893. * Define the name of the texture.
  85894. */
  85895. name: string;
  85896. /**
  85897. * Gets or sets an object used to store user defined information.
  85898. */
  85899. metadata: any;
  85900. /**
  85901. * For internal use only. Please do not use.
  85902. */
  85903. reservedDataStore: any;
  85904. private _hasAlpha;
  85905. /**
  85906. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85907. */
  85908. hasAlpha: boolean;
  85909. /**
  85910. * Defines if the alpha value should be determined via the rgb values.
  85911. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85912. */
  85913. getAlphaFromRGB: boolean;
  85914. /**
  85915. * Intensity or strength of the texture.
  85916. * It is commonly used by materials to fine tune the intensity of the texture
  85917. */
  85918. level: number;
  85919. /**
  85920. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85921. * This is part of the texture as textures usually maps to one uv set.
  85922. */
  85923. coordinatesIndex: number;
  85924. private _coordinatesMode;
  85925. /**
  85926. * How a texture is mapped.
  85927. *
  85928. * | Value | Type | Description |
  85929. * | ----- | ----------------------------------- | ----------- |
  85930. * | 0 | EXPLICIT_MODE | |
  85931. * | 1 | SPHERICAL_MODE | |
  85932. * | 2 | PLANAR_MODE | |
  85933. * | 3 | CUBIC_MODE | |
  85934. * | 4 | PROJECTION_MODE | |
  85935. * | 5 | SKYBOX_MODE | |
  85936. * | 6 | INVCUBIC_MODE | |
  85937. * | 7 | EQUIRECTANGULAR_MODE | |
  85938. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85939. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85940. */
  85941. coordinatesMode: number;
  85942. /**
  85943. * | Value | Type | Description |
  85944. * | ----- | ------------------ | ----------- |
  85945. * | 0 | CLAMP_ADDRESSMODE | |
  85946. * | 1 | WRAP_ADDRESSMODE | |
  85947. * | 2 | MIRROR_ADDRESSMODE | |
  85948. */
  85949. wrapU: number;
  85950. /**
  85951. * | Value | Type | Description |
  85952. * | ----- | ------------------ | ----------- |
  85953. * | 0 | CLAMP_ADDRESSMODE | |
  85954. * | 1 | WRAP_ADDRESSMODE | |
  85955. * | 2 | MIRROR_ADDRESSMODE | |
  85956. */
  85957. wrapV: number;
  85958. /**
  85959. * | Value | Type | Description |
  85960. * | ----- | ------------------ | ----------- |
  85961. * | 0 | CLAMP_ADDRESSMODE | |
  85962. * | 1 | WRAP_ADDRESSMODE | |
  85963. * | 2 | MIRROR_ADDRESSMODE | |
  85964. */
  85965. wrapR: number;
  85966. /**
  85967. * With compliant hardware and browser (supporting anisotropic filtering)
  85968. * this defines the level of anisotropic filtering in the texture.
  85969. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85970. */
  85971. anisotropicFilteringLevel: number;
  85972. /**
  85973. * Define if the texture is a cube texture or if false a 2d texture.
  85974. */
  85975. isCube: boolean;
  85976. /**
  85977. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85978. */
  85979. is3D: boolean;
  85980. /**
  85981. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85982. * HDR texture are usually stored in linear space.
  85983. * This only impacts the PBR and Background materials
  85984. */
  85985. gammaSpace: boolean;
  85986. /**
  85987. * Gets whether or not the texture contains RGBD data.
  85988. */
  85989. readonly isRGBD: boolean;
  85990. /**
  85991. * Is Z inverted in the texture (useful in a cube texture).
  85992. */
  85993. invertZ: boolean;
  85994. /**
  85995. * Are mip maps generated for this texture or not.
  85996. */
  85997. readonly noMipmap: boolean;
  85998. /**
  85999. * @hidden
  86000. */
  86001. lodLevelInAlpha: boolean;
  86002. /**
  86003. * With prefiltered texture, defined the offset used during the prefiltering steps.
  86004. */
  86005. lodGenerationOffset: number;
  86006. /**
  86007. * With prefiltered texture, defined the scale used during the prefiltering steps.
  86008. */
  86009. lodGenerationScale: number;
  86010. /**
  86011. * Define if the texture is a render target.
  86012. */
  86013. isRenderTarget: boolean;
  86014. /**
  86015. * Define the unique id of the texture in the scene.
  86016. */
  86017. readonly uid: string;
  86018. /**
  86019. * Return a string representation of the texture.
  86020. * @returns the texture as a string
  86021. */
  86022. toString(): string;
  86023. /**
  86024. * Get the class name of the texture.
  86025. * @returns "BaseTexture"
  86026. */
  86027. getClassName(): string;
  86028. /**
  86029. * Define the list of animation attached to the texture.
  86030. */
  86031. animations: Animation[];
  86032. /**
  86033. * An event triggered when the texture is disposed.
  86034. */
  86035. onDisposeObservable: Observable<BaseTexture>;
  86036. private _onDisposeObserver;
  86037. /**
  86038. * Callback triggered when the texture has been disposed.
  86039. * Kept for back compatibility, you can use the onDisposeObservable instead.
  86040. */
  86041. onDispose: () => void;
  86042. /**
  86043. * Define the current state of the loading sequence when in delayed load mode.
  86044. */
  86045. delayLoadState: number;
  86046. private _scene;
  86047. /** @hidden */
  86048. _texture: Nullable<InternalTexture>;
  86049. private _uid;
  86050. /**
  86051. * Define if the texture is preventinga material to render or not.
  86052. * If not and the texture is not ready, the engine will use a default black texture instead.
  86053. */
  86054. readonly isBlocking: boolean;
  86055. /**
  86056. * Instantiates a new BaseTexture.
  86057. * Base class of all the textures in babylon.
  86058. * It groups all the common properties the materials, post process, lights... might need
  86059. * in order to make a correct use of the texture.
  86060. * @param scene Define the scene the texture blongs to
  86061. */
  86062. constructor(scene: Nullable<Scene>);
  86063. /**
  86064. * Get the scene the texture belongs to.
  86065. * @returns the scene or null if undefined
  86066. */
  86067. getScene(): Nullable<Scene>;
  86068. /**
  86069. * Get the texture transform matrix used to offset tile the texture for istance.
  86070. * @returns the transformation matrix
  86071. */
  86072. getTextureMatrix(): Matrix;
  86073. /**
  86074. * Get the texture reflection matrix used to rotate/transform the reflection.
  86075. * @returns the reflection matrix
  86076. */
  86077. getReflectionTextureMatrix(): Matrix;
  86078. /**
  86079. * Get the underlying lower level texture from Babylon.
  86080. * @returns the insternal texture
  86081. */
  86082. getInternalTexture(): Nullable<InternalTexture>;
  86083. /**
  86084. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  86085. * @returns true if ready or not blocking
  86086. */
  86087. isReadyOrNotBlocking(): boolean;
  86088. /**
  86089. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86090. * @returns true if fully ready
  86091. */
  86092. isReady(): boolean;
  86093. private _cachedSize;
  86094. /**
  86095. * Get the size of the texture.
  86096. * @returns the texture size.
  86097. */
  86098. getSize(): ISize;
  86099. /**
  86100. * Get the base size of the texture.
  86101. * It can be different from the size if the texture has been resized for POT for instance
  86102. * @returns the base size
  86103. */
  86104. getBaseSize(): ISize;
  86105. /**
  86106. * Update the sampling mode of the texture.
  86107. * Default is Trilinear mode.
  86108. *
  86109. * | Value | Type | Description |
  86110. * | ----- | ------------------ | ----------- |
  86111. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86112. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86113. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86114. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86115. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86116. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86117. * | 7 | NEAREST_LINEAR | |
  86118. * | 8 | NEAREST_NEAREST | |
  86119. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86120. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86121. * | 11 | LINEAR_LINEAR | |
  86122. * | 12 | LINEAR_NEAREST | |
  86123. *
  86124. * > _mag_: magnification filter (close to the viewer)
  86125. * > _min_: minification filter (far from the viewer)
  86126. * > _mip_: filter used between mip map levels
  86127. *@param samplingMode Define the new sampling mode of the texture
  86128. */
  86129. updateSamplingMode(samplingMode: number): void;
  86130. /**
  86131. * Scales the texture if is `canRescale()`
  86132. * @param ratio the resize factor we want to use to rescale
  86133. */
  86134. scale(ratio: number): void;
  86135. /**
  86136. * Get if the texture can rescale.
  86137. */
  86138. readonly canRescale: boolean;
  86139. /** @hidden */
  86140. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  86141. /** @hidden */
  86142. _rebuild(): void;
  86143. /**
  86144. * Triggers the load sequence in delayed load mode.
  86145. */
  86146. delayLoad(): void;
  86147. /**
  86148. * Clones the texture.
  86149. * @returns the cloned texture
  86150. */
  86151. clone(): Nullable<BaseTexture>;
  86152. /**
  86153. * Get the texture underlying type (INT, FLOAT...)
  86154. */
  86155. readonly textureType: number;
  86156. /**
  86157. * Get the texture underlying format (RGB, RGBA...)
  86158. */
  86159. readonly textureFormat: number;
  86160. /**
  86161. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  86162. * This will returns an RGBA array buffer containing either in values (0-255) or
  86163. * float values (0-1) depending of the underlying buffer type.
  86164. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  86165. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  86166. * @param buffer defines a user defined buffer to fill with data (can be null)
  86167. * @returns The Array buffer containing the pixels data.
  86168. */
  86169. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  86170. /**
  86171. * Release and destroy the underlying lower level texture aka internalTexture.
  86172. */
  86173. releaseInternalTexture(): void;
  86174. /**
  86175. * Get the polynomial representation of the texture data.
  86176. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  86177. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  86178. */
  86179. sphericalPolynomial: Nullable<SphericalPolynomial>;
  86180. /** @hidden */
  86181. readonly _lodTextureHigh: Nullable<BaseTexture>;
  86182. /** @hidden */
  86183. readonly _lodTextureMid: Nullable<BaseTexture>;
  86184. /** @hidden */
  86185. readonly _lodTextureLow: Nullable<BaseTexture>;
  86186. /**
  86187. * Dispose the texture and release its associated resources.
  86188. */
  86189. dispose(): void;
  86190. /**
  86191. * Serialize the texture into a JSON representation that can be parsed later on.
  86192. * @returns the JSON representation of the texture
  86193. */
  86194. serialize(): any;
  86195. /**
  86196. * Helper function to be called back once a list of texture contains only ready textures.
  86197. * @param textures Define the list of textures to wait for
  86198. * @param callback Define the callback triggered once the entire list will be ready
  86199. */
  86200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  86201. }
  86202. }
  86203. declare module BABYLON {
  86204. /**
  86205. * Uniform buffer objects.
  86206. *
  86207. * Handles blocks of uniform on the GPU.
  86208. *
  86209. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86210. *
  86211. * For more information, please refer to :
  86212. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86213. */
  86214. export class UniformBuffer {
  86215. private _engine;
  86216. private _buffer;
  86217. private _data;
  86218. private _bufferData;
  86219. private _dynamic?;
  86220. private _uniformLocations;
  86221. private _uniformSizes;
  86222. private _uniformLocationPointer;
  86223. private _needSync;
  86224. private _noUBO;
  86225. private _currentEffect;
  86226. private static _MAX_UNIFORM_SIZE;
  86227. private static _tempBuffer;
  86228. /**
  86229. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86230. * This is dynamic to allow compat with webgl 1 and 2.
  86231. * You will need to pass the name of the uniform as well as the value.
  86232. */
  86233. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86234. /**
  86235. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86236. * This is dynamic to allow compat with webgl 1 and 2.
  86237. * You will need to pass the name of the uniform as well as the value.
  86238. */
  86239. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86240. /**
  86241. * Lambda to Update a single float in a uniform buffer.
  86242. * This is dynamic to allow compat with webgl 1 and 2.
  86243. * You will need to pass the name of the uniform as well as the value.
  86244. */
  86245. updateFloat: (name: string, x: number) => void;
  86246. /**
  86247. * Lambda to Update a vec2 of float in a uniform buffer.
  86248. * This is dynamic to allow compat with webgl 1 and 2.
  86249. * You will need to pass the name of the uniform as well as the value.
  86250. */
  86251. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86252. /**
  86253. * Lambda to Update a vec3 of float in a uniform buffer.
  86254. * This is dynamic to allow compat with webgl 1 and 2.
  86255. * You will need to pass the name of the uniform as well as the value.
  86256. */
  86257. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86258. /**
  86259. * Lambda to Update a vec4 of float in a uniform buffer.
  86260. * This is dynamic to allow compat with webgl 1 and 2.
  86261. * You will need to pass the name of the uniform as well as the value.
  86262. */
  86263. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86264. /**
  86265. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86266. * This is dynamic to allow compat with webgl 1 and 2.
  86267. * You will need to pass the name of the uniform as well as the value.
  86268. */
  86269. updateMatrix: (name: string, mat: Matrix) => void;
  86270. /**
  86271. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86272. * This is dynamic to allow compat with webgl 1 and 2.
  86273. * You will need to pass the name of the uniform as well as the value.
  86274. */
  86275. updateVector3: (name: string, vector: Vector3) => void;
  86276. /**
  86277. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86278. * This is dynamic to allow compat with webgl 1 and 2.
  86279. * You will need to pass the name of the uniform as well as the value.
  86280. */
  86281. updateVector4: (name: string, vector: Vector4) => void;
  86282. /**
  86283. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86284. * This is dynamic to allow compat with webgl 1 and 2.
  86285. * You will need to pass the name of the uniform as well as the value.
  86286. */
  86287. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86288. /**
  86289. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86290. * This is dynamic to allow compat with webgl 1 and 2.
  86291. * You will need to pass the name of the uniform as well as the value.
  86292. */
  86293. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86294. /**
  86295. * Instantiates a new Uniform buffer objects.
  86296. *
  86297. * Handles blocks of uniform on the GPU.
  86298. *
  86299. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86300. *
  86301. * For more information, please refer to :
  86302. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86303. * @param engine Define the engine the buffer is associated with
  86304. * @param data Define the data contained in the buffer
  86305. * @param dynamic Define if the buffer is updatable
  86306. */
  86307. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86308. /**
  86309. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86310. * or just falling back on setUniformXXX calls.
  86311. */
  86312. readonly useUbo: boolean;
  86313. /**
  86314. * Indicates if the WebGL underlying uniform buffer is in sync
  86315. * with the javascript cache data.
  86316. */
  86317. readonly isSync: boolean;
  86318. /**
  86319. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86320. * Also, a dynamic UniformBuffer will disable cache verification and always
  86321. * update the underlying WebGL uniform buffer to the GPU.
  86322. * @returns if Dynamic, otherwise false
  86323. */
  86324. isDynamic(): boolean;
  86325. /**
  86326. * The data cache on JS side.
  86327. * @returns the underlying data as a float array
  86328. */
  86329. getData(): Float32Array;
  86330. /**
  86331. * The underlying WebGL Uniform buffer.
  86332. * @returns the webgl buffer
  86333. */
  86334. getBuffer(): Nullable<DataBuffer>;
  86335. /**
  86336. * std140 layout specifies how to align data within an UBO structure.
  86337. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86338. * for specs.
  86339. */
  86340. private _fillAlignment;
  86341. /**
  86342. * Adds an uniform in the buffer.
  86343. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86344. * for the layout to be correct !
  86345. * @param name Name of the uniform, as used in the uniform block in the shader.
  86346. * @param size Data size, or data directly.
  86347. */
  86348. addUniform(name: string, size: number | number[]): void;
  86349. /**
  86350. * Adds a Matrix 4x4 to the uniform buffer.
  86351. * @param name Name of the uniform, as used in the uniform block in the shader.
  86352. * @param mat A 4x4 matrix.
  86353. */
  86354. addMatrix(name: string, mat: Matrix): void;
  86355. /**
  86356. * Adds a vec2 to the uniform buffer.
  86357. * @param name Name of the uniform, as used in the uniform block in the shader.
  86358. * @param x Define the x component value of the vec2
  86359. * @param y Define the y component value of the vec2
  86360. */
  86361. addFloat2(name: string, x: number, y: number): void;
  86362. /**
  86363. * Adds a vec3 to the uniform buffer.
  86364. * @param name Name of the uniform, as used in the uniform block in the shader.
  86365. * @param x Define the x component value of the vec3
  86366. * @param y Define the y component value of the vec3
  86367. * @param z Define the z component value of the vec3
  86368. */
  86369. addFloat3(name: string, x: number, y: number, z: number): void;
  86370. /**
  86371. * Adds a vec3 to the uniform buffer.
  86372. * @param name Name of the uniform, as used in the uniform block in the shader.
  86373. * @param color Define the vec3 from a Color
  86374. */
  86375. addColor3(name: string, color: Color3): void;
  86376. /**
  86377. * Adds a vec4 to the uniform buffer.
  86378. * @param name Name of the uniform, as used in the uniform block in the shader.
  86379. * @param color Define the rgb components from a Color
  86380. * @param alpha Define the a component of the vec4
  86381. */
  86382. addColor4(name: string, color: Color3, alpha: number): void;
  86383. /**
  86384. * Adds a vec3 to the uniform buffer.
  86385. * @param name Name of the uniform, as used in the uniform block in the shader.
  86386. * @param vector Define the vec3 components from a Vector
  86387. */
  86388. addVector3(name: string, vector: Vector3): void;
  86389. /**
  86390. * Adds a Matrix 3x3 to the uniform buffer.
  86391. * @param name Name of the uniform, as used in the uniform block in the shader.
  86392. */
  86393. addMatrix3x3(name: string): void;
  86394. /**
  86395. * Adds a Matrix 2x2 to the uniform buffer.
  86396. * @param name Name of the uniform, as used in the uniform block in the shader.
  86397. */
  86398. addMatrix2x2(name: string): void;
  86399. /**
  86400. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86401. */
  86402. create(): void;
  86403. /** @hidden */
  86404. _rebuild(): void;
  86405. /**
  86406. * Updates the WebGL Uniform Buffer on the GPU.
  86407. * If the `dynamic` flag is set to true, no cache comparison is done.
  86408. * Otherwise, the buffer will be updated only if the cache differs.
  86409. */
  86410. update(): void;
  86411. /**
  86412. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86413. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86414. * @param data Define the flattened data
  86415. * @param size Define the size of the data.
  86416. */
  86417. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86418. private _updateMatrix3x3ForUniform;
  86419. private _updateMatrix3x3ForEffect;
  86420. private _updateMatrix2x2ForEffect;
  86421. private _updateMatrix2x2ForUniform;
  86422. private _updateFloatForEffect;
  86423. private _updateFloatForUniform;
  86424. private _updateFloat2ForEffect;
  86425. private _updateFloat2ForUniform;
  86426. private _updateFloat3ForEffect;
  86427. private _updateFloat3ForUniform;
  86428. private _updateFloat4ForEffect;
  86429. private _updateFloat4ForUniform;
  86430. private _updateMatrixForEffect;
  86431. private _updateMatrixForUniform;
  86432. private _updateVector3ForEffect;
  86433. private _updateVector3ForUniform;
  86434. private _updateVector4ForEffect;
  86435. private _updateVector4ForUniform;
  86436. private _updateColor3ForEffect;
  86437. private _updateColor3ForUniform;
  86438. private _updateColor4ForEffect;
  86439. private _updateColor4ForUniform;
  86440. /**
  86441. * Sets a sampler uniform on the effect.
  86442. * @param name Define the name of the sampler.
  86443. * @param texture Define the texture to set in the sampler
  86444. */
  86445. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86446. /**
  86447. * Directly updates the value of the uniform in the cache AND on the GPU.
  86448. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86449. * @param data Define the flattened data
  86450. */
  86451. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86452. /**
  86453. * Binds this uniform buffer to an effect.
  86454. * @param effect Define the effect to bind the buffer to
  86455. * @param name Name of the uniform block in the shader.
  86456. */
  86457. bindToEffect(effect: Effect, name: string): void;
  86458. /**
  86459. * Disposes the uniform buffer.
  86460. */
  86461. dispose(): void;
  86462. }
  86463. }
  86464. declare module BABYLON {
  86465. /**
  86466. * Class used to work with sound analyzer using fast fourier transform (FFT)
  86467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86468. */
  86469. export class Analyser {
  86470. /**
  86471. * Gets or sets the smoothing
  86472. * @ignorenaming
  86473. */
  86474. SMOOTHING: number;
  86475. /**
  86476. * Gets or sets the FFT table size
  86477. * @ignorenaming
  86478. */
  86479. FFT_SIZE: number;
  86480. /**
  86481. * Gets or sets the bar graph amplitude
  86482. * @ignorenaming
  86483. */
  86484. BARGRAPHAMPLITUDE: number;
  86485. /**
  86486. * Gets or sets the position of the debug canvas
  86487. * @ignorenaming
  86488. */
  86489. DEBUGCANVASPOS: {
  86490. x: number;
  86491. y: number;
  86492. };
  86493. /**
  86494. * Gets or sets the debug canvas size
  86495. * @ignorenaming
  86496. */
  86497. DEBUGCANVASSIZE: {
  86498. width: number;
  86499. height: number;
  86500. };
  86501. private _byteFreqs;
  86502. private _byteTime;
  86503. private _floatFreqs;
  86504. private _webAudioAnalyser;
  86505. private _debugCanvas;
  86506. private _debugCanvasContext;
  86507. private _scene;
  86508. private _registerFunc;
  86509. private _audioEngine;
  86510. /**
  86511. * Creates a new analyser
  86512. * @param scene defines hosting scene
  86513. */
  86514. constructor(scene: Scene);
  86515. /**
  86516. * Get the number of data values you will have to play with for the visualization
  86517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86518. * @returns a number
  86519. */
  86520. getFrequencyBinCount(): number;
  86521. /**
  86522. * Gets the current frequency data as a byte array
  86523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86524. * @returns a Uint8Array
  86525. */
  86526. getByteFrequencyData(): Uint8Array;
  86527. /**
  86528. * Gets the current waveform as a byte array
  86529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86530. * @returns a Uint8Array
  86531. */
  86532. getByteTimeDomainData(): Uint8Array;
  86533. /**
  86534. * Gets the current frequency data as a float array
  86535. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86536. * @returns a Float32Array
  86537. */
  86538. getFloatFrequencyData(): Float32Array;
  86539. /**
  86540. * Renders the debug canvas
  86541. */
  86542. drawDebugCanvas(): void;
  86543. /**
  86544. * Stops rendering the debug canvas and removes it
  86545. */
  86546. stopDebugCanvas(): void;
  86547. /**
  86548. * Connects two audio nodes
  86549. * @param inputAudioNode defines first node to connect
  86550. * @param outputAudioNode defines second node to connect
  86551. */
  86552. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86553. /**
  86554. * Releases all associated resources
  86555. */
  86556. dispose(): void;
  86557. }
  86558. }
  86559. declare module BABYLON {
  86560. /**
  86561. * This represents an audio engine and it is responsible
  86562. * to play, synchronize and analyse sounds throughout the application.
  86563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86564. */
  86565. export interface IAudioEngine extends IDisposable {
  86566. /**
  86567. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86568. */
  86569. readonly canUseWebAudio: boolean;
  86570. /**
  86571. * Gets the current AudioContext if available.
  86572. */
  86573. readonly audioContext: Nullable<AudioContext>;
  86574. /**
  86575. * The master gain node defines the global audio volume of your audio engine.
  86576. */
  86577. readonly masterGain: GainNode;
  86578. /**
  86579. * Gets whether or not mp3 are supported by your browser.
  86580. */
  86581. readonly isMP3supported: boolean;
  86582. /**
  86583. * Gets whether or not ogg are supported by your browser.
  86584. */
  86585. readonly isOGGsupported: boolean;
  86586. /**
  86587. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86588. * @ignoreNaming
  86589. */
  86590. WarnedWebAudioUnsupported: boolean;
  86591. /**
  86592. * Defines if the audio engine relies on a custom unlocked button.
  86593. * In this case, the embedded button will not be displayed.
  86594. */
  86595. useCustomUnlockedButton: boolean;
  86596. /**
  86597. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86598. */
  86599. readonly unlocked: boolean;
  86600. /**
  86601. * Event raised when audio has been unlocked on the browser.
  86602. */
  86603. onAudioUnlockedObservable: Observable<AudioEngine>;
  86604. /**
  86605. * Event raised when audio has been locked on the browser.
  86606. */
  86607. onAudioLockedObservable: Observable<AudioEngine>;
  86608. /**
  86609. * Flags the audio engine in Locked state.
  86610. * This happens due to new browser policies preventing audio to autoplay.
  86611. */
  86612. lock(): void;
  86613. /**
  86614. * Unlocks the audio engine once a user action has been done on the dom.
  86615. * This is helpful to resume play once browser policies have been satisfied.
  86616. */
  86617. unlock(): void;
  86618. }
  86619. /**
  86620. * This represents the default audio engine used in babylon.
  86621. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86623. */
  86624. export class AudioEngine implements IAudioEngine {
  86625. private _audioContext;
  86626. private _audioContextInitialized;
  86627. private _muteButton;
  86628. private _hostElement;
  86629. /**
  86630. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86631. */
  86632. canUseWebAudio: boolean;
  86633. /**
  86634. * The master gain node defines the global audio volume of your audio engine.
  86635. */
  86636. masterGain: GainNode;
  86637. /**
  86638. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86639. * @ignoreNaming
  86640. */
  86641. WarnedWebAudioUnsupported: boolean;
  86642. /**
  86643. * Gets whether or not mp3 are supported by your browser.
  86644. */
  86645. isMP3supported: boolean;
  86646. /**
  86647. * Gets whether or not ogg are supported by your browser.
  86648. */
  86649. isOGGsupported: boolean;
  86650. /**
  86651. * Gets whether audio has been unlocked on the device.
  86652. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86653. * a user interaction has happened.
  86654. */
  86655. unlocked: boolean;
  86656. /**
  86657. * Defines if the audio engine relies on a custom unlocked button.
  86658. * In this case, the embedded button will not be displayed.
  86659. */
  86660. useCustomUnlockedButton: boolean;
  86661. /**
  86662. * Event raised when audio has been unlocked on the browser.
  86663. */
  86664. onAudioUnlockedObservable: Observable<AudioEngine>;
  86665. /**
  86666. * Event raised when audio has been locked on the browser.
  86667. */
  86668. onAudioLockedObservable: Observable<AudioEngine>;
  86669. /**
  86670. * Gets the current AudioContext if available.
  86671. */
  86672. readonly audioContext: Nullable<AudioContext>;
  86673. private _connectedAnalyser;
  86674. /**
  86675. * Instantiates a new audio engine.
  86676. *
  86677. * There should be only one per page as some browsers restrict the number
  86678. * of audio contexts you can create.
  86679. * @param hostElement defines the host element where to display the mute icon if necessary
  86680. */
  86681. constructor(hostElement?: Nullable<HTMLElement>);
  86682. /**
  86683. * Flags the audio engine in Locked state.
  86684. * This happens due to new browser policies preventing audio to autoplay.
  86685. */
  86686. lock(): void;
  86687. /**
  86688. * Unlocks the audio engine once a user action has been done on the dom.
  86689. * This is helpful to resume play once browser policies have been satisfied.
  86690. */
  86691. unlock(): void;
  86692. private _resumeAudioContext;
  86693. private _initializeAudioContext;
  86694. private _tryToRun;
  86695. private _triggerRunningState;
  86696. private _triggerSuspendedState;
  86697. private _displayMuteButton;
  86698. private _moveButtonToTopLeft;
  86699. private _onResize;
  86700. private _hideMuteButton;
  86701. /**
  86702. * Destroy and release the resources associated with the audio ccontext.
  86703. */
  86704. dispose(): void;
  86705. /**
  86706. * Gets the global volume sets on the master gain.
  86707. * @returns the global volume if set or -1 otherwise
  86708. */
  86709. getGlobalVolume(): number;
  86710. /**
  86711. * Sets the global volume of your experience (sets on the master gain).
  86712. * @param newVolume Defines the new global volume of the application
  86713. */
  86714. setGlobalVolume(newVolume: number): void;
  86715. /**
  86716. * Connect the audio engine to an audio analyser allowing some amazing
  86717. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86719. * @param analyser The analyser to connect to the engine
  86720. */
  86721. connectToAnalyser(analyser: Analyser): void;
  86722. }
  86723. }
  86724. declare module BABYLON {
  86725. /**
  86726. * Interface used to present a loading screen while loading a scene
  86727. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86728. */
  86729. export interface ILoadingScreen {
  86730. /**
  86731. * Function called to display the loading screen
  86732. */
  86733. displayLoadingUI: () => void;
  86734. /**
  86735. * Function called to hide the loading screen
  86736. */
  86737. hideLoadingUI: () => void;
  86738. /**
  86739. * Gets or sets the color to use for the background
  86740. */
  86741. loadingUIBackgroundColor: string;
  86742. /**
  86743. * Gets or sets the text to display while loading
  86744. */
  86745. loadingUIText: string;
  86746. }
  86747. /**
  86748. * Class used for the default loading screen
  86749. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86750. */
  86751. export class DefaultLoadingScreen implements ILoadingScreen {
  86752. private _renderingCanvas;
  86753. private _loadingText;
  86754. private _loadingDivBackgroundColor;
  86755. private _loadingDiv;
  86756. private _loadingTextDiv;
  86757. /**
  86758. * Creates a new default loading screen
  86759. * @param _renderingCanvas defines the canvas used to render the scene
  86760. * @param _loadingText defines the default text to display
  86761. * @param _loadingDivBackgroundColor defines the default background color
  86762. */
  86763. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86764. /**
  86765. * Function called to display the loading screen
  86766. */
  86767. displayLoadingUI(): void;
  86768. /**
  86769. * Function called to hide the loading screen
  86770. */
  86771. hideLoadingUI(): void;
  86772. /**
  86773. * Gets or sets the text to display while loading
  86774. */
  86775. loadingUIText: string;
  86776. /**
  86777. * Gets or sets the color to use for the background
  86778. */
  86779. loadingUIBackgroundColor: string;
  86780. private _resizeLoadingUI;
  86781. }
  86782. }
  86783. declare module BABYLON {
  86784. /** @hidden */
  86785. export class WebGLPipelineContext implements IPipelineContext {
  86786. engine: Engine;
  86787. program: Nullable<WebGLProgram>;
  86788. context?: WebGLRenderingContext;
  86789. vertexShader?: WebGLShader;
  86790. fragmentShader?: WebGLShader;
  86791. isParallelCompiled: boolean;
  86792. onCompiled?: () => void;
  86793. transformFeedback?: WebGLTransformFeedback | null;
  86794. readonly isAsync: boolean;
  86795. readonly isReady: boolean;
  86796. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86797. }
  86798. }
  86799. declare module BABYLON {
  86800. /** @hidden */
  86801. export class WebGLDataBuffer extends DataBuffer {
  86802. private _buffer;
  86803. constructor(resource: WebGLBuffer);
  86804. readonly underlyingResource: any;
  86805. }
  86806. }
  86807. declare module BABYLON {
  86808. /**
  86809. * Settings for finer control over video usage
  86810. */
  86811. export interface VideoTextureSettings {
  86812. /**
  86813. * Applies `autoplay` to video, if specified
  86814. */
  86815. autoPlay?: boolean;
  86816. /**
  86817. * Applies `loop` to video, if specified
  86818. */
  86819. loop?: boolean;
  86820. /**
  86821. * Automatically updates internal texture from video at every frame in the render loop
  86822. */
  86823. autoUpdateTexture: boolean;
  86824. /**
  86825. * Image src displayed during the video loading or until the user interacts with the video.
  86826. */
  86827. poster?: string;
  86828. }
  86829. /**
  86830. * If you want to display a video in your scene, this is the special texture for that.
  86831. * This special texture works similar to other textures, with the exception of a few parameters.
  86832. * @see https://doc.babylonjs.com/how_to/video_texture
  86833. */
  86834. export class VideoTexture extends Texture {
  86835. /**
  86836. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86837. */
  86838. readonly autoUpdateTexture: boolean;
  86839. /**
  86840. * The video instance used by the texture internally
  86841. */
  86842. readonly video: HTMLVideoElement;
  86843. private _onUserActionRequestedObservable;
  86844. /**
  86845. * Event triggerd when a dom action is required by the user to play the video.
  86846. * This happens due to recent changes in browser policies preventing video to auto start.
  86847. */
  86848. readonly onUserActionRequestedObservable: Observable<Texture>;
  86849. private _generateMipMaps;
  86850. private _engine;
  86851. private _stillImageCaptured;
  86852. private _displayingPosterTexture;
  86853. private _settings;
  86854. private _createInternalTextureOnEvent;
  86855. /**
  86856. * Creates a video texture.
  86857. * If you want to display a video in your scene, this is the special texture for that.
  86858. * This special texture works similar to other textures, with the exception of a few parameters.
  86859. * @see https://doc.babylonjs.com/how_to/video_texture
  86860. * @param name optional name, will detect from video source, if not defined
  86861. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86862. * @param scene is obviously the current scene.
  86863. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86864. * @param invertY is false by default but can be used to invert video on Y axis
  86865. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86866. * @param settings allows finer control over video usage
  86867. */
  86868. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86869. private _getName;
  86870. private _getVideo;
  86871. private _createInternalTexture;
  86872. private reset;
  86873. /**
  86874. * @hidden Internal method to initiate `update`.
  86875. */
  86876. _rebuild(): void;
  86877. /**
  86878. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86879. */
  86880. update(): void;
  86881. /**
  86882. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86883. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86884. */
  86885. updateTexture(isVisible: boolean): void;
  86886. protected _updateInternalTexture: () => void;
  86887. /**
  86888. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86889. * @param url New url.
  86890. */
  86891. updateURL(url: string): void;
  86892. /**
  86893. * Dispose the texture and release its associated resources.
  86894. */
  86895. dispose(): void;
  86896. /**
  86897. * Creates a video texture straight from a stream.
  86898. * @param scene Define the scene the texture should be created in
  86899. * @param stream Define the stream the texture should be created from
  86900. * @returns The created video texture as a promise
  86901. */
  86902. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86903. /**
  86904. * Creates a video texture straight from your WebCam video feed.
  86905. * @param scene Define the scene the texture should be created in
  86906. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86907. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86908. * @returns The created video texture as a promise
  86909. */
  86910. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86911. minWidth: number;
  86912. maxWidth: number;
  86913. minHeight: number;
  86914. maxHeight: number;
  86915. deviceId: string;
  86916. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86917. /**
  86918. * Creates a video texture straight from your WebCam video feed.
  86919. * @param scene Define the scene the texture should be created in
  86920. * @param onReady Define a callback to triggered once the texture will be ready
  86921. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86922. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86923. */
  86924. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86925. minWidth: number;
  86926. maxWidth: number;
  86927. minHeight: number;
  86928. maxHeight: number;
  86929. deviceId: string;
  86930. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86931. }
  86932. }
  86933. declare module BABYLON {
  86934. /**
  86935. * Interface for attribute information associated with buffer instanciation
  86936. */
  86937. export class InstancingAttributeInfo {
  86938. /**
  86939. * Index/offset of the attribute in the vertex shader
  86940. */
  86941. index: number;
  86942. /**
  86943. * size of the attribute, 1, 2, 3 or 4
  86944. */
  86945. attributeSize: number;
  86946. /**
  86947. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86948. * default is FLOAT
  86949. */
  86950. attribyteType: number;
  86951. /**
  86952. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86953. */
  86954. normalized: boolean;
  86955. /**
  86956. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86957. */
  86958. offset: number;
  86959. /**
  86960. * Name of the GLSL attribute, for debugging purpose only
  86961. */
  86962. attributeName: string;
  86963. }
  86964. /**
  86965. * Define options used to create a depth texture
  86966. */
  86967. export class DepthTextureCreationOptions {
  86968. /** Specifies whether or not a stencil should be allocated in the texture */
  86969. generateStencil?: boolean;
  86970. /** Specifies whether or not bilinear filtering is enable on the texture */
  86971. bilinearFiltering?: boolean;
  86972. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86973. comparisonFunction?: number;
  86974. /** Specifies if the created texture is a cube texture */
  86975. isCube?: boolean;
  86976. }
  86977. /**
  86978. * Class used to describe the capabilities of the engine relatively to the current browser
  86979. */
  86980. export class EngineCapabilities {
  86981. /** Maximum textures units per fragment shader */
  86982. maxTexturesImageUnits: number;
  86983. /** Maximum texture units per vertex shader */
  86984. maxVertexTextureImageUnits: number;
  86985. /** Maximum textures units in the entire pipeline */
  86986. maxCombinedTexturesImageUnits: number;
  86987. /** Maximum texture size */
  86988. maxTextureSize: number;
  86989. /** Maximum cube texture size */
  86990. maxCubemapTextureSize: number;
  86991. /** Maximum render texture size */
  86992. maxRenderTextureSize: number;
  86993. /** Maximum number of vertex attributes */
  86994. maxVertexAttribs: number;
  86995. /** Maximum number of varyings */
  86996. maxVaryingVectors: number;
  86997. /** Maximum number of uniforms per vertex shader */
  86998. maxVertexUniformVectors: number;
  86999. /** Maximum number of uniforms per fragment shader */
  87000. maxFragmentUniformVectors: number;
  87001. /** Defines if standard derivates (dx/dy) are supported */
  87002. standardDerivatives: boolean;
  87003. /** Defines if s3tc texture compression is supported */
  87004. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  87005. /** Defines if pvrtc texture compression is supported */
  87006. pvrtc: any;
  87007. /** Defines if etc1 texture compression is supported */
  87008. etc1: any;
  87009. /** Defines if etc2 texture compression is supported */
  87010. etc2: any;
  87011. /** Defines if astc texture compression is supported */
  87012. astc: any;
  87013. /** Defines if float textures are supported */
  87014. textureFloat: boolean;
  87015. /** Defines if vertex array objects are supported */
  87016. vertexArrayObject: boolean;
  87017. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  87018. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  87019. /** Gets the maximum level of anisotropy supported */
  87020. maxAnisotropy: number;
  87021. /** Defines if instancing is supported */
  87022. instancedArrays: boolean;
  87023. /** Defines if 32 bits indices are supported */
  87024. uintIndices: boolean;
  87025. /** Defines if high precision shaders are supported */
  87026. highPrecisionShaderSupported: boolean;
  87027. /** Defines if depth reading in the fragment shader is supported */
  87028. fragmentDepthSupported: boolean;
  87029. /** Defines if float texture linear filtering is supported*/
  87030. textureFloatLinearFiltering: boolean;
  87031. /** Defines if rendering to float textures is supported */
  87032. textureFloatRender: boolean;
  87033. /** Defines if half float textures are supported*/
  87034. textureHalfFloat: boolean;
  87035. /** Defines if half float texture linear filtering is supported*/
  87036. textureHalfFloatLinearFiltering: boolean;
  87037. /** Defines if rendering to half float textures is supported */
  87038. textureHalfFloatRender: boolean;
  87039. /** Defines if textureLOD shader command is supported */
  87040. textureLOD: boolean;
  87041. /** Defines if draw buffers extension is supported */
  87042. drawBuffersExtension: boolean;
  87043. /** Defines if depth textures are supported */
  87044. depthTextureExtension: boolean;
  87045. /** Defines if float color buffer are supported */
  87046. colorBufferFloat: boolean;
  87047. /** Gets disjoint timer query extension (null if not supported) */
  87048. timerQuery: EXT_disjoint_timer_query;
  87049. /** Defines if timestamp can be used with timer query */
  87050. canUseTimestampForTimerQuery: boolean;
  87051. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  87052. multiview: any;
  87053. /** Function used to let the system compiles shaders in background */
  87054. parallelShaderCompile: {
  87055. COMPLETION_STATUS_KHR: number;
  87056. };
  87057. }
  87058. /** Interface defining initialization parameters for Engine class */
  87059. export interface EngineOptions extends WebGLContextAttributes {
  87060. /**
  87061. * Defines if the engine should no exceed a specified device ratio
  87062. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  87063. */
  87064. limitDeviceRatio?: number;
  87065. /**
  87066. * Defines if webvr should be enabled automatically
  87067. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87068. */
  87069. autoEnableWebVR?: boolean;
  87070. /**
  87071. * Defines if webgl2 should be turned off even if supported
  87072. * @see http://doc.babylonjs.com/features/webgl2
  87073. */
  87074. disableWebGL2Support?: boolean;
  87075. /**
  87076. * Defines if webaudio should be initialized as well
  87077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87078. */
  87079. audioEngine?: boolean;
  87080. /**
  87081. * Defines if animations should run using a deterministic lock step
  87082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87083. */
  87084. deterministicLockstep?: boolean;
  87085. /** Defines the maximum steps to use with deterministic lock step mode */
  87086. lockstepMaxSteps?: number;
  87087. /**
  87088. * Defines that engine should ignore context lost events
  87089. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  87090. */
  87091. doNotHandleContextLost?: boolean;
  87092. /**
  87093. * Defines that engine should ignore modifying touch action attribute and style
  87094. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  87095. */
  87096. doNotHandleTouchAction?: boolean;
  87097. /**
  87098. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  87099. */
  87100. useHighPrecisionFloats?: boolean;
  87101. }
  87102. /**
  87103. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  87104. */
  87105. export class Engine {
  87106. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  87107. static ExceptionList: ({
  87108. key: string;
  87109. capture: string;
  87110. captureConstraint: number;
  87111. targets: string[];
  87112. } | {
  87113. key: string;
  87114. capture: null;
  87115. captureConstraint: null;
  87116. targets: string[];
  87117. })[];
  87118. /** Gets the list of created engines */
  87119. static readonly Instances: Engine[];
  87120. /**
  87121. * Gets the latest created engine
  87122. */
  87123. static readonly LastCreatedEngine: Nullable<Engine>;
  87124. /**
  87125. * Gets the latest created scene
  87126. */
  87127. static readonly LastCreatedScene: Nullable<Scene>;
  87128. /**
  87129. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  87130. * @param flag defines which part of the materials must be marked as dirty
  87131. * @param predicate defines a predicate used to filter which materials should be affected
  87132. */
  87133. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  87134. /**
  87135. * Hidden
  87136. */
  87137. static _TextureLoaders: IInternalTextureLoader[];
  87138. /** Defines that alpha blending is disabled */
  87139. static readonly ALPHA_DISABLE: number;
  87140. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  87141. static readonly ALPHA_ADD: number;
  87142. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  87143. static readonly ALPHA_COMBINE: number;
  87144. /** Defines that alpha blending to DEST - SRC * DEST */
  87145. static readonly ALPHA_SUBTRACT: number;
  87146. /** Defines that alpha blending to SRC * DEST */
  87147. static readonly ALPHA_MULTIPLY: number;
  87148. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  87149. static readonly ALPHA_MAXIMIZED: number;
  87150. /** Defines that alpha blending to SRC + DEST */
  87151. static readonly ALPHA_ONEONE: number;
  87152. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  87153. static readonly ALPHA_PREMULTIPLIED: number;
  87154. /**
  87155. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  87156. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  87157. */
  87158. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  87159. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  87160. static readonly ALPHA_INTERPOLATE: number;
  87161. /**
  87162. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  87163. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  87164. */
  87165. static readonly ALPHA_SCREENMODE: number;
  87166. /** Defines that the ressource is not delayed*/
  87167. static readonly DELAYLOADSTATE_NONE: number;
  87168. /** Defines that the ressource was successfully delay loaded */
  87169. static readonly DELAYLOADSTATE_LOADED: number;
  87170. /** Defines that the ressource is currently delay loading */
  87171. static readonly DELAYLOADSTATE_LOADING: number;
  87172. /** Defines that the ressource is delayed and has not started loading */
  87173. static readonly DELAYLOADSTATE_NOTLOADED: number;
  87174. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  87175. static readonly NEVER: number;
  87176. /** 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 */
  87177. static readonly ALWAYS: number;
  87178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  87179. static readonly LESS: number;
  87180. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  87181. static readonly EQUAL: number;
  87182. /** 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 */
  87183. static readonly LEQUAL: number;
  87184. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  87185. static readonly GREATER: number;
  87186. /** 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 */
  87187. static readonly GEQUAL: number;
  87188. /** 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 */
  87189. static readonly NOTEQUAL: number;
  87190. /** Passed to stencilOperation to specify that stencil value must be kept */
  87191. static readonly KEEP: number;
  87192. /** Passed to stencilOperation to specify that stencil value must be replaced */
  87193. static readonly REPLACE: number;
  87194. /** Passed to stencilOperation to specify that stencil value must be incremented */
  87195. static readonly INCR: number;
  87196. /** Passed to stencilOperation to specify that stencil value must be decremented */
  87197. static readonly DECR: number;
  87198. /** Passed to stencilOperation to specify that stencil value must be inverted */
  87199. static readonly INVERT: number;
  87200. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  87201. static readonly INCR_WRAP: number;
  87202. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  87203. static readonly DECR_WRAP: number;
  87204. /** Texture is not repeating outside of 0..1 UVs */
  87205. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  87206. /** Texture is repeating outside of 0..1 UVs */
  87207. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  87208. /** Texture is repeating and mirrored */
  87209. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  87210. /** ALPHA */
  87211. static readonly TEXTUREFORMAT_ALPHA: number;
  87212. /** LUMINANCE */
  87213. static readonly TEXTUREFORMAT_LUMINANCE: number;
  87214. /** LUMINANCE_ALPHA */
  87215. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  87216. /** RGB */
  87217. static readonly TEXTUREFORMAT_RGB: number;
  87218. /** RGBA */
  87219. static readonly TEXTUREFORMAT_RGBA: number;
  87220. /** RED */
  87221. static readonly TEXTUREFORMAT_RED: number;
  87222. /** RED (2nd reference) */
  87223. static readonly TEXTUREFORMAT_R: number;
  87224. /** RG */
  87225. static readonly TEXTUREFORMAT_RG: number;
  87226. /** RED_INTEGER */
  87227. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  87228. /** RED_INTEGER (2nd reference) */
  87229. static readonly TEXTUREFORMAT_R_INTEGER: number;
  87230. /** RG_INTEGER */
  87231. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  87232. /** RGB_INTEGER */
  87233. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  87234. /** RGBA_INTEGER */
  87235. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  87236. /** UNSIGNED_BYTE */
  87237. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  87238. /** UNSIGNED_BYTE (2nd reference) */
  87239. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  87240. /** FLOAT */
  87241. static readonly TEXTURETYPE_FLOAT: number;
  87242. /** HALF_FLOAT */
  87243. static readonly TEXTURETYPE_HALF_FLOAT: number;
  87244. /** BYTE */
  87245. static readonly TEXTURETYPE_BYTE: number;
  87246. /** SHORT */
  87247. static readonly TEXTURETYPE_SHORT: number;
  87248. /** UNSIGNED_SHORT */
  87249. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  87250. /** INT */
  87251. static readonly TEXTURETYPE_INT: number;
  87252. /** UNSIGNED_INT */
  87253. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  87254. /** UNSIGNED_SHORT_4_4_4_4 */
  87255. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  87256. /** UNSIGNED_SHORT_5_5_5_1 */
  87257. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  87258. /** UNSIGNED_SHORT_5_6_5 */
  87259. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  87260. /** UNSIGNED_INT_2_10_10_10_REV */
  87261. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  87262. /** UNSIGNED_INT_24_8 */
  87263. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  87264. /** UNSIGNED_INT_10F_11F_11F_REV */
  87265. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  87266. /** UNSIGNED_INT_5_9_9_9_REV */
  87267. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  87268. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  87269. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  87270. /** nearest is mag = nearest and min = nearest and mip = linear */
  87271. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  87272. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87273. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  87274. /** Trilinear is mag = linear and min = linear and mip = linear */
  87275. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  87276. /** nearest is mag = nearest and min = nearest and mip = linear */
  87277. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  87278. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87279. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  87280. /** Trilinear is mag = linear and min = linear and mip = linear */
  87281. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  87282. /** mag = nearest and min = nearest and mip = nearest */
  87283. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  87284. /** mag = nearest and min = linear and mip = nearest */
  87285. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  87286. /** mag = nearest and min = linear and mip = linear */
  87287. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  87288. /** mag = nearest and min = linear and mip = none */
  87289. static readonly TEXTURE_NEAREST_LINEAR: number;
  87290. /** mag = nearest and min = nearest and mip = none */
  87291. static readonly TEXTURE_NEAREST_NEAREST: number;
  87292. /** mag = linear and min = nearest and mip = nearest */
  87293. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  87294. /** mag = linear and min = nearest and mip = linear */
  87295. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  87296. /** mag = linear and min = linear and mip = none */
  87297. static readonly TEXTURE_LINEAR_LINEAR: number;
  87298. /** mag = linear and min = nearest and mip = none */
  87299. static readonly TEXTURE_LINEAR_NEAREST: number;
  87300. /** Explicit coordinates mode */
  87301. static readonly TEXTURE_EXPLICIT_MODE: number;
  87302. /** Spherical coordinates mode */
  87303. static readonly TEXTURE_SPHERICAL_MODE: number;
  87304. /** Planar coordinates mode */
  87305. static readonly TEXTURE_PLANAR_MODE: number;
  87306. /** Cubic coordinates mode */
  87307. static readonly TEXTURE_CUBIC_MODE: number;
  87308. /** Projection coordinates mode */
  87309. static readonly TEXTURE_PROJECTION_MODE: number;
  87310. /** Skybox coordinates mode */
  87311. static readonly TEXTURE_SKYBOX_MODE: number;
  87312. /** Inverse Cubic coordinates mode */
  87313. static readonly TEXTURE_INVCUBIC_MODE: number;
  87314. /** Equirectangular coordinates mode */
  87315. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  87316. /** Equirectangular Fixed coordinates mode */
  87317. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  87318. /** Equirectangular Fixed Mirrored coordinates mode */
  87319. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87320. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  87321. static readonly SCALEMODE_FLOOR: number;
  87322. /** Defines that texture rescaling will look for the nearest power of 2 size */
  87323. static readonly SCALEMODE_NEAREST: number;
  87324. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  87325. static readonly SCALEMODE_CEILING: number;
  87326. /**
  87327. * Returns the current npm package of the sdk
  87328. */
  87329. static readonly NpmPackage: string;
  87330. /**
  87331. * Returns the current version of the framework
  87332. */
  87333. static readonly Version: string;
  87334. /**
  87335. * Returns a string describing the current engine
  87336. */
  87337. readonly description: string;
  87338. /**
  87339. * Gets or sets the epsilon value used by collision engine
  87340. */
  87341. static CollisionsEpsilon: number;
  87342. /**
  87343. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87344. */
  87345. static ShadersRepository: string;
  87346. /**
  87347. * Method called to create the default loading screen.
  87348. * This can be overriden in your own app.
  87349. * @param canvas The rendering canvas element
  87350. * @returns The loading screen
  87351. */
  87352. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  87353. /**
  87354. * Method called to create the default rescale post process on each engine.
  87355. */
  87356. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  87357. /**
  87358. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  87359. */
  87360. forcePOTTextures: boolean;
  87361. /**
  87362. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  87363. */
  87364. isFullscreen: boolean;
  87365. /**
  87366. * Gets a boolean indicating if the pointer is currently locked
  87367. */
  87368. isPointerLock: boolean;
  87369. /**
  87370. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  87371. */
  87372. cullBackFaces: boolean;
  87373. /**
  87374. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  87375. */
  87376. renderEvenInBackground: boolean;
  87377. /**
  87378. * Gets or sets a boolean indicating that cache can be kept between frames
  87379. */
  87380. preventCacheWipeBetweenFrames: boolean;
  87381. /**
  87382. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  87383. **/
  87384. enableOfflineSupport: boolean;
  87385. /**
  87386. * 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)
  87387. **/
  87388. disableManifestCheck: boolean;
  87389. /**
  87390. * Gets the list of created scenes
  87391. */
  87392. scenes: Scene[];
  87393. /**
  87394. * Event raised when a new scene is created
  87395. */
  87396. onNewSceneAddedObservable: Observable<Scene>;
  87397. /**
  87398. * Gets the list of created postprocesses
  87399. */
  87400. postProcesses: PostProcess[];
  87401. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  87402. validateShaderPrograms: boolean;
  87403. /**
  87404. * Observable event triggered each time the rendering canvas is resized
  87405. */
  87406. onResizeObservable: Observable<Engine>;
  87407. /**
  87408. * Observable event triggered each time the canvas loses focus
  87409. */
  87410. onCanvasBlurObservable: Observable<Engine>;
  87411. /**
  87412. * Observable event triggered each time the canvas gains focus
  87413. */
  87414. onCanvasFocusObservable: Observable<Engine>;
  87415. /**
  87416. * Observable event triggered each time the canvas receives pointerout event
  87417. */
  87418. onCanvasPointerOutObservable: Observable<PointerEvent>;
  87419. /**
  87420. * Observable event triggered before each texture is initialized
  87421. */
  87422. onBeforeTextureInitObservable: Observable<Texture>;
  87423. /**
  87424. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  87425. */
  87426. disableUniformBuffers: boolean;
  87427. /** @hidden */
  87428. _uniformBuffers: UniformBuffer[];
  87429. /**
  87430. * Gets a boolean indicating that the engine supports uniform buffers
  87431. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87432. */
  87433. readonly supportsUniformBuffers: boolean;
  87434. /**
  87435. * Observable raised when the engine begins a new frame
  87436. */
  87437. onBeginFrameObservable: Observable<Engine>;
  87438. /**
  87439. * If set, will be used to request the next animation frame for the render loop
  87440. */
  87441. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  87442. /**
  87443. * Observable raised when the engine ends the current frame
  87444. */
  87445. onEndFrameObservable: Observable<Engine>;
  87446. /**
  87447. * Observable raised when the engine is about to compile a shader
  87448. */
  87449. onBeforeShaderCompilationObservable: Observable<Engine>;
  87450. /**
  87451. * Observable raised when the engine has jsut compiled a shader
  87452. */
  87453. onAfterShaderCompilationObservable: Observable<Engine>;
  87454. /** @hidden */
  87455. _gl: WebGLRenderingContext;
  87456. private _renderingCanvas;
  87457. private _windowIsBackground;
  87458. private _webGLVersion;
  87459. protected _highPrecisionShadersAllowed: boolean;
  87460. /** @hidden */
  87461. readonly _shouldUseHighPrecisionShader: boolean;
  87462. /**
  87463. * Gets a boolean indicating that only power of 2 textures are supported
  87464. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  87465. */
  87466. readonly needPOTTextures: boolean;
  87467. /** @hidden */
  87468. _badOS: boolean;
  87469. /** @hidden */
  87470. _badDesktopOS: boolean;
  87471. /**
  87472. * Gets the audio engine
  87473. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  87474. * @ignorenaming
  87475. */
  87476. static audioEngine: IAudioEngine;
  87477. /**
  87478. * Default AudioEngine factory responsible of creating the Audio Engine.
  87479. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  87480. */
  87481. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  87482. /**
  87483. * Default offline support factory responsible of creating a tool used to store data locally.
  87484. * By default, this will create a Database object if the workload has been embedded.
  87485. */
  87486. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  87487. private _onFocus;
  87488. private _onBlur;
  87489. private _onCanvasPointerOut;
  87490. private _onCanvasBlur;
  87491. private _onCanvasFocus;
  87492. private _onFullscreenChange;
  87493. private _onPointerLockChange;
  87494. private _hardwareScalingLevel;
  87495. /** @hidden */
  87496. _caps: EngineCapabilities;
  87497. private _pointerLockRequested;
  87498. private _isStencilEnable;
  87499. private _colorWrite;
  87500. private _loadingScreen;
  87501. /** @hidden */
  87502. _drawCalls: PerfCounter;
  87503. private _glVersion;
  87504. private _glRenderer;
  87505. private _glVendor;
  87506. private _videoTextureSupported;
  87507. private _renderingQueueLaunched;
  87508. private _activeRenderLoops;
  87509. private _deterministicLockstep;
  87510. private _lockstepMaxSteps;
  87511. /**
  87512. * Observable signaled when a context lost event is raised
  87513. */
  87514. onContextLostObservable: Observable<Engine>;
  87515. /**
  87516. * Observable signaled when a context restored event is raised
  87517. */
  87518. onContextRestoredObservable: Observable<Engine>;
  87519. private _onContextLost;
  87520. private _onContextRestored;
  87521. private _contextWasLost;
  87522. /** @hidden */
  87523. _doNotHandleContextLost: boolean;
  87524. /**
  87525. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87527. */
  87528. doNotHandleContextLost: boolean;
  87529. private _performanceMonitor;
  87530. private _fps;
  87531. private _deltaTime;
  87532. /**
  87533. * Turn this value on if you want to pause FPS computation when in background
  87534. */
  87535. disablePerformanceMonitorInBackground: boolean;
  87536. /**
  87537. * Gets the performance monitor attached to this engine
  87538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87539. */
  87540. readonly performanceMonitor: PerformanceMonitor;
  87541. /**
  87542. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87543. */
  87544. disableVertexArrayObjects: boolean;
  87545. /** @hidden */
  87546. protected _depthCullingState: _DepthCullingState;
  87547. /** @hidden */
  87548. protected _stencilState: _StencilState;
  87549. /** @hidden */
  87550. protected _alphaState: _AlphaState;
  87551. /** @hidden */
  87552. protected _alphaMode: number;
  87553. /** @hidden */
  87554. _internalTexturesCache: InternalTexture[];
  87555. /** @hidden */
  87556. protected _activeChannel: number;
  87557. private _currentTextureChannel;
  87558. /** @hidden */
  87559. protected _boundTexturesCache: {
  87560. [key: string]: Nullable<InternalTexture>;
  87561. };
  87562. /** @hidden */
  87563. protected _currentEffect: Nullable<Effect>;
  87564. /** @hidden */
  87565. protected _currentProgram: Nullable<WebGLProgram>;
  87566. private _compiledEffects;
  87567. private _vertexAttribArraysEnabled;
  87568. /** @hidden */
  87569. protected _cachedViewport: Nullable<Viewport>;
  87570. private _cachedVertexArrayObject;
  87571. /** @hidden */
  87572. protected _cachedVertexBuffers: any;
  87573. /** @hidden */
  87574. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  87575. /** @hidden */
  87576. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87577. /** @hidden */
  87578. _currentRenderTarget: Nullable<InternalTexture>;
  87579. private _uintIndicesCurrentlySet;
  87580. private _currentBoundBuffer;
  87581. /** @hidden */
  87582. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87583. private _currentBufferPointers;
  87584. private _currentInstanceLocations;
  87585. private _currentInstanceBuffers;
  87586. private _textureUnits;
  87587. /** @hidden */
  87588. _workingCanvas: Nullable<HTMLCanvasElement>;
  87589. /** @hidden */
  87590. _workingContext: Nullable<CanvasRenderingContext2D>;
  87591. private _rescalePostProcess;
  87592. private _dummyFramebuffer;
  87593. private _externalData;
  87594. /** @hidden */
  87595. _bindedRenderFunction: any;
  87596. private _vaoRecordInProgress;
  87597. private _mustWipeVertexAttributes;
  87598. private _emptyTexture;
  87599. private _emptyCubeTexture;
  87600. private _emptyTexture3D;
  87601. /** @hidden */
  87602. _frameHandler: number;
  87603. private _nextFreeTextureSlots;
  87604. private _maxSimultaneousTextures;
  87605. private _activeRequests;
  87606. private _texturesSupported;
  87607. /** @hidden */
  87608. _textureFormatInUse: Nullable<string>;
  87609. /**
  87610. * Gets the list of texture formats supported
  87611. */
  87612. readonly texturesSupported: Array<string>;
  87613. /**
  87614. * Gets the list of texture formats in use
  87615. */
  87616. readonly textureFormatInUse: Nullable<string>;
  87617. /**
  87618. * Gets the current viewport
  87619. */
  87620. readonly currentViewport: Nullable<Viewport>;
  87621. /**
  87622. * Gets the default empty texture
  87623. */
  87624. readonly emptyTexture: InternalTexture;
  87625. /**
  87626. * Gets the default empty 3D texture
  87627. */
  87628. readonly emptyTexture3D: InternalTexture;
  87629. /**
  87630. * Gets the default empty cube texture
  87631. */
  87632. readonly emptyCubeTexture: InternalTexture;
  87633. /**
  87634. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87635. */
  87636. readonly premultipliedAlpha: boolean;
  87637. /**
  87638. * Creates a new engine
  87639. * @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
  87640. * @param antialias defines enable antialiasing (default: false)
  87641. * @param options defines further options to be sent to the getContext() function
  87642. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87643. */
  87644. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87645. /**
  87646. * Initializes a webVR display and starts listening to display change events
  87647. * The onVRDisplayChangedObservable will be notified upon these changes
  87648. * @returns The onVRDisplayChangedObservable
  87649. */
  87650. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87651. /** @hidden */
  87652. _prepareVRComponent(): void;
  87653. /** @hidden */
  87654. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  87655. /** @hidden */
  87656. _submitVRFrame(): void;
  87657. /**
  87658. * Call this function to leave webVR mode
  87659. * Will do nothing if webVR is not supported or if there is no webVR device
  87660. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87661. */
  87662. disableVR(): void;
  87663. /**
  87664. * Gets a boolean indicating that the system is in VR mode and is presenting
  87665. * @returns true if VR mode is engaged
  87666. */
  87667. isVRPresenting(): boolean;
  87668. /** @hidden */
  87669. _requestVRFrame(): void;
  87670. private _disableTouchAction;
  87671. private _rebuildInternalTextures;
  87672. private _rebuildEffects;
  87673. /**
  87674. * Gets a boolean indicating if all created effects are ready
  87675. * @returns true if all effects are ready
  87676. */
  87677. areAllEffectsReady(): boolean;
  87678. private _rebuildBuffers;
  87679. private _initGLContext;
  87680. /**
  87681. * Gets version of the current webGL context
  87682. */
  87683. readonly webGLVersion: number;
  87684. /**
  87685. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87686. */
  87687. readonly isStencilEnable: boolean;
  87688. /** @hidden */
  87689. _prepareWorkingCanvas(): void;
  87690. /**
  87691. * Reset the texture cache to empty state
  87692. */
  87693. resetTextureCache(): void;
  87694. /**
  87695. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87696. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87697. * @returns true if engine is in deterministic lock step mode
  87698. */
  87699. isDeterministicLockStep(): boolean;
  87700. /**
  87701. * Gets the max steps when engine is running in deterministic lock step
  87702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87703. * @returns the max steps
  87704. */
  87705. getLockstepMaxSteps(): number;
  87706. /**
  87707. * Gets an object containing information about the current webGL context
  87708. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87709. */
  87710. getGlInfo(): {
  87711. vendor: string;
  87712. renderer: string;
  87713. version: string;
  87714. };
  87715. /**
  87716. * Gets current aspect ratio
  87717. * @param camera defines the camera to use to get the aspect ratio
  87718. * @param useScreen defines if screen size must be used (or the current render target if any)
  87719. * @returns a number defining the aspect ratio
  87720. */
  87721. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87722. /**
  87723. * Gets current screen aspect ratio
  87724. * @returns a number defining the aspect ratio
  87725. */
  87726. getScreenAspectRatio(): number;
  87727. /**
  87728. * Gets the current render width
  87729. * @param useScreen defines if screen size must be used (or the current render target if any)
  87730. * @returns a number defining the current render width
  87731. */
  87732. getRenderWidth(useScreen?: boolean): number;
  87733. /**
  87734. * Gets the current render height
  87735. * @param useScreen defines if screen size must be used (or the current render target if any)
  87736. * @returns a number defining the current render height
  87737. */
  87738. getRenderHeight(useScreen?: boolean): number;
  87739. /**
  87740. * Gets the HTML canvas attached with the current webGL context
  87741. * @returns a HTML canvas
  87742. */
  87743. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87744. /**
  87745. * Gets the client rect of the HTML canvas attached with the current webGL context
  87746. * @returns a client rectanglee
  87747. */
  87748. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87749. /**
  87750. * Defines the hardware scaling level.
  87751. * By default the hardware scaling level is computed from the window device ratio.
  87752. * 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.
  87753. * @param level defines the level to use
  87754. */
  87755. setHardwareScalingLevel(level: number): void;
  87756. /**
  87757. * Gets the current hardware scaling level.
  87758. * By default the hardware scaling level is computed from the window device ratio.
  87759. * 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.
  87760. * @returns a number indicating the current hardware scaling level
  87761. */
  87762. getHardwareScalingLevel(): number;
  87763. /**
  87764. * Gets the list of loaded textures
  87765. * @returns an array containing all loaded textures
  87766. */
  87767. getLoadedTexturesCache(): InternalTexture[];
  87768. /**
  87769. * Gets the object containing all engine capabilities
  87770. * @returns the EngineCapabilities object
  87771. */
  87772. getCaps(): EngineCapabilities;
  87773. /**
  87774. * Gets the current depth function
  87775. * @returns a number defining the depth function
  87776. */
  87777. getDepthFunction(): Nullable<number>;
  87778. /**
  87779. * Sets the current depth function
  87780. * @param depthFunc defines the function to use
  87781. */
  87782. setDepthFunction(depthFunc: number): void;
  87783. /**
  87784. * Sets the current depth function to GREATER
  87785. */
  87786. setDepthFunctionToGreater(): void;
  87787. /**
  87788. * Sets the current depth function to GEQUAL
  87789. */
  87790. setDepthFunctionToGreaterOrEqual(): void;
  87791. /**
  87792. * Sets the current depth function to LESS
  87793. */
  87794. setDepthFunctionToLess(): void;
  87795. private _cachedStencilBuffer;
  87796. private _cachedStencilFunction;
  87797. private _cachedStencilMask;
  87798. private _cachedStencilOperationPass;
  87799. private _cachedStencilOperationFail;
  87800. private _cachedStencilOperationDepthFail;
  87801. private _cachedStencilReference;
  87802. /**
  87803. * Caches the the state of the stencil buffer
  87804. */
  87805. cacheStencilState(): void;
  87806. /**
  87807. * Restores the state of the stencil buffer
  87808. */
  87809. restoreStencilState(): void;
  87810. /**
  87811. * Sets the current depth function to LEQUAL
  87812. */
  87813. setDepthFunctionToLessOrEqual(): void;
  87814. /**
  87815. * Gets a boolean indicating if stencil buffer is enabled
  87816. * @returns the current stencil buffer state
  87817. */
  87818. getStencilBuffer(): boolean;
  87819. /**
  87820. * Enable or disable the stencil buffer
  87821. * @param enable defines if the stencil buffer must be enabled or disabled
  87822. */
  87823. setStencilBuffer(enable: boolean): void;
  87824. /**
  87825. * Gets the current stencil mask
  87826. * @returns a number defining the new stencil mask to use
  87827. */
  87828. getStencilMask(): number;
  87829. /**
  87830. * Sets the current stencil mask
  87831. * @param mask defines the new stencil mask to use
  87832. */
  87833. setStencilMask(mask: number): void;
  87834. /**
  87835. * Gets the current stencil function
  87836. * @returns a number defining the stencil function to use
  87837. */
  87838. getStencilFunction(): number;
  87839. /**
  87840. * Gets the current stencil reference value
  87841. * @returns a number defining the stencil reference value to use
  87842. */
  87843. getStencilFunctionReference(): number;
  87844. /**
  87845. * Gets the current stencil mask
  87846. * @returns a number defining the stencil mask to use
  87847. */
  87848. getStencilFunctionMask(): number;
  87849. /**
  87850. * Sets the current stencil function
  87851. * @param stencilFunc defines the new stencil function to use
  87852. */
  87853. setStencilFunction(stencilFunc: number): void;
  87854. /**
  87855. * Sets the current stencil reference
  87856. * @param reference defines the new stencil reference to use
  87857. */
  87858. setStencilFunctionReference(reference: number): void;
  87859. /**
  87860. * Sets the current stencil mask
  87861. * @param mask defines the new stencil mask to use
  87862. */
  87863. setStencilFunctionMask(mask: number): void;
  87864. /**
  87865. * Gets the current stencil operation when stencil fails
  87866. * @returns a number defining stencil operation to use when stencil fails
  87867. */
  87868. getStencilOperationFail(): number;
  87869. /**
  87870. * Gets the current stencil operation when depth fails
  87871. * @returns a number defining stencil operation to use when depth fails
  87872. */
  87873. getStencilOperationDepthFail(): number;
  87874. /**
  87875. * Gets the current stencil operation when stencil passes
  87876. * @returns a number defining stencil operation to use when stencil passes
  87877. */
  87878. getStencilOperationPass(): number;
  87879. /**
  87880. * Sets the stencil operation to use when stencil fails
  87881. * @param operation defines the stencil operation to use when stencil fails
  87882. */
  87883. setStencilOperationFail(operation: number): void;
  87884. /**
  87885. * Sets the stencil operation to use when depth fails
  87886. * @param operation defines the stencil operation to use when depth fails
  87887. */
  87888. setStencilOperationDepthFail(operation: number): void;
  87889. /**
  87890. * Sets the stencil operation to use when stencil passes
  87891. * @param operation defines the stencil operation to use when stencil passes
  87892. */
  87893. setStencilOperationPass(operation: number): void;
  87894. /**
  87895. * Sets a boolean indicating if the dithering state is enabled or disabled
  87896. * @param value defines the dithering state
  87897. */
  87898. setDitheringState(value: boolean): void;
  87899. /**
  87900. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87901. * @param value defines the rasterizer state
  87902. */
  87903. setRasterizerState(value: boolean): void;
  87904. /**
  87905. * stop executing a render loop function and remove it from the execution array
  87906. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87907. */
  87908. stopRenderLoop(renderFunction?: () => void): void;
  87909. /** @hidden */
  87910. _renderLoop(): void;
  87911. /**
  87912. * Register and execute a render loop. The engine can have more than one render function
  87913. * @param renderFunction defines the function to continuously execute
  87914. */
  87915. runRenderLoop(renderFunction: () => void): void;
  87916. /**
  87917. * Toggle full screen mode
  87918. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87919. */
  87920. switchFullscreen(requestPointerLock: boolean): void;
  87921. /**
  87922. * Enters full screen mode
  87923. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87924. */
  87925. enterFullscreen(requestPointerLock: boolean): void;
  87926. /**
  87927. * Exits full screen mode
  87928. */
  87929. exitFullscreen(): void;
  87930. /**
  87931. * Clear the current render buffer or the current render target (if any is set up)
  87932. * @param color defines the color to use
  87933. * @param backBuffer defines if the back buffer must be cleared
  87934. * @param depth defines if the depth buffer must be cleared
  87935. * @param stencil defines if the stencil buffer must be cleared
  87936. */
  87937. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87938. /**
  87939. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87940. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87941. * @param y defines the y-coordinate of the corner of the clear rectangle
  87942. * @param width defines the width of the clear rectangle
  87943. * @param height defines the height of the clear rectangle
  87944. * @param clearColor defines the clear color
  87945. */
  87946. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87947. /**
  87948. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87949. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87950. * @param y defines the y-coordinate of the corner of the clear rectangle
  87951. * @param width defines the width of the clear rectangle
  87952. * @param height defines the height of the clear rectangle
  87953. */
  87954. enableScissor(x: number, y: number, width: number, height: number): void;
  87955. /**
  87956. * Disable previously set scissor test rectangle
  87957. */
  87958. disableScissor(): void;
  87959. private _viewportCached;
  87960. /** @hidden */
  87961. _viewport(x: number, y: number, width: number, height: number): void;
  87962. /**
  87963. * Set the WebGL's viewport
  87964. * @param viewport defines the viewport element to be used
  87965. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87966. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87967. */
  87968. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87969. /**
  87970. * Directly set the WebGL Viewport
  87971. * @param x defines the x coordinate of the viewport (in screen space)
  87972. * @param y defines the y coordinate of the viewport (in screen space)
  87973. * @param width defines the width of the viewport (in screen space)
  87974. * @param height defines the height of the viewport (in screen space)
  87975. * @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
  87976. */
  87977. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87978. /**
  87979. * Begin a new frame
  87980. */
  87981. beginFrame(): void;
  87982. /**
  87983. * Enf the current frame
  87984. */
  87985. endFrame(): void;
  87986. /**
  87987. * Resize the view according to the canvas' size
  87988. */
  87989. resize(): void;
  87990. /**
  87991. * Force a specific size of the canvas
  87992. * @param width defines the new canvas' width
  87993. * @param height defines the new canvas' height
  87994. */
  87995. setSize(width: number, height: number): void;
  87996. /**
  87997. * Binds the frame buffer to the specified texture.
  87998. * @param texture The texture to render to or null for the default canvas
  87999. * @param faceIndex The face of the texture to render to in case of cube texture
  88000. * @param requiredWidth The width of the target to render to
  88001. * @param requiredHeight The height of the target to render to
  88002. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  88003. * @param depthStencilTexture The depth stencil texture to use to render
  88004. * @param lodLevel defines le lod level to bind to the frame buffer
  88005. */
  88006. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  88007. /** @hidden */
  88008. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  88009. /**
  88010. * Unbind the current render target texture from the webGL context
  88011. * @param texture defines the render target texture to unbind
  88012. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  88013. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  88014. */
  88015. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  88016. /**
  88017. * Force the mipmap generation for the given render target texture
  88018. * @param texture defines the render target texture to use
  88019. */
  88020. generateMipMapsForCubemap(texture: InternalTexture): void;
  88021. /**
  88022. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  88023. */
  88024. flushFramebuffer(): void;
  88025. /**
  88026. * Unbind the current render target and bind the default framebuffer
  88027. */
  88028. restoreDefaultFramebuffer(): void;
  88029. /**
  88030. * Create an uniform buffer
  88031. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88032. * @param elements defines the content of the uniform buffer
  88033. * @returns the webGL uniform buffer
  88034. */
  88035. createUniformBuffer(elements: FloatArray): DataBuffer;
  88036. /**
  88037. * Create a dynamic uniform buffer
  88038. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88039. * @param elements defines the content of the uniform buffer
  88040. * @returns the webGL uniform buffer
  88041. */
  88042. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88043. /**
  88044. * Update an existing uniform buffer
  88045. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88046. * @param uniformBuffer defines the target uniform buffer
  88047. * @param elements defines the content to update
  88048. * @param offset defines the offset in the uniform buffer where update should start
  88049. * @param count defines the size of the data to update
  88050. */
  88051. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88052. private _resetVertexBufferBinding;
  88053. /**
  88054. * Creates a vertex buffer
  88055. * @param data the data for the vertex buffer
  88056. * @returns the new WebGL static buffer
  88057. */
  88058. createVertexBuffer(data: DataArray): DataBuffer;
  88059. /**
  88060. * Creates a dynamic vertex buffer
  88061. * @param data the data for the dynamic vertex buffer
  88062. * @returns the new WebGL dynamic buffer
  88063. */
  88064. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  88065. /**
  88066. * Update a dynamic index buffer
  88067. * @param indexBuffer defines the target index buffer
  88068. * @param indices defines the data to update
  88069. * @param offset defines the offset in the target index buffer where update should start
  88070. */
  88071. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  88072. /**
  88073. * Updates a dynamic vertex buffer.
  88074. * @param vertexBuffer the vertex buffer to update
  88075. * @param data the data used to update the vertex buffer
  88076. * @param byteOffset the byte offset of the data
  88077. * @param byteLength the byte length of the data
  88078. */
  88079. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  88080. private _resetIndexBufferBinding;
  88081. /**
  88082. * Creates a new index buffer
  88083. * @param indices defines the content of the index buffer
  88084. * @param updatable defines if the index buffer must be updatable
  88085. * @returns a new webGL buffer
  88086. */
  88087. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  88088. /**
  88089. * Bind a webGL buffer to the webGL context
  88090. * @param buffer defines the buffer to bind
  88091. */
  88092. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  88093. /**
  88094. * Bind an uniform buffer to the current webGL context
  88095. * @param buffer defines the buffer to bind
  88096. */
  88097. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88098. /**
  88099. * Bind a buffer to the current webGL context at a given location
  88100. * @param buffer defines the buffer to bind
  88101. * @param location defines the index where to bind the buffer
  88102. */
  88103. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88104. /**
  88105. * Bind a specific block at a given index in a specific shader program
  88106. * @param pipelineContext defines the pipeline context to use
  88107. * @param blockName defines the block name
  88108. * @param index defines the index where to bind the block
  88109. */
  88110. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88111. private bindIndexBuffer;
  88112. private bindBuffer;
  88113. /**
  88114. * update the bound buffer with the given data
  88115. * @param data defines the data to update
  88116. */
  88117. updateArrayBuffer(data: Float32Array): void;
  88118. private _vertexAttribPointer;
  88119. private _bindIndexBufferWithCache;
  88120. private _bindVertexBuffersAttributes;
  88121. /**
  88122. * Records a vertex array object
  88123. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88124. * @param vertexBuffers defines the list of vertex buffers to store
  88125. * @param indexBuffer defines the index buffer to store
  88126. * @param effect defines the effect to store
  88127. * @returns the new vertex array object
  88128. */
  88129. recordVertexArrayObject(vertexBuffers: {
  88130. [key: string]: VertexBuffer;
  88131. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  88132. /**
  88133. * Bind a specific vertex array object
  88134. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  88135. * @param vertexArrayObject defines the vertex array object to bind
  88136. * @param indexBuffer defines the index buffer to bind
  88137. */
  88138. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  88139. /**
  88140. * Bind webGl buffers directly to the webGL context
  88141. * @param vertexBuffer defines the vertex buffer to bind
  88142. * @param indexBuffer defines the index buffer to bind
  88143. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  88144. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  88145. * @param effect defines the effect associated with the vertex buffer
  88146. */
  88147. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  88148. private _unbindVertexArrayObject;
  88149. /**
  88150. * Bind a list of vertex buffers to the webGL context
  88151. * @param vertexBuffers defines the list of vertex buffers to bind
  88152. * @param indexBuffer defines the index buffer to bind
  88153. * @param effect defines the effect associated with the vertex buffers
  88154. */
  88155. bindBuffers(vertexBuffers: {
  88156. [key: string]: Nullable<VertexBuffer>;
  88157. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  88158. /**
  88159. * Unbind all instance attributes
  88160. */
  88161. unbindInstanceAttributes(): void;
  88162. /**
  88163. * Release and free the memory of a vertex array object
  88164. * @param vao defines the vertex array object to delete
  88165. */
  88166. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  88167. /** @hidden */
  88168. _releaseBuffer(buffer: DataBuffer): boolean;
  88169. /**
  88170. * Creates a webGL buffer to use with instanciation
  88171. * @param capacity defines the size of the buffer
  88172. * @returns the webGL buffer
  88173. */
  88174. createInstancesBuffer(capacity: number): DataBuffer;
  88175. /**
  88176. * Delete a webGL buffer used with instanciation
  88177. * @param buffer defines the webGL buffer to delete
  88178. */
  88179. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  88180. /**
  88181. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  88182. * @param instancesBuffer defines the webGL buffer to update and bind
  88183. * @param data defines the data to store in the buffer
  88184. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  88185. */
  88186. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  88187. /**
  88188. * Apply all cached states (depth, culling, stencil and alpha)
  88189. */
  88190. applyStates(): void;
  88191. /**
  88192. * Send a draw order
  88193. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88194. * @param indexStart defines the starting index
  88195. * @param indexCount defines the number of index to draw
  88196. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88197. */
  88198. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  88199. /**
  88200. * Draw a list of points
  88201. * @param verticesStart defines the index of first vertex to draw
  88202. * @param verticesCount defines the count of vertices to draw
  88203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88204. */
  88205. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88206. /**
  88207. * Draw a list of unindexed primitives
  88208. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  88209. * @param verticesStart defines the index of first vertex to draw
  88210. * @param verticesCount defines the count of vertices to draw
  88211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88212. */
  88213. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88214. /**
  88215. * Draw a list of indexed primitives
  88216. * @param fillMode defines the primitive to use
  88217. * @param indexStart defines the starting index
  88218. * @param indexCount defines the number of index to draw
  88219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88220. */
  88221. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  88222. /**
  88223. * Draw a list of unindexed primitives
  88224. * @param fillMode defines the primitive to use
  88225. * @param verticesStart defines the index of first vertex to draw
  88226. * @param verticesCount defines the count of vertices to draw
  88227. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  88228. */
  88229. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  88230. private _drawMode;
  88231. /** @hidden */
  88232. _releaseEffect(effect: Effect): void;
  88233. /** @hidden */
  88234. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  88235. /**
  88236. * Create a new effect (used to store vertex/fragment shaders)
  88237. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  88238. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  88239. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  88240. * @param samplers defines an array of string used to represent textures
  88241. * @param defines defines the string containing the defines to use to compile the shaders
  88242. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  88243. * @param onCompiled defines a function to call when the effect creation is successful
  88244. * @param onError defines a function to call when the effect creation has failed
  88245. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  88246. * @returns the new Effect
  88247. */
  88248. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  88249. private _compileShader;
  88250. private _compileRawShader;
  88251. /**
  88252. * Directly creates a webGL program
  88253. * @param pipelineContext defines the pipeline context to attach to
  88254. * @param vertexCode defines the vertex shader code to use
  88255. * @param fragmentCode defines the fragment shader code to use
  88256. * @param context defines the webGL context to use (if not set, the current one will be used)
  88257. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88258. * @returns the new webGL program
  88259. */
  88260. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88261. /**
  88262. * Creates a webGL program
  88263. * @param pipelineContext defines the pipeline context to attach to
  88264. * @param vertexCode defines the vertex shader code to use
  88265. * @param fragmentCode defines the fragment shader code to use
  88266. * @param defines defines the string containing the defines to use to compile the shaders
  88267. * @param context defines the webGL context to use (if not set, the current one will be used)
  88268. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  88269. * @returns the new webGL program
  88270. */
  88271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  88272. /**
  88273. * Creates a new pipeline context
  88274. * @returns the new pipeline
  88275. */
  88276. createPipelineContext(): WebGLPipelineContext;
  88277. private _createShaderProgram;
  88278. private _finalizePipelineContext;
  88279. /** @hidden */
  88280. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  88281. /** @hidden */
  88282. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  88283. /** @hidden */
  88284. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  88285. /**
  88286. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  88287. * @param pipelineContext defines the pipeline context to use
  88288. * @param uniformsNames defines the list of uniform names
  88289. * @returns an array of webGL uniform locations
  88290. */
  88291. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  88292. /**
  88293. * Gets the lsit of active attributes for a given webGL program
  88294. * @param pipelineContext defines the pipeline context to use
  88295. * @param attributesNames defines the list of attribute names to get
  88296. * @returns an array of indices indicating the offset of each attribute
  88297. */
  88298. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  88299. /**
  88300. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  88301. * @param effect defines the effect to activate
  88302. */
  88303. enableEffect(effect: Nullable<Effect>): void;
  88304. /**
  88305. * Set the value of an uniform to an array of int32
  88306. * @param uniform defines the webGL uniform location where to store the value
  88307. * @param array defines the array of int32 to store
  88308. */
  88309. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88310. /**
  88311. * Set the value of an uniform to an array of int32 (stored as vec2)
  88312. * @param uniform defines the webGL uniform location where to store the value
  88313. * @param array defines the array of int32 to store
  88314. */
  88315. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88316. /**
  88317. * Set the value of an uniform to an array of int32 (stored as vec3)
  88318. * @param uniform defines the webGL uniform location where to store the value
  88319. * @param array defines the array of int32 to store
  88320. */
  88321. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88322. /**
  88323. * Set the value of an uniform to an array of int32 (stored as vec4)
  88324. * @param uniform defines the webGL uniform location where to store the value
  88325. * @param array defines the array of int32 to store
  88326. */
  88327. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  88328. /**
  88329. * Set the value of an uniform to an array of float32
  88330. * @param uniform defines the webGL uniform location where to store the value
  88331. * @param array defines the array of float32 to store
  88332. */
  88333. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88334. /**
  88335. * Set the value of an uniform to an array of float32 (stored as vec2)
  88336. * @param uniform defines the webGL uniform location where to store the value
  88337. * @param array defines the array of float32 to store
  88338. */
  88339. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88340. /**
  88341. * Set the value of an uniform to an array of float32 (stored as vec3)
  88342. * @param uniform defines the webGL uniform location where to store the value
  88343. * @param array defines the array of float32 to store
  88344. */
  88345. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88346. /**
  88347. * Set the value of an uniform to an array of float32 (stored as vec4)
  88348. * @param uniform defines the webGL uniform location where to store the value
  88349. * @param array defines the array of float32 to store
  88350. */
  88351. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  88352. /**
  88353. * Set the value of an uniform to an array of number
  88354. * @param uniform defines the webGL uniform location where to store the value
  88355. * @param array defines the array of number to store
  88356. */
  88357. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88358. /**
  88359. * Set the value of an uniform to an array of number (stored as vec2)
  88360. * @param uniform defines the webGL uniform location where to store the value
  88361. * @param array defines the array of number to store
  88362. */
  88363. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88364. /**
  88365. * Set the value of an uniform to an array of number (stored as vec3)
  88366. * @param uniform defines the webGL uniform location where to store the value
  88367. * @param array defines the array of number to store
  88368. */
  88369. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88370. /**
  88371. * Set the value of an uniform to an array of number (stored as vec4)
  88372. * @param uniform defines the webGL uniform location where to store the value
  88373. * @param array defines the array of number to store
  88374. */
  88375. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  88376. /**
  88377. * Set the value of an uniform to an array of float32 (stored as matrices)
  88378. * @param uniform defines the webGL uniform location where to store the value
  88379. * @param matrices defines the array of float32 to store
  88380. */
  88381. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  88382. /**
  88383. * Set the value of an uniform to a matrix
  88384. * @param uniform defines the webGL uniform location where to store the value
  88385. * @param matrix defines the matrix to store
  88386. */
  88387. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  88388. /**
  88389. * Set the value of an uniform to a matrix (3x3)
  88390. * @param uniform defines the webGL uniform location where to store the value
  88391. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  88392. */
  88393. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88394. /**
  88395. * Set the value of an uniform to a matrix (2x2)
  88396. * @param uniform defines the webGL uniform location where to store the value
  88397. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  88398. */
  88399. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  88400. /**
  88401. * Set the value of an uniform to a number (int)
  88402. * @param uniform defines the webGL uniform location where to store the value
  88403. * @param value defines the int number to store
  88404. */
  88405. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88406. /**
  88407. * Set the value of an uniform to a number (float)
  88408. * @param uniform defines the webGL uniform location where to store the value
  88409. * @param value defines the float number to store
  88410. */
  88411. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  88412. /**
  88413. * Set the value of an uniform to a vec2
  88414. * @param uniform defines the webGL uniform location where to store the value
  88415. * @param x defines the 1st component of the value
  88416. * @param y defines the 2nd component of the value
  88417. */
  88418. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  88419. /**
  88420. * Set the value of an uniform to a vec3
  88421. * @param uniform defines the webGL uniform location where to store the value
  88422. * @param x defines the 1st component of the value
  88423. * @param y defines the 2nd component of the value
  88424. * @param z defines the 3rd component of the value
  88425. */
  88426. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  88427. /**
  88428. * Set the value of an uniform to a boolean
  88429. * @param uniform defines the webGL uniform location where to store the value
  88430. * @param bool defines the boolean to store
  88431. */
  88432. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  88433. /**
  88434. * Set the value of an uniform to a vec4
  88435. * @param uniform defines the webGL uniform location where to store the value
  88436. * @param x defines the 1st component of the value
  88437. * @param y defines the 2nd component of the value
  88438. * @param z defines the 3rd component of the value
  88439. * @param w defines the 4th component of the value
  88440. */
  88441. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  88442. /**
  88443. * Set the value of an uniform to a Color3
  88444. * @param uniform defines the webGL uniform location where to store the value
  88445. * @param color3 defines the color to store
  88446. */
  88447. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  88448. /**
  88449. * Set the value of an uniform to a Color3 and an alpha value
  88450. * @param uniform defines the webGL uniform location where to store the value
  88451. * @param color3 defines the color to store
  88452. * @param alpha defines the alpha component to store
  88453. */
  88454. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  88455. /**
  88456. * Sets a Color4 on a uniform variable
  88457. * @param uniform defines the uniform location
  88458. * @param color4 defines the value to be set
  88459. */
  88460. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  88461. /**
  88462. * Set various states to the webGL context
  88463. * @param culling defines backface culling state
  88464. * @param zOffset defines the value to apply to zOffset (0 by default)
  88465. * @param force defines if states must be applied even if cache is up to date
  88466. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  88467. */
  88468. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88469. /**
  88470. * Set the z offset to apply to current rendering
  88471. * @param value defines the offset to apply
  88472. */
  88473. setZOffset(value: number): void;
  88474. /**
  88475. * Gets the current value of the zOffset
  88476. * @returns the current zOffset state
  88477. */
  88478. getZOffset(): number;
  88479. /**
  88480. * Enable or disable depth buffering
  88481. * @param enable defines the state to set
  88482. */
  88483. setDepthBuffer(enable: boolean): void;
  88484. /**
  88485. * Gets a boolean indicating if depth writing is enabled
  88486. * @returns the current depth writing state
  88487. */
  88488. getDepthWrite(): boolean;
  88489. /**
  88490. * Enable or disable depth writing
  88491. * @param enable defines the state to set
  88492. */
  88493. setDepthWrite(enable: boolean): void;
  88494. /**
  88495. * Enable or disable color writing
  88496. * @param enable defines the state to set
  88497. */
  88498. setColorWrite(enable: boolean): void;
  88499. /**
  88500. * Gets a boolean indicating if color writing is enabled
  88501. * @returns the current color writing state
  88502. */
  88503. getColorWrite(): boolean;
  88504. /**
  88505. * Sets alpha constants used by some alpha blending modes
  88506. * @param r defines the red component
  88507. * @param g defines the green component
  88508. * @param b defines the blue component
  88509. * @param a defines the alpha component
  88510. */
  88511. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88512. /**
  88513. * Sets the current alpha mode
  88514. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88515. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88517. */
  88518. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88519. /**
  88520. * Gets the current alpha mode
  88521. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88522. * @returns the current alpha mode
  88523. */
  88524. getAlphaMode(): number;
  88525. /**
  88526. * Clears the list of texture accessible through engine.
  88527. * This can help preventing texture load conflict due to name collision.
  88528. */
  88529. clearInternalTexturesCache(): void;
  88530. /**
  88531. * Force the entire cache to be cleared
  88532. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88533. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88534. */
  88535. wipeCaches(bruteForce?: boolean): void;
  88536. /**
  88537. * Set the compressed texture format to use, based on the formats you have, and the formats
  88538. * supported by the hardware / browser.
  88539. *
  88540. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88541. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88542. * to API arguments needed to compressed textures. This puts the burden on the container
  88543. * generator to house the arcane code for determining these for current & future formats.
  88544. *
  88545. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88546. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88547. *
  88548. * Note: The result of this call is not taken into account when a texture is base64.
  88549. *
  88550. * @param formatsAvailable defines the list of those format families you have created
  88551. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88552. *
  88553. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88554. * @returns The extension selected.
  88555. */
  88556. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88557. /** @hidden */
  88558. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88559. min: number;
  88560. mag: number;
  88561. };
  88562. /** @hidden */
  88563. _createTexture(): WebGLTexture;
  88564. /**
  88565. * Usually called from Texture.ts.
  88566. * Passed information to create a WebGLTexture
  88567. * @param urlArg defines a value which contains one of the following:
  88568. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88569. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88570. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88571. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88572. * @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)
  88573. * @param scene needed for loading to the correct scene
  88574. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88575. * @param onLoad optional callback to be called upon successful completion
  88576. * @param onError optional callback to be called upon failure
  88577. * @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
  88578. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88579. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88580. * @param forcedExtension defines the extension to use to pick the right loader
  88581. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88582. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88583. */
  88584. 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;
  88585. private _rescaleTexture;
  88586. private _unpackFlipYCached;
  88587. /**
  88588. * In case you are sharing the context with other applications, it might
  88589. * be interested to not cache the unpack flip y state to ensure a consistent
  88590. * value would be set.
  88591. */
  88592. enableUnpackFlipYCached: boolean;
  88593. /** @hidden */
  88594. _unpackFlipY(value: boolean): void;
  88595. /** @hidden */
  88596. _getUnpackAlignement(): number;
  88597. /**
  88598. * Creates a dynamic texture
  88599. * @param width defines the width of the texture
  88600. * @param height defines the height of the texture
  88601. * @param generateMipMaps defines if the engine should generate the mip levels
  88602. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88603. * @returns the dynamic texture inside an InternalTexture
  88604. */
  88605. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88606. /**
  88607. * Update the sampling mode of a given texture
  88608. * @param samplingMode defines the required sampling mode
  88609. * @param texture defines the texture to update
  88610. */
  88611. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88612. /**
  88613. * Update the content of a dynamic texture
  88614. * @param texture defines the texture to update
  88615. * @param canvas defines the canvas containing the source
  88616. * @param invertY defines if data must be stored with Y axis inverted
  88617. * @param premulAlpha defines if alpha is stored as premultiplied
  88618. * @param format defines the format of the data
  88619. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88620. */
  88621. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88622. /**
  88623. * Update a video texture
  88624. * @param texture defines the texture to update
  88625. * @param video defines the video element to use
  88626. * @param invertY defines if data must be stored with Y axis inverted
  88627. */
  88628. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88629. /**
  88630. * Updates a depth texture Comparison Mode and Function.
  88631. * If the comparison Function is equal to 0, the mode will be set to none.
  88632. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88633. * @param texture The texture to set the comparison function for
  88634. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88635. */
  88636. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88637. /** @hidden */
  88638. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  88639. width: number;
  88640. height: number;
  88641. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  88642. /**
  88643. * Creates a depth stencil texture.
  88644. * This is only available in WebGL 2 or with the depth texture extension available.
  88645. * @param size The size of face edge in the texture.
  88646. * @param options The options defining the texture.
  88647. * @returns The texture
  88648. */
  88649. createDepthStencilTexture(size: number | {
  88650. width: number;
  88651. height: number;
  88652. }, options: DepthTextureCreationOptions): InternalTexture;
  88653. /**
  88654. * Creates a depth stencil texture.
  88655. * This is only available in WebGL 2 or with the depth texture extension available.
  88656. * @param size The size of face edge in the texture.
  88657. * @param options The options defining the texture.
  88658. * @returns The texture
  88659. */
  88660. private _createDepthStencilTexture;
  88661. /**
  88662. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88663. * @param renderTarget The render target to set the frame buffer for
  88664. */
  88665. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88666. /**
  88667. * Creates a new render target texture
  88668. * @param size defines the size of the texture
  88669. * @param options defines the options used to create the texture
  88670. * @returns a new render target texture stored in an InternalTexture
  88671. */
  88672. createRenderTargetTexture(size: number | {
  88673. width: number;
  88674. height: number;
  88675. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88676. /** @hidden */
  88677. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  88678. /**
  88679. * Updates the sample count of a render target texture
  88680. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88681. * @param texture defines the texture to update
  88682. * @param samples defines the sample count to set
  88683. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88684. */
  88685. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88686. /** @hidden */
  88687. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88688. /** @hidden */
  88689. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88690. /** @hidden */
  88691. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88692. /** @hidden */
  88693. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88694. /**
  88695. * @hidden
  88696. */
  88697. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88698. private _prepareWebGLTextureContinuation;
  88699. private _prepareWebGLTexture;
  88700. /** @hidden */
  88701. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88702. /** @hidden */
  88703. _releaseFramebufferObjects(texture: InternalTexture): void;
  88704. /** @hidden */
  88705. _releaseTexture(texture: InternalTexture): void;
  88706. private setProgram;
  88707. private _boundUniforms;
  88708. /**
  88709. * Binds an effect to the webGL context
  88710. * @param effect defines the effect to bind
  88711. */
  88712. bindSamplers(effect: Effect): void;
  88713. private _activateCurrentTexture;
  88714. /** @hidden */
  88715. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88716. /** @hidden */
  88717. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88718. /**
  88719. * Sets a texture to the webGL context from a postprocess
  88720. * @param channel defines the channel to use
  88721. * @param postProcess defines the source postprocess
  88722. */
  88723. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88724. /**
  88725. * Binds the output of the passed in post process to the texture channel specified
  88726. * @param channel The channel the texture should be bound to
  88727. * @param postProcess The post process which's output should be bound
  88728. */
  88729. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88730. /**
  88731. * Unbind all textures from the webGL context
  88732. */
  88733. unbindAllTextures(): void;
  88734. /**
  88735. * Sets a texture to the according uniform.
  88736. * @param channel The texture channel
  88737. * @param uniform The uniform to set
  88738. * @param texture The texture to apply
  88739. */
  88740. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88741. /**
  88742. * Sets a depth stencil texture from a render target to the according uniform.
  88743. * @param channel The texture channel
  88744. * @param uniform The uniform to set
  88745. * @param texture The render target texture containing the depth stencil texture to apply
  88746. */
  88747. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88748. private _bindSamplerUniformToChannel;
  88749. private _getTextureWrapMode;
  88750. private _setTexture;
  88751. /**
  88752. * Sets an array of texture to the webGL context
  88753. * @param channel defines the channel where the texture array must be set
  88754. * @param uniform defines the associated uniform location
  88755. * @param textures defines the array of textures to bind
  88756. */
  88757. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88758. /** @hidden */
  88759. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88760. private _setTextureParameterFloat;
  88761. private _setTextureParameterInteger;
  88762. /**
  88763. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88764. * @param x defines the x coordinate of the rectangle where pixels must be read
  88765. * @param y defines the y coordinate of the rectangle where pixels must be read
  88766. * @param width defines the width of the rectangle where pixels must be read
  88767. * @param height defines the height of the rectangle where pixels must be read
  88768. * @returns a Uint8Array containing RGBA colors
  88769. */
  88770. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88771. /**
  88772. * Add an externaly attached data from its key.
  88773. * This method call will fail and return false, if such key already exists.
  88774. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88775. * @param key the unique key that identifies the data
  88776. * @param data the data object to associate to the key for this Engine instance
  88777. * @return true if no such key were already present and the data was added successfully, false otherwise
  88778. */
  88779. addExternalData<T>(key: string, data: T): boolean;
  88780. /**
  88781. * Get an externaly attached data from its key
  88782. * @param key the unique key that identifies the data
  88783. * @return the associated data, if present (can be null), or undefined if not present
  88784. */
  88785. getExternalData<T>(key: string): T;
  88786. /**
  88787. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88788. * @param key the unique key that identifies the data
  88789. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88790. * @return the associated data, can be null if the factory returned null.
  88791. */
  88792. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88793. /**
  88794. * Remove an externaly attached data from the Engine instance
  88795. * @param key the unique key that identifies the data
  88796. * @return true if the data was successfully removed, false if it doesn't exist
  88797. */
  88798. removeExternalData(key: string): boolean;
  88799. /**
  88800. * Unbind all vertex attributes from the webGL context
  88801. */
  88802. unbindAllAttributes(): void;
  88803. /**
  88804. * 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
  88805. */
  88806. releaseEffects(): void;
  88807. /**
  88808. * Dispose and release all associated resources
  88809. */
  88810. dispose(): void;
  88811. /**
  88812. * Display the loading screen
  88813. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88814. */
  88815. displayLoadingUI(): void;
  88816. /**
  88817. * Hide the loading screen
  88818. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88819. */
  88820. hideLoadingUI(): void;
  88821. /**
  88822. * Gets the current loading screen object
  88823. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88824. */
  88825. /**
  88826. * Sets the current loading screen object
  88827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88828. */
  88829. loadingScreen: ILoadingScreen;
  88830. /**
  88831. * Sets the current loading screen text
  88832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88833. */
  88834. loadingUIText: string;
  88835. /**
  88836. * Sets the current loading screen background color
  88837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88838. */
  88839. loadingUIBackgroundColor: string;
  88840. /**
  88841. * Attach a new callback raised when context lost event is fired
  88842. * @param callback defines the callback to call
  88843. */
  88844. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88845. /**
  88846. * Attach a new callback raised when context restored event is fired
  88847. * @param callback defines the callback to call
  88848. */
  88849. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88850. /**
  88851. * Gets the source code of the vertex shader associated with a specific webGL program
  88852. * @param program defines the program to use
  88853. * @returns a string containing the source code of the vertex shader associated with the program
  88854. */
  88855. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88856. /**
  88857. * Gets the source code of the fragment shader associated with a specific webGL program
  88858. * @param program defines the program to use
  88859. * @returns a string containing the source code of the fragment shader associated with the program
  88860. */
  88861. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88862. /**
  88863. * Get the current error code of the webGL context
  88864. * @returns the error code
  88865. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88866. */
  88867. getError(): number;
  88868. /**
  88869. * Gets the current framerate
  88870. * @returns a number representing the framerate
  88871. */
  88872. getFps(): number;
  88873. /**
  88874. * Gets the time spent between current and previous frame
  88875. * @returns a number representing the delta time in ms
  88876. */
  88877. getDeltaTime(): number;
  88878. private _measureFps;
  88879. /** @hidden */
  88880. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88881. private _canRenderToFloatFramebuffer;
  88882. private _canRenderToHalfFloatFramebuffer;
  88883. private _canRenderToFramebuffer;
  88884. /** @hidden */
  88885. _getWebGLTextureType(type: number): number;
  88886. /** @hidden */
  88887. _getInternalFormat(format: number): number;
  88888. /** @hidden */
  88889. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88890. /** @hidden */
  88891. _getRGBAMultiSampleBufferFormat(type: number): number;
  88892. /** @hidden */
  88893. _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;
  88894. /** @hidden */
  88895. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88896. /**
  88897. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88898. * @returns true if the engine can be created
  88899. * @ignorenaming
  88900. */
  88901. static isSupported(): boolean;
  88902. }
  88903. }
  88904. declare module BABYLON {
  88905. /**
  88906. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88907. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88908. */
  88909. export class EffectFallbacks {
  88910. private _defines;
  88911. private _currentRank;
  88912. private _maxRank;
  88913. private _mesh;
  88914. /**
  88915. * Removes the fallback from the bound mesh.
  88916. */
  88917. unBindMesh(): void;
  88918. /**
  88919. * Adds a fallback on the specified property.
  88920. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88921. * @param define The name of the define in the shader
  88922. */
  88923. addFallback(rank: number, define: string): void;
  88924. /**
  88925. * Sets the mesh to use CPU skinning when needing to fallback.
  88926. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88927. * @param mesh The mesh to use the fallbacks.
  88928. */
  88929. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88930. /**
  88931. * Checks to see if more fallbacks are still availible.
  88932. */
  88933. readonly isMoreFallbacks: boolean;
  88934. /**
  88935. * Removes the defines that shoould be removed when falling back.
  88936. * @param currentDefines defines the current define statements for the shader.
  88937. * @param effect defines the current effect we try to compile
  88938. * @returns The resulting defines with defines of the current rank removed.
  88939. */
  88940. reduce(currentDefines: string, effect: Effect): string;
  88941. }
  88942. /**
  88943. * Options to be used when creating an effect.
  88944. */
  88945. export class EffectCreationOptions {
  88946. /**
  88947. * Atrributes that will be used in the shader.
  88948. */
  88949. attributes: string[];
  88950. /**
  88951. * Uniform varible names that will be set in the shader.
  88952. */
  88953. uniformsNames: string[];
  88954. /**
  88955. * Uniform buffer varible names that will be set in the shader.
  88956. */
  88957. uniformBuffersNames: string[];
  88958. /**
  88959. * Sampler texture variable names that will be set in the shader.
  88960. */
  88961. samplers: string[];
  88962. /**
  88963. * Define statements that will be set in the shader.
  88964. */
  88965. defines: any;
  88966. /**
  88967. * Possible fallbacks for this effect to improve performance when needed.
  88968. */
  88969. fallbacks: Nullable<EffectFallbacks>;
  88970. /**
  88971. * Callback that will be called when the shader is compiled.
  88972. */
  88973. onCompiled: Nullable<(effect: Effect) => void>;
  88974. /**
  88975. * Callback that will be called if an error occurs during shader compilation.
  88976. */
  88977. onError: Nullable<(effect: Effect, errors: string) => void>;
  88978. /**
  88979. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88980. */
  88981. indexParameters: any;
  88982. /**
  88983. * Max number of lights that can be used in the shader.
  88984. */
  88985. maxSimultaneousLights: number;
  88986. /**
  88987. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88988. */
  88989. transformFeedbackVaryings: Nullable<string[]>;
  88990. }
  88991. /**
  88992. * Effect containing vertex and fragment shader that can be executed on an object.
  88993. */
  88994. export class Effect implements IDisposable {
  88995. /**
  88996. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88997. */
  88998. static ShadersRepository: string;
  88999. /**
  89000. * Name of the effect.
  89001. */
  89002. name: any;
  89003. /**
  89004. * String container all the define statements that should be set on the shader.
  89005. */
  89006. defines: string;
  89007. /**
  89008. * Callback that will be called when the shader is compiled.
  89009. */
  89010. onCompiled: Nullable<(effect: Effect) => void>;
  89011. /**
  89012. * Callback that will be called if an error occurs during shader compilation.
  89013. */
  89014. onError: Nullable<(effect: Effect, errors: string) => void>;
  89015. /**
  89016. * Callback that will be called when effect is bound.
  89017. */
  89018. onBind: Nullable<(effect: Effect) => void>;
  89019. /**
  89020. * Unique ID of the effect.
  89021. */
  89022. uniqueId: number;
  89023. /**
  89024. * Observable that will be called when the shader is compiled.
  89025. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  89026. */
  89027. onCompileObservable: Observable<Effect>;
  89028. /**
  89029. * Observable that will be called if an error occurs during shader compilation.
  89030. */
  89031. onErrorObservable: Observable<Effect>;
  89032. /** @hidden */
  89033. _onBindObservable: Nullable<Observable<Effect>>;
  89034. /**
  89035. * Observable that will be called when effect is bound.
  89036. */
  89037. readonly onBindObservable: Observable<Effect>;
  89038. /** @hidden */
  89039. _bonesComputationForcedToCPU: boolean;
  89040. private static _uniqueIdSeed;
  89041. private _engine;
  89042. private _uniformBuffersNames;
  89043. private _uniformsNames;
  89044. private _samplerList;
  89045. private _samplers;
  89046. private _isReady;
  89047. private _compilationError;
  89048. private _attributesNames;
  89049. private _attributes;
  89050. private _uniforms;
  89051. /**
  89052. * Key for the effect.
  89053. * @hidden
  89054. */
  89055. _key: string;
  89056. private _indexParameters;
  89057. private _fallbacks;
  89058. private _vertexSourceCode;
  89059. private _fragmentSourceCode;
  89060. private _vertexSourceCodeOverride;
  89061. private _fragmentSourceCodeOverride;
  89062. private _transformFeedbackVaryings;
  89063. /**
  89064. * Compiled shader to webGL program.
  89065. * @hidden
  89066. */
  89067. _pipelineContext: IPipelineContext;
  89068. private _valueCache;
  89069. private static _baseCache;
  89070. /**
  89071. * Instantiates an effect.
  89072. * An effect can be used to create/manage/execute vertex and fragment shaders.
  89073. * @param baseName Name of the effect.
  89074. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  89075. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  89076. * @param samplers List of sampler variables that will be passed to the shader.
  89077. * @param engine Engine to be used to render the effect
  89078. * @param defines Define statements to be added to the shader.
  89079. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  89080. * @param onCompiled Callback that will be called when the shader is compiled.
  89081. * @param onError Callback that will be called if an error occurs during shader compilation.
  89082. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  89083. */
  89084. 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);
  89085. /**
  89086. * Unique key for this effect
  89087. */
  89088. readonly key: string;
  89089. /**
  89090. * If the effect has been compiled and prepared.
  89091. * @returns if the effect is compiled and prepared.
  89092. */
  89093. isReady(): boolean;
  89094. /**
  89095. * The engine the effect was initialized with.
  89096. * @returns the engine.
  89097. */
  89098. getEngine(): Engine;
  89099. /**
  89100. * The pipeline context for this effect
  89101. * @returns the associated pipeline context
  89102. */
  89103. getPipelineContext(): IPipelineContext;
  89104. /**
  89105. * The set of names of attribute variables for the shader.
  89106. * @returns An array of attribute names.
  89107. */
  89108. getAttributesNames(): string[];
  89109. /**
  89110. * Returns the attribute at the given index.
  89111. * @param index The index of the attribute.
  89112. * @returns The location of the attribute.
  89113. */
  89114. getAttributeLocation(index: number): number;
  89115. /**
  89116. * Returns the attribute based on the name of the variable.
  89117. * @param name of the attribute to look up.
  89118. * @returns the attribute location.
  89119. */
  89120. getAttributeLocationByName(name: string): number;
  89121. /**
  89122. * The number of attributes.
  89123. * @returns the numnber of attributes.
  89124. */
  89125. getAttributesCount(): number;
  89126. /**
  89127. * Gets the index of a uniform variable.
  89128. * @param uniformName of the uniform to look up.
  89129. * @returns the index.
  89130. */
  89131. getUniformIndex(uniformName: string): number;
  89132. /**
  89133. * Returns the attribute based on the name of the variable.
  89134. * @param uniformName of the uniform to look up.
  89135. * @returns the location of the uniform.
  89136. */
  89137. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  89138. /**
  89139. * Returns an array of sampler variable names
  89140. * @returns The array of sampler variable neames.
  89141. */
  89142. getSamplers(): string[];
  89143. /**
  89144. * The error from the last compilation.
  89145. * @returns the error string.
  89146. */
  89147. getCompilationError(): string;
  89148. /**
  89149. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  89150. * @param func The callback to be used.
  89151. */
  89152. executeWhenCompiled(func: (effect: Effect) => void): void;
  89153. private _checkIsReady;
  89154. /** @hidden */
  89155. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  89156. /** @hidden */
  89157. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  89158. /** @hidden */
  89159. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  89160. private _processShaderConversion;
  89161. private _processIncludes;
  89162. private _processPrecision;
  89163. /**
  89164. * Recompiles the webGL program
  89165. * @param vertexSourceCode The source code for the vertex shader.
  89166. * @param fragmentSourceCode The source code for the fragment shader.
  89167. * @param onCompiled Callback called when completed.
  89168. * @param onError Callback called on error.
  89169. * @hidden
  89170. */
  89171. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  89172. /**
  89173. * Prepares the effect
  89174. * @hidden
  89175. */
  89176. _prepareEffect(): void;
  89177. /**
  89178. * Checks if the effect is supported. (Must be called after compilation)
  89179. */
  89180. readonly isSupported: boolean;
  89181. /**
  89182. * Binds a texture to the engine to be used as output of the shader.
  89183. * @param channel Name of the output variable.
  89184. * @param texture Texture to bind.
  89185. * @hidden
  89186. */
  89187. _bindTexture(channel: string, texture: InternalTexture): void;
  89188. /**
  89189. * Sets a texture on the engine to be used in the shader.
  89190. * @param channel Name of the sampler variable.
  89191. * @param texture Texture to set.
  89192. */
  89193. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  89194. /**
  89195. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  89196. * @param channel Name of the sampler variable.
  89197. * @param texture Texture to set.
  89198. */
  89199. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  89200. /**
  89201. * Sets an array of textures on the engine to be used in the shader.
  89202. * @param channel Name of the variable.
  89203. * @param textures Textures to set.
  89204. */
  89205. setTextureArray(channel: string, textures: BaseTexture[]): void;
  89206. /**
  89207. * 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)
  89208. * @param channel Name of the sampler variable.
  89209. * @param postProcess Post process to get the input texture from.
  89210. */
  89211. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  89212. /**
  89213. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  89214. * 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)
  89215. * @param channel Name of the sampler variable.
  89216. * @param postProcess Post process to get the output texture from.
  89217. */
  89218. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  89219. /** @hidden */
  89220. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  89221. /** @hidden */
  89222. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  89223. /** @hidden */
  89224. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  89225. /** @hidden */
  89226. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  89227. /**
  89228. * Binds a buffer to a uniform.
  89229. * @param buffer Buffer to bind.
  89230. * @param name Name of the uniform variable to bind to.
  89231. */
  89232. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  89233. /**
  89234. * Binds block to a uniform.
  89235. * @param blockName Name of the block to bind.
  89236. * @param index Index to bind.
  89237. */
  89238. bindUniformBlock(blockName: string, index: number): void;
  89239. /**
  89240. * Sets an interger value on a uniform variable.
  89241. * @param uniformName Name of the variable.
  89242. * @param value Value to be set.
  89243. * @returns this effect.
  89244. */
  89245. setInt(uniformName: string, value: number): Effect;
  89246. /**
  89247. * Sets an int array on a uniform variable.
  89248. * @param uniformName Name of the variable.
  89249. * @param array array to be set.
  89250. * @returns this effect.
  89251. */
  89252. setIntArray(uniformName: string, array: Int32Array): Effect;
  89253. /**
  89254. * 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)
  89255. * @param uniformName Name of the variable.
  89256. * @param array array to be set.
  89257. * @returns this effect.
  89258. */
  89259. setIntArray2(uniformName: string, array: Int32Array): Effect;
  89260. /**
  89261. * 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)
  89262. * @param uniformName Name of the variable.
  89263. * @param array array to be set.
  89264. * @returns this effect.
  89265. */
  89266. setIntArray3(uniformName: string, array: Int32Array): Effect;
  89267. /**
  89268. * 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)
  89269. * @param uniformName Name of the variable.
  89270. * @param array array to be set.
  89271. * @returns this effect.
  89272. */
  89273. setIntArray4(uniformName: string, array: Int32Array): Effect;
  89274. /**
  89275. * Sets an float array on a uniform variable.
  89276. * @param uniformName Name of the variable.
  89277. * @param array array to be set.
  89278. * @returns this effect.
  89279. */
  89280. setFloatArray(uniformName: string, array: Float32Array): Effect;
  89281. /**
  89282. * 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)
  89283. * @param uniformName Name of the variable.
  89284. * @param array array to be set.
  89285. * @returns this effect.
  89286. */
  89287. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  89288. /**
  89289. * 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)
  89290. * @param uniformName Name of the variable.
  89291. * @param array array to be set.
  89292. * @returns this effect.
  89293. */
  89294. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  89295. /**
  89296. * 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)
  89297. * @param uniformName Name of the variable.
  89298. * @param array array to be set.
  89299. * @returns this effect.
  89300. */
  89301. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  89302. /**
  89303. * Sets an array on a uniform variable.
  89304. * @param uniformName Name of the variable.
  89305. * @param array array to be set.
  89306. * @returns this effect.
  89307. */
  89308. setArray(uniformName: string, array: number[]): Effect;
  89309. /**
  89310. * 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)
  89311. * @param uniformName Name of the variable.
  89312. * @param array array to be set.
  89313. * @returns this effect.
  89314. */
  89315. setArray2(uniformName: string, array: number[]): Effect;
  89316. /**
  89317. * 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)
  89318. * @param uniformName Name of the variable.
  89319. * @param array array to be set.
  89320. * @returns this effect.
  89321. */
  89322. setArray3(uniformName: string, array: number[]): Effect;
  89323. /**
  89324. * 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)
  89325. * @param uniformName Name of the variable.
  89326. * @param array array to be set.
  89327. * @returns this effect.
  89328. */
  89329. setArray4(uniformName: string, array: number[]): Effect;
  89330. /**
  89331. * Sets matrices on a uniform variable.
  89332. * @param uniformName Name of the variable.
  89333. * @param matrices matrices to be set.
  89334. * @returns this effect.
  89335. */
  89336. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  89337. /**
  89338. * Sets matrix on a uniform variable.
  89339. * @param uniformName Name of the variable.
  89340. * @param matrix matrix to be set.
  89341. * @returns this effect.
  89342. */
  89343. setMatrix(uniformName: string, matrix: Matrix): Effect;
  89344. /**
  89345. * 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)
  89346. * @param uniformName Name of the variable.
  89347. * @param matrix matrix to be set.
  89348. * @returns this effect.
  89349. */
  89350. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  89351. /**
  89352. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  89353. * @param uniformName Name of the variable.
  89354. * @param matrix matrix to be set.
  89355. * @returns this effect.
  89356. */
  89357. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  89358. /**
  89359. * Sets a float on a uniform variable.
  89360. * @param uniformName Name of the variable.
  89361. * @param value value to be set.
  89362. * @returns this effect.
  89363. */
  89364. setFloat(uniformName: string, value: number): Effect;
  89365. /**
  89366. * Sets a boolean on a uniform variable.
  89367. * @param uniformName Name of the variable.
  89368. * @param bool value to be set.
  89369. * @returns this effect.
  89370. */
  89371. setBool(uniformName: string, bool: boolean): Effect;
  89372. /**
  89373. * Sets a Vector2 on a uniform variable.
  89374. * @param uniformName Name of the variable.
  89375. * @param vector2 vector2 to be set.
  89376. * @returns this effect.
  89377. */
  89378. setVector2(uniformName: string, vector2: Vector2): Effect;
  89379. /**
  89380. * Sets a float2 on a uniform variable.
  89381. * @param uniformName Name of the variable.
  89382. * @param x First float in float2.
  89383. * @param y Second float in float2.
  89384. * @returns this effect.
  89385. */
  89386. setFloat2(uniformName: string, x: number, y: number): Effect;
  89387. /**
  89388. * Sets a Vector3 on a uniform variable.
  89389. * @param uniformName Name of the variable.
  89390. * @param vector3 Value to be set.
  89391. * @returns this effect.
  89392. */
  89393. setVector3(uniformName: string, vector3: Vector3): Effect;
  89394. /**
  89395. * Sets a float3 on a uniform variable.
  89396. * @param uniformName Name of the variable.
  89397. * @param x First float in float3.
  89398. * @param y Second float in float3.
  89399. * @param z Third float in float3.
  89400. * @returns this effect.
  89401. */
  89402. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  89403. /**
  89404. * Sets a Vector4 on a uniform variable.
  89405. * @param uniformName Name of the variable.
  89406. * @param vector4 Value to be set.
  89407. * @returns this effect.
  89408. */
  89409. setVector4(uniformName: string, vector4: Vector4): Effect;
  89410. /**
  89411. * Sets a float4 on a uniform variable.
  89412. * @param uniformName Name of the variable.
  89413. * @param x First float in float4.
  89414. * @param y Second float in float4.
  89415. * @param z Third float in float4.
  89416. * @param w Fourth float in float4.
  89417. * @returns this effect.
  89418. */
  89419. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89420. /**
  89421. * Sets a Color3 on a uniform variable.
  89422. * @param uniformName Name of the variable.
  89423. * @param color3 Value to be set.
  89424. * @returns this effect.
  89425. */
  89426. setColor3(uniformName: string, color3: Color3): Effect;
  89427. /**
  89428. * Sets a Color4 on a uniform variable.
  89429. * @param uniformName Name of the variable.
  89430. * @param color3 Value to be set.
  89431. * @param alpha Alpha value to be set.
  89432. * @returns this effect.
  89433. */
  89434. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89435. /**
  89436. * Sets a Color4 on a uniform variable
  89437. * @param uniformName defines the name of the variable
  89438. * @param color4 defines the value to be set
  89439. * @returns this effect.
  89440. */
  89441. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89442. /** Release all associated resources */
  89443. dispose(): void;
  89444. /**
  89445. * This function will add a new shader to the shader store
  89446. * @param name the name of the shader
  89447. * @param pixelShader optional pixel shader content
  89448. * @param vertexShader optional vertex shader content
  89449. */
  89450. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89451. /**
  89452. * Store of each shader (The can be looked up using effect.key)
  89453. */
  89454. static ShadersStore: {
  89455. [key: string]: string;
  89456. };
  89457. /**
  89458. * Store of each included file for a shader (The can be looked up using effect.key)
  89459. */
  89460. static IncludesShadersStore: {
  89461. [key: string]: string;
  89462. };
  89463. /**
  89464. * Resets the cache of effects.
  89465. */
  89466. static ResetCache(): void;
  89467. }
  89468. }
  89469. declare module BABYLON {
  89470. /**
  89471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89473. * 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;
  89474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89475. */
  89476. export class ColorCurves {
  89477. private _dirty;
  89478. private _tempColor;
  89479. private _globalCurve;
  89480. private _highlightsCurve;
  89481. private _midtonesCurve;
  89482. private _shadowsCurve;
  89483. private _positiveCurve;
  89484. private _negativeCurve;
  89485. private _globalHue;
  89486. private _globalDensity;
  89487. private _globalSaturation;
  89488. private _globalExposure;
  89489. /**
  89490. * Gets the global Hue value.
  89491. * 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).
  89492. */
  89493. /**
  89494. * Sets the global Hue value.
  89495. * 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).
  89496. */
  89497. globalHue: number;
  89498. /**
  89499. * Gets the global Density value.
  89500. * 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.
  89501. * Values less than zero provide a filter of opposite hue.
  89502. */
  89503. /**
  89504. * Sets the global Density value.
  89505. * 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.
  89506. * Values less than zero provide a filter of opposite hue.
  89507. */
  89508. globalDensity: number;
  89509. /**
  89510. * Gets the global Saturation value.
  89511. * 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.
  89512. */
  89513. /**
  89514. * Sets the global Saturation value.
  89515. * 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.
  89516. */
  89517. globalSaturation: number;
  89518. /**
  89519. * Gets the global Exposure value.
  89520. * 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.
  89521. */
  89522. /**
  89523. * Sets the global Exposure value.
  89524. * 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.
  89525. */
  89526. globalExposure: number;
  89527. private _highlightsHue;
  89528. private _highlightsDensity;
  89529. private _highlightsSaturation;
  89530. private _highlightsExposure;
  89531. /**
  89532. * Gets the highlights Hue value.
  89533. * 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).
  89534. */
  89535. /**
  89536. * Sets the highlights Hue value.
  89537. * 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).
  89538. */
  89539. highlightsHue: number;
  89540. /**
  89541. * Gets the highlights Density value.
  89542. * 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.
  89543. * Values less than zero provide a filter of opposite hue.
  89544. */
  89545. /**
  89546. * Sets the highlights Density value.
  89547. * 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.
  89548. * Values less than zero provide a filter of opposite hue.
  89549. */
  89550. highlightsDensity: number;
  89551. /**
  89552. * Gets the highlights Saturation value.
  89553. * 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.
  89554. */
  89555. /**
  89556. * Sets the highlights Saturation value.
  89557. * 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.
  89558. */
  89559. highlightsSaturation: number;
  89560. /**
  89561. * Gets the highlights Exposure value.
  89562. * 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.
  89563. */
  89564. /**
  89565. * Sets the highlights Exposure value.
  89566. * 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.
  89567. */
  89568. highlightsExposure: number;
  89569. private _midtonesHue;
  89570. private _midtonesDensity;
  89571. private _midtonesSaturation;
  89572. private _midtonesExposure;
  89573. /**
  89574. * Gets the midtones Hue value.
  89575. * 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).
  89576. */
  89577. /**
  89578. * Sets the midtones Hue value.
  89579. * 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).
  89580. */
  89581. midtonesHue: number;
  89582. /**
  89583. * Gets the midtones Density value.
  89584. * 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.
  89585. * Values less than zero provide a filter of opposite hue.
  89586. */
  89587. /**
  89588. * Sets the midtones Density value.
  89589. * 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.
  89590. * Values less than zero provide a filter of opposite hue.
  89591. */
  89592. midtonesDensity: number;
  89593. /**
  89594. * Gets the midtones Saturation value.
  89595. * 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.
  89596. */
  89597. /**
  89598. * Sets the midtones Saturation value.
  89599. * 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.
  89600. */
  89601. midtonesSaturation: number;
  89602. /**
  89603. * Gets the midtones Exposure value.
  89604. * 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.
  89605. */
  89606. /**
  89607. * Sets the midtones Exposure value.
  89608. * 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.
  89609. */
  89610. midtonesExposure: number;
  89611. private _shadowsHue;
  89612. private _shadowsDensity;
  89613. private _shadowsSaturation;
  89614. private _shadowsExposure;
  89615. /**
  89616. * Gets the shadows Hue value.
  89617. * 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).
  89618. */
  89619. /**
  89620. * Sets the shadows Hue value.
  89621. * 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).
  89622. */
  89623. shadowsHue: number;
  89624. /**
  89625. * Gets the shadows Density value.
  89626. * 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.
  89627. * Values less than zero provide a filter of opposite hue.
  89628. */
  89629. /**
  89630. * Sets the shadows Density value.
  89631. * 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.
  89632. * Values less than zero provide a filter of opposite hue.
  89633. */
  89634. shadowsDensity: number;
  89635. /**
  89636. * Gets the shadows Saturation value.
  89637. * 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.
  89638. */
  89639. /**
  89640. * Sets the shadows Saturation value.
  89641. * 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.
  89642. */
  89643. shadowsSaturation: number;
  89644. /**
  89645. * Gets the shadows Exposure value.
  89646. * 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.
  89647. */
  89648. /**
  89649. * Sets the shadows Exposure value.
  89650. * 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.
  89651. */
  89652. shadowsExposure: number;
  89653. /**
  89654. * Returns the class name
  89655. * @returns The class name
  89656. */
  89657. getClassName(): string;
  89658. /**
  89659. * Binds the color curves to the shader.
  89660. * @param colorCurves The color curve to bind
  89661. * @param effect The effect to bind to
  89662. * @param positiveUniform The positive uniform shader parameter
  89663. * @param neutralUniform The neutral uniform shader parameter
  89664. * @param negativeUniform The negative uniform shader parameter
  89665. */
  89666. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89667. /**
  89668. * Prepare the list of uniforms associated with the ColorCurves effects.
  89669. * @param uniformsList The list of uniforms used in the effect
  89670. */
  89671. static PrepareUniforms(uniformsList: string[]): void;
  89672. /**
  89673. * Returns color grading data based on a hue, density, saturation and exposure value.
  89674. * @param filterHue The hue of the color filter.
  89675. * @param filterDensity The density of the color filter.
  89676. * @param saturation The saturation.
  89677. * @param exposure The exposure.
  89678. * @param result The result data container.
  89679. */
  89680. private getColorGradingDataToRef;
  89681. /**
  89682. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89683. * @param value The input slider value in range [-100,100].
  89684. * @returns Adjusted value.
  89685. */
  89686. private static applyColorGradingSliderNonlinear;
  89687. /**
  89688. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89689. * @param hue The hue (H) input.
  89690. * @param saturation The saturation (S) input.
  89691. * @param brightness The brightness (B) input.
  89692. * @result An RGBA color represented as Vector4.
  89693. */
  89694. private static fromHSBToRef;
  89695. /**
  89696. * Returns a value clamped between min and max
  89697. * @param value The value to clamp
  89698. * @param min The minimum of value
  89699. * @param max The maximum of value
  89700. * @returns The clamped value.
  89701. */
  89702. private static clamp;
  89703. /**
  89704. * Clones the current color curve instance.
  89705. * @return The cloned curves
  89706. */
  89707. clone(): ColorCurves;
  89708. /**
  89709. * Serializes the current color curve instance to a json representation.
  89710. * @return a JSON representation
  89711. */
  89712. serialize(): any;
  89713. /**
  89714. * Parses the color curve from a json representation.
  89715. * @param source the JSON source to parse
  89716. * @return The parsed curves
  89717. */
  89718. static Parse(source: any): ColorCurves;
  89719. }
  89720. }
  89721. declare module BABYLON {
  89722. /**
  89723. * Interface to follow in your material defines to integrate easily the
  89724. * Image proccessing functions.
  89725. * @hidden
  89726. */
  89727. export interface IImageProcessingConfigurationDefines {
  89728. IMAGEPROCESSING: boolean;
  89729. VIGNETTE: boolean;
  89730. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89731. VIGNETTEBLENDMODEOPAQUE: boolean;
  89732. TONEMAPPING: boolean;
  89733. TONEMAPPING_ACES: boolean;
  89734. CONTRAST: boolean;
  89735. EXPOSURE: boolean;
  89736. COLORCURVES: boolean;
  89737. COLORGRADING: boolean;
  89738. COLORGRADING3D: boolean;
  89739. SAMPLER3DGREENDEPTH: boolean;
  89740. SAMPLER3DBGRMAP: boolean;
  89741. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89742. }
  89743. /**
  89744. * @hidden
  89745. */
  89746. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89747. IMAGEPROCESSING: boolean;
  89748. VIGNETTE: boolean;
  89749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89750. VIGNETTEBLENDMODEOPAQUE: boolean;
  89751. TONEMAPPING: boolean;
  89752. TONEMAPPING_ACES: boolean;
  89753. CONTRAST: boolean;
  89754. COLORCURVES: boolean;
  89755. COLORGRADING: boolean;
  89756. COLORGRADING3D: boolean;
  89757. SAMPLER3DGREENDEPTH: boolean;
  89758. SAMPLER3DBGRMAP: boolean;
  89759. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89760. EXPOSURE: boolean;
  89761. constructor();
  89762. }
  89763. /**
  89764. * This groups together the common properties used for image processing either in direct forward pass
  89765. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89766. * or not.
  89767. */
  89768. export class ImageProcessingConfiguration {
  89769. /**
  89770. * Default tone mapping applied in BabylonJS.
  89771. */
  89772. static readonly TONEMAPPING_STANDARD: number;
  89773. /**
  89774. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89775. * to other engines rendering to increase portability.
  89776. */
  89777. static readonly TONEMAPPING_ACES: number;
  89778. /**
  89779. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89780. */
  89781. colorCurves: Nullable<ColorCurves>;
  89782. private _colorCurvesEnabled;
  89783. /**
  89784. * Gets wether the color curves effect is enabled.
  89785. */
  89786. /**
  89787. * Sets wether the color curves effect is enabled.
  89788. */
  89789. colorCurvesEnabled: boolean;
  89790. private _colorGradingTexture;
  89791. /**
  89792. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89793. */
  89794. /**
  89795. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89796. */
  89797. colorGradingTexture: Nullable<BaseTexture>;
  89798. private _colorGradingEnabled;
  89799. /**
  89800. * Gets wether the color grading effect is enabled.
  89801. */
  89802. /**
  89803. * Sets wether the color grading effect is enabled.
  89804. */
  89805. colorGradingEnabled: boolean;
  89806. private _colorGradingWithGreenDepth;
  89807. /**
  89808. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89809. */
  89810. /**
  89811. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89812. */
  89813. colorGradingWithGreenDepth: boolean;
  89814. private _colorGradingBGR;
  89815. /**
  89816. * Gets wether the color grading texture contains BGR values.
  89817. */
  89818. /**
  89819. * Sets wether the color grading texture contains BGR values.
  89820. */
  89821. colorGradingBGR: boolean;
  89822. /** @hidden */
  89823. _exposure: number;
  89824. /**
  89825. * Gets the Exposure used in the effect.
  89826. */
  89827. /**
  89828. * Sets the Exposure used in the effect.
  89829. */
  89830. exposure: number;
  89831. private _toneMappingEnabled;
  89832. /**
  89833. * Gets wether the tone mapping effect is enabled.
  89834. */
  89835. /**
  89836. * Sets wether the tone mapping effect is enabled.
  89837. */
  89838. toneMappingEnabled: boolean;
  89839. private _toneMappingType;
  89840. /**
  89841. * Gets the type of tone mapping effect.
  89842. */
  89843. /**
  89844. * Sets the type of tone mapping effect used in BabylonJS.
  89845. */
  89846. toneMappingType: number;
  89847. protected _contrast: number;
  89848. /**
  89849. * Gets the contrast used in the effect.
  89850. */
  89851. /**
  89852. * Sets the contrast used in the effect.
  89853. */
  89854. contrast: number;
  89855. /**
  89856. * Vignette stretch size.
  89857. */
  89858. vignetteStretch: number;
  89859. /**
  89860. * Vignette centre X Offset.
  89861. */
  89862. vignetteCentreX: number;
  89863. /**
  89864. * Vignette centre Y Offset.
  89865. */
  89866. vignetteCentreY: number;
  89867. /**
  89868. * Vignette weight or intensity of the vignette effect.
  89869. */
  89870. vignetteWeight: number;
  89871. /**
  89872. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89873. * if vignetteEnabled is set to true.
  89874. */
  89875. vignetteColor: Color4;
  89876. /**
  89877. * Camera field of view used by the Vignette effect.
  89878. */
  89879. vignetteCameraFov: number;
  89880. private _vignetteBlendMode;
  89881. /**
  89882. * Gets the vignette blend mode allowing different kind of effect.
  89883. */
  89884. /**
  89885. * Sets the vignette blend mode allowing different kind of effect.
  89886. */
  89887. vignetteBlendMode: number;
  89888. private _vignetteEnabled;
  89889. /**
  89890. * Gets wether the vignette effect is enabled.
  89891. */
  89892. /**
  89893. * Sets wether the vignette effect is enabled.
  89894. */
  89895. vignetteEnabled: boolean;
  89896. private _applyByPostProcess;
  89897. /**
  89898. * Gets wether the image processing is applied through a post process or not.
  89899. */
  89900. /**
  89901. * Sets wether the image processing is applied through a post process or not.
  89902. */
  89903. applyByPostProcess: boolean;
  89904. private _isEnabled;
  89905. /**
  89906. * Gets wether the image processing is enabled or not.
  89907. */
  89908. /**
  89909. * Sets wether the image processing is enabled or not.
  89910. */
  89911. isEnabled: boolean;
  89912. /**
  89913. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89914. */
  89915. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89916. /**
  89917. * Method called each time the image processing information changes requires to recompile the effect.
  89918. */
  89919. protected _updateParameters(): void;
  89920. /**
  89921. * Gets the current class name.
  89922. * @return "ImageProcessingConfiguration"
  89923. */
  89924. getClassName(): string;
  89925. /**
  89926. * Prepare the list of uniforms associated with the Image Processing effects.
  89927. * @param uniforms The list of uniforms used in the effect
  89928. * @param defines the list of defines currently in use
  89929. */
  89930. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89931. /**
  89932. * Prepare the list of samplers associated with the Image Processing effects.
  89933. * @param samplersList The list of uniforms used in the effect
  89934. * @param defines the list of defines currently in use
  89935. */
  89936. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89937. /**
  89938. * Prepare the list of defines associated to the shader.
  89939. * @param defines the list of defines to complete
  89940. * @param forPostProcess Define if we are currently in post process mode or not
  89941. */
  89942. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89943. /**
  89944. * Returns true if all the image processing information are ready.
  89945. * @returns True if ready, otherwise, false
  89946. */
  89947. isReady(): boolean;
  89948. /**
  89949. * Binds the image processing to the shader.
  89950. * @param effect The effect to bind to
  89951. * @param aspectRatio Define the current aspect ratio of the effect
  89952. */
  89953. bind(effect: Effect, aspectRatio?: number): void;
  89954. /**
  89955. * Clones the current image processing instance.
  89956. * @return The cloned image processing
  89957. */
  89958. clone(): ImageProcessingConfiguration;
  89959. /**
  89960. * Serializes the current image processing instance to a json representation.
  89961. * @return a JSON representation
  89962. */
  89963. serialize(): any;
  89964. /**
  89965. * Parses the image processing from a json representation.
  89966. * @param source the JSON source to parse
  89967. * @return The parsed image processing
  89968. */
  89969. static Parse(source: any): ImageProcessingConfiguration;
  89970. private static _VIGNETTEMODE_MULTIPLY;
  89971. private static _VIGNETTEMODE_OPAQUE;
  89972. /**
  89973. * Used to apply the vignette as a mix with the pixel color.
  89974. */
  89975. static readonly VIGNETTEMODE_MULTIPLY: number;
  89976. /**
  89977. * Used to apply the vignette as a replacement of the pixel color.
  89978. */
  89979. static readonly VIGNETTEMODE_OPAQUE: number;
  89980. }
  89981. }
  89982. declare module BABYLON {
  89983. /**
  89984. * This represents all the required information to add a fresnel effect on a material:
  89985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89986. */
  89987. export class FresnelParameters {
  89988. private _isEnabled;
  89989. /**
  89990. * Define if the fresnel effect is enable or not.
  89991. */
  89992. isEnabled: boolean;
  89993. /**
  89994. * Define the color used on edges (grazing angle)
  89995. */
  89996. leftColor: Color3;
  89997. /**
  89998. * Define the color used on center
  89999. */
  90000. rightColor: Color3;
  90001. /**
  90002. * Define bias applied to computed fresnel term
  90003. */
  90004. bias: number;
  90005. /**
  90006. * Defined the power exponent applied to fresnel term
  90007. */
  90008. power: number;
  90009. /**
  90010. * Clones the current fresnel and its valuues
  90011. * @returns a clone fresnel configuration
  90012. */
  90013. clone(): FresnelParameters;
  90014. /**
  90015. * Serializes the current fresnel parameters to a JSON representation.
  90016. * @return the JSON serialization
  90017. */
  90018. serialize(): any;
  90019. /**
  90020. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90021. * @param parsedFresnelParameters Define the JSON representation
  90022. * @returns the parsed parameters
  90023. */
  90024. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90025. }
  90026. }
  90027. declare module BABYLON {
  90028. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90029. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90030. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90031. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90032. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90033. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90034. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90035. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90036. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90037. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90038. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90039. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90040. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90041. /**
  90042. * Decorator used to define property that can be serialized as reference to a camera
  90043. * @param sourceName defines the name of the property to decorate
  90044. */
  90045. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90046. /**
  90047. * Class used to help serialization objects
  90048. */
  90049. export class SerializationHelper {
  90050. /** hidden */
  90051. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90052. /** hidden */
  90053. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90054. /** hidden */
  90055. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90056. /** hidden */
  90057. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90058. /**
  90059. * Appends the serialized animations from the source animations
  90060. * @param source Source containing the animations
  90061. * @param destination Target to store the animations
  90062. */
  90063. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90064. /**
  90065. * Static function used to serialized a specific entity
  90066. * @param entity defines the entity to serialize
  90067. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90068. * @returns a JSON compatible object representing the serialization of the entity
  90069. */
  90070. static Serialize<T>(entity: T, serializationObject?: any): any;
  90071. /**
  90072. * Creates a new entity from a serialization data object
  90073. * @param creationFunction defines a function used to instanciated the new entity
  90074. * @param source defines the source serialization data
  90075. * @param scene defines the hosting scene
  90076. * @param rootUrl defines the root url for resources
  90077. * @returns a new entity
  90078. */
  90079. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90080. /**
  90081. * Clones an object
  90082. * @param creationFunction defines the function used to instanciate the new object
  90083. * @param source defines the source object
  90084. * @returns the cloned object
  90085. */
  90086. static Clone<T>(creationFunction: () => T, source: T): T;
  90087. /**
  90088. * Instanciates a new object based on a source one (some data will be shared between both object)
  90089. * @param creationFunction defines the function used to instanciate the new object
  90090. * @param source defines the source object
  90091. * @returns the new object
  90092. */
  90093. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90094. }
  90095. }
  90096. declare module BABYLON {
  90097. /**
  90098. * This is the base class of all the camera used in the application.
  90099. * @see http://doc.babylonjs.com/features/cameras
  90100. */
  90101. export class Camera extends Node {
  90102. /** @hidden */
  90103. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90104. /**
  90105. * This is the default projection mode used by the cameras.
  90106. * It helps recreating a feeling of perspective and better appreciate depth.
  90107. * This is the best way to simulate real life cameras.
  90108. */
  90109. static readonly PERSPECTIVE_CAMERA: number;
  90110. /**
  90111. * This helps creating camera with an orthographic mode.
  90112. * 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.
  90113. */
  90114. static readonly ORTHOGRAPHIC_CAMERA: number;
  90115. /**
  90116. * This is the default FOV mode for perspective cameras.
  90117. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90118. */
  90119. static readonly FOVMODE_VERTICAL_FIXED: number;
  90120. /**
  90121. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90122. */
  90123. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90124. /**
  90125. * This specifies ther is no need for a camera rig.
  90126. * Basically only one eye is rendered corresponding to the camera.
  90127. */
  90128. static readonly RIG_MODE_NONE: number;
  90129. /**
  90130. * Simulates a camera Rig with one blue eye and one red eye.
  90131. * This can be use with 3d blue and red glasses.
  90132. */
  90133. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90134. /**
  90135. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90136. */
  90137. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90138. /**
  90139. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90140. */
  90141. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90142. /**
  90143. * Defines that both eyes of the camera will be rendered over under each other.
  90144. */
  90145. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90146. /**
  90147. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90148. */
  90149. static readonly RIG_MODE_VR: number;
  90150. /**
  90151. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90152. */
  90153. static readonly RIG_MODE_WEBVR: number;
  90154. /**
  90155. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90156. */
  90157. static readonly RIG_MODE_CUSTOM: number;
  90158. /**
  90159. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90160. */
  90161. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90162. /**
  90163. * Define the input manager associated with the camera.
  90164. */
  90165. inputs: CameraInputsManager<Camera>;
  90166. /** @hidden */
  90167. _position: Vector3;
  90168. /**
  90169. * Define the current local position of the camera in the scene
  90170. */
  90171. position: Vector3;
  90172. /**
  90173. * The vector the camera should consider as up.
  90174. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90175. */
  90176. upVector: Vector3;
  90177. /**
  90178. * Define the current limit on the left side for an orthographic camera
  90179. * In scene unit
  90180. */
  90181. orthoLeft: Nullable<number>;
  90182. /**
  90183. * Define the current limit on the right side for an orthographic camera
  90184. * In scene unit
  90185. */
  90186. orthoRight: Nullable<number>;
  90187. /**
  90188. * Define the current limit on the bottom side for an orthographic camera
  90189. * In scene unit
  90190. */
  90191. orthoBottom: Nullable<number>;
  90192. /**
  90193. * Define the current limit on the top side for an orthographic camera
  90194. * In scene unit
  90195. */
  90196. orthoTop: Nullable<number>;
  90197. /**
  90198. * Field Of View is set in Radians. (default is 0.8)
  90199. */
  90200. fov: number;
  90201. /**
  90202. * Define the minimum distance the camera can see from.
  90203. * This is important to note that the depth buffer are not infinite and the closer it starts
  90204. * the more your scene might encounter depth fighting issue.
  90205. */
  90206. minZ: number;
  90207. /**
  90208. * Define the maximum distance the camera can see to.
  90209. * This is important to note that the depth buffer are not infinite and the further it end
  90210. * the more your scene might encounter depth fighting issue.
  90211. */
  90212. maxZ: number;
  90213. /**
  90214. * Define the default inertia of the camera.
  90215. * This helps giving a smooth feeling to the camera movement.
  90216. */
  90217. inertia: number;
  90218. /**
  90219. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  90220. */
  90221. mode: number;
  90222. /**
  90223. * Define wether the camera is intermediate.
  90224. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90225. */
  90226. isIntermediate: boolean;
  90227. /**
  90228. * Define the viewport of the camera.
  90229. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90230. */
  90231. viewport: Viewport;
  90232. /**
  90233. * Restricts the camera to viewing objects with the same layerMask.
  90234. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90235. */
  90236. layerMask: number;
  90237. /**
  90238. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90239. */
  90240. fovMode: number;
  90241. /**
  90242. * Rig mode of the camera.
  90243. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90244. * This is normally controlled byt the camera themselves as internal use.
  90245. */
  90246. cameraRigMode: number;
  90247. /**
  90248. * Defines the distance between both "eyes" in case of a RIG
  90249. */
  90250. interaxialDistance: number;
  90251. /**
  90252. * Defines if stereoscopic rendering is done side by side or over under.
  90253. */
  90254. isStereoscopicSideBySide: boolean;
  90255. /**
  90256. * 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
  90257. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90258. * else in the scene.
  90259. */
  90260. customRenderTargets: RenderTargetTexture[];
  90261. /**
  90262. * When set, the camera will render to this render target instead of the default canvas
  90263. */
  90264. outputRenderTarget: Nullable<RenderTargetTexture>;
  90265. /**
  90266. * Observable triggered when the camera view matrix has changed.
  90267. */
  90268. onViewMatrixChangedObservable: Observable<Camera>;
  90269. /**
  90270. * Observable triggered when the camera Projection matrix has changed.
  90271. */
  90272. onProjectionMatrixChangedObservable: Observable<Camera>;
  90273. /**
  90274. * Observable triggered when the inputs have been processed.
  90275. */
  90276. onAfterCheckInputsObservable: Observable<Camera>;
  90277. /**
  90278. * Observable triggered when reset has been called and applied to the camera.
  90279. */
  90280. onRestoreStateObservable: Observable<Camera>;
  90281. /** @hidden */
  90282. _cameraRigParams: any;
  90283. /** @hidden */
  90284. _rigCameras: Camera[];
  90285. /** @hidden */
  90286. _rigPostProcess: Nullable<PostProcess>;
  90287. protected _webvrViewMatrix: Matrix;
  90288. /** @hidden */
  90289. _skipRendering: boolean;
  90290. /** @hidden */
  90291. _projectionMatrix: Matrix;
  90292. /** @hidden */
  90293. _postProcesses: Nullable<PostProcess>[];
  90294. /** @hidden */
  90295. _activeMeshes: SmartArray<AbstractMesh>;
  90296. protected _globalPosition: Vector3;
  90297. /** hidden */
  90298. _computedViewMatrix: Matrix;
  90299. private _doNotComputeProjectionMatrix;
  90300. private _transformMatrix;
  90301. private _frustumPlanes;
  90302. private _refreshFrustumPlanes;
  90303. private _storedFov;
  90304. private _stateStored;
  90305. /**
  90306. * Instantiates a new camera object.
  90307. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90308. * @see http://doc.babylonjs.com/features/cameras
  90309. * @param name Defines the name of the camera in the scene
  90310. * @param position Defines the position of the camera
  90311. * @param scene Defines the scene the camera belongs too
  90312. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90313. */
  90314. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90315. /**
  90316. * Store current camera state (fov, position, etc..)
  90317. * @returns the camera
  90318. */
  90319. storeState(): Camera;
  90320. /**
  90321. * Restores the camera state values if it has been stored. You must call storeState() first
  90322. */
  90323. protected _restoreStateValues(): boolean;
  90324. /**
  90325. * Restored camera state. You must call storeState() first.
  90326. * @returns true if restored and false otherwise
  90327. */
  90328. restoreState(): boolean;
  90329. /**
  90330. * Gets the class name of the camera.
  90331. * @returns the class name
  90332. */
  90333. getClassName(): string;
  90334. /** @hidden */
  90335. readonly _isCamera: boolean;
  90336. /**
  90337. * Gets a string representation of the camera useful for debug purpose.
  90338. * @param fullDetails Defines that a more verboe level of logging is required
  90339. * @returns the string representation
  90340. */
  90341. toString(fullDetails?: boolean): string;
  90342. /**
  90343. * Gets the current world space position of the camera.
  90344. */
  90345. readonly globalPosition: Vector3;
  90346. /**
  90347. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90348. * @returns the active meshe list
  90349. */
  90350. getActiveMeshes(): SmartArray<AbstractMesh>;
  90351. /**
  90352. * Check wether a mesh is part of the current active mesh list of the camera
  90353. * @param mesh Defines the mesh to check
  90354. * @returns true if active, false otherwise
  90355. */
  90356. isActiveMesh(mesh: Mesh): boolean;
  90357. /**
  90358. * Is this camera ready to be used/rendered
  90359. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90360. * @return true if the camera is ready
  90361. */
  90362. isReady(completeCheck?: boolean): boolean;
  90363. /** @hidden */
  90364. _initCache(): void;
  90365. /** @hidden */
  90366. _updateCache(ignoreParentClass?: boolean): void;
  90367. /** @hidden */
  90368. _isSynchronized(): boolean;
  90369. /** @hidden */
  90370. _isSynchronizedViewMatrix(): boolean;
  90371. /** @hidden */
  90372. _isSynchronizedProjectionMatrix(): boolean;
  90373. /**
  90374. * Attach the input controls to a specific dom element to get the input from.
  90375. * @param element Defines the element the controls should be listened from
  90376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90377. */
  90378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90379. /**
  90380. * Detach the current controls from the specified dom element.
  90381. * @param element Defines the element to stop listening the inputs from
  90382. */
  90383. detachControl(element: HTMLElement): void;
  90384. /**
  90385. * Update the camera state according to the different inputs gathered during the frame.
  90386. */
  90387. update(): void;
  90388. /** @hidden */
  90389. _checkInputs(): void;
  90390. /** @hidden */
  90391. readonly rigCameras: Camera[];
  90392. /**
  90393. * Gets the post process used by the rig cameras
  90394. */
  90395. readonly rigPostProcess: Nullable<PostProcess>;
  90396. /**
  90397. * Internal, gets the first post proces.
  90398. * @returns the first post process to be run on this camera.
  90399. */
  90400. _getFirstPostProcess(): Nullable<PostProcess>;
  90401. private _cascadePostProcessesToRigCams;
  90402. /**
  90403. * Attach a post process to the camera.
  90404. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90405. * @param postProcess The post process to attach to the camera
  90406. * @param insertAt The position of the post process in case several of them are in use in the scene
  90407. * @returns the position the post process has been inserted at
  90408. */
  90409. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90410. /**
  90411. * Detach a post process to the camera.
  90412. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90413. * @param postProcess The post process to detach from the camera
  90414. */
  90415. detachPostProcess(postProcess: PostProcess): void;
  90416. /**
  90417. * Gets the current world matrix of the camera
  90418. */
  90419. getWorldMatrix(): Matrix;
  90420. /** @hidden */
  90421. _getViewMatrix(): Matrix;
  90422. /**
  90423. * Gets the current view matrix of the camera.
  90424. * @param force forces the camera to recompute the matrix without looking at the cached state
  90425. * @returns the view matrix
  90426. */
  90427. getViewMatrix(force?: boolean): Matrix;
  90428. /**
  90429. * Freeze the projection matrix.
  90430. * It will prevent the cache check of the camera projection compute and can speed up perf
  90431. * if no parameter of the camera are meant to change
  90432. * @param projection Defines manually a projection if necessary
  90433. */
  90434. freezeProjectionMatrix(projection?: Matrix): void;
  90435. /**
  90436. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90437. */
  90438. unfreezeProjectionMatrix(): void;
  90439. /**
  90440. * Gets the current projection matrix of the camera.
  90441. * @param force forces the camera to recompute the matrix without looking at the cached state
  90442. * @returns the projection matrix
  90443. */
  90444. getProjectionMatrix(force?: boolean): Matrix;
  90445. /**
  90446. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90447. * @returns a Matrix
  90448. */
  90449. getTransformationMatrix(): Matrix;
  90450. private _updateFrustumPlanes;
  90451. /**
  90452. * Checks if a cullable object (mesh...) is in the camera frustum
  90453. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90454. * @param target The object to check
  90455. * @returns true if the object is in frustum otherwise false
  90456. */
  90457. isInFrustum(target: ICullable): boolean;
  90458. /**
  90459. * Checks if a cullable object (mesh...) is in the camera frustum
  90460. * Unlike isInFrustum this cheks the full bounding box
  90461. * @param target The object to check
  90462. * @returns true if the object is in frustum otherwise false
  90463. */
  90464. isCompletelyInFrustum(target: ICullable): boolean;
  90465. /**
  90466. * Gets a ray in the forward direction from the camera.
  90467. * @param length Defines the length of the ray to create
  90468. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90469. * @param origin Defines the start point of the ray which defaults to the camera position
  90470. * @returns the forward ray
  90471. */
  90472. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90473. /**
  90474. * Releases resources associated with this node.
  90475. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90476. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90477. */
  90478. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90479. /** @hidden */
  90480. _isLeftCamera: boolean;
  90481. /**
  90482. * Gets the left camera of a rig setup in case of Rigged Camera
  90483. */
  90484. readonly isLeftCamera: boolean;
  90485. /** @hidden */
  90486. _isRightCamera: boolean;
  90487. /**
  90488. * Gets the right camera of a rig setup in case of Rigged Camera
  90489. */
  90490. readonly isRightCamera: boolean;
  90491. /**
  90492. * Gets the left camera of a rig setup in case of Rigged Camera
  90493. */
  90494. readonly leftCamera: Nullable<FreeCamera>;
  90495. /**
  90496. * Gets the right camera of a rig setup in case of Rigged Camera
  90497. */
  90498. readonly rightCamera: Nullable<FreeCamera>;
  90499. /**
  90500. * Gets the left camera target of a rig setup in case of Rigged Camera
  90501. * @returns the target position
  90502. */
  90503. getLeftTarget(): Nullable<Vector3>;
  90504. /**
  90505. * Gets the right camera target of a rig setup in case of Rigged Camera
  90506. * @returns the target position
  90507. */
  90508. getRightTarget(): Nullable<Vector3>;
  90509. /**
  90510. * @hidden
  90511. */
  90512. setCameraRigMode(mode: number, rigParams: any): void;
  90513. /** @hidden */
  90514. static _setStereoscopicRigMode(camera: Camera): void;
  90515. /** @hidden */
  90516. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90517. /** @hidden */
  90518. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90519. /** @hidden */
  90520. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90521. /** @hidden */
  90522. _getVRProjectionMatrix(): Matrix;
  90523. protected _updateCameraRotationMatrix(): void;
  90524. protected _updateWebVRCameraRotationMatrix(): void;
  90525. /**
  90526. * This function MUST be overwritten by the different WebVR cameras available.
  90527. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90528. * @hidden
  90529. */
  90530. _getWebVRProjectionMatrix(): Matrix;
  90531. /**
  90532. * This function MUST be overwritten by the different WebVR cameras available.
  90533. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90534. * @hidden
  90535. */
  90536. _getWebVRViewMatrix(): Matrix;
  90537. /** @hidden */
  90538. setCameraRigParameter(name: string, value: any): void;
  90539. /**
  90540. * needs to be overridden by children so sub has required properties to be copied
  90541. * @hidden
  90542. */
  90543. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90544. /**
  90545. * May need to be overridden by children
  90546. * @hidden
  90547. */
  90548. _updateRigCameras(): void;
  90549. /** @hidden */
  90550. _setupInputs(): void;
  90551. /**
  90552. * Serialiaze the camera setup to a json represention
  90553. * @returns the JSON representation
  90554. */
  90555. serialize(): any;
  90556. /**
  90557. * Clones the current camera.
  90558. * @param name The cloned camera name
  90559. * @returns the cloned camera
  90560. */
  90561. clone(name: string): Camera;
  90562. /**
  90563. * Gets the direction of the camera relative to a given local axis.
  90564. * @param localAxis Defines the reference axis to provide a relative direction.
  90565. * @return the direction
  90566. */
  90567. getDirection(localAxis: Vector3): Vector3;
  90568. /**
  90569. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90570. * @param localAxis Defines the reference axis to provide a relative direction.
  90571. * @param result Defines the vector to store the result in
  90572. */
  90573. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90574. /**
  90575. * Gets a camera constructor for a given camera type
  90576. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90577. * @param name The name of the camera the result will be able to instantiate
  90578. * @param scene The scene the result will construct the camera in
  90579. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90580. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90581. * @returns a factory method to construc the camera
  90582. */
  90583. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90584. /**
  90585. * Compute the world matrix of the camera.
  90586. * @returns the camera workd matrix
  90587. */
  90588. computeWorldMatrix(): Matrix;
  90589. /**
  90590. * Parse a JSON and creates the camera from the parsed information
  90591. * @param parsedCamera The JSON to parse
  90592. * @param scene The scene to instantiate the camera in
  90593. * @returns the newly constructed camera
  90594. */
  90595. static Parse(parsedCamera: any, scene: Scene): Camera;
  90596. }
  90597. }
  90598. declare module BABYLON {
  90599. /**
  90600. * Interface for any object that can request an animation frame
  90601. */
  90602. export interface ICustomAnimationFrameRequester {
  90603. /**
  90604. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90605. */
  90606. renderFunction?: Function;
  90607. /**
  90608. * Called to request the next frame to render to
  90609. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90610. */
  90611. requestAnimationFrame: Function;
  90612. /**
  90613. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90614. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90615. */
  90616. requestID?: number;
  90617. }
  90618. /**
  90619. * Interface containing an array of animations
  90620. */
  90621. export interface IAnimatable {
  90622. /**
  90623. * Array of animations
  90624. */
  90625. animations: Nullable<Array<Animation>>;
  90626. }
  90627. /** Interface used by value gradients (color, factor, ...) */
  90628. export interface IValueGradient {
  90629. /**
  90630. * Gets or sets the gradient value (between 0 and 1)
  90631. */
  90632. gradient: number;
  90633. }
  90634. /** Class used to store color4 gradient */
  90635. export class ColorGradient implements IValueGradient {
  90636. /**
  90637. * Gets or sets the gradient value (between 0 and 1)
  90638. */
  90639. gradient: number;
  90640. /**
  90641. * Gets or sets first associated color
  90642. */
  90643. color1: Color4;
  90644. /**
  90645. * Gets or sets second associated color
  90646. */
  90647. color2?: Color4;
  90648. /**
  90649. * Will get a color picked randomly between color1 and color2.
  90650. * If color2 is undefined then color1 will be used
  90651. * @param result defines the target Color4 to store the result in
  90652. */
  90653. getColorToRef(result: Color4): void;
  90654. }
  90655. /** Class used to store color 3 gradient */
  90656. export class Color3Gradient implements IValueGradient {
  90657. /**
  90658. * Gets or sets the gradient value (between 0 and 1)
  90659. */
  90660. gradient: number;
  90661. /**
  90662. * Gets or sets the associated color
  90663. */
  90664. color: Color3;
  90665. }
  90666. /** Class used to store factor gradient */
  90667. export class FactorGradient implements IValueGradient {
  90668. /**
  90669. * Gets or sets the gradient value (between 0 and 1)
  90670. */
  90671. gradient: number;
  90672. /**
  90673. * Gets or sets first associated factor
  90674. */
  90675. factor1: number;
  90676. /**
  90677. * Gets or sets second associated factor
  90678. */
  90679. factor2?: number;
  90680. /**
  90681. * Will get a number picked randomly between factor1 and factor2.
  90682. * If factor2 is undefined then factor1 will be used
  90683. * @returns the picked number
  90684. */
  90685. getFactor(): number;
  90686. }
  90687. /**
  90688. * @ignore
  90689. * Application error to support additional information when loading a file
  90690. */
  90691. export class LoadFileError extends Error {
  90692. /** defines the optional web request */
  90693. request?: WebRequest | undefined;
  90694. private static _setPrototypeOf;
  90695. /**
  90696. * Creates a new LoadFileError
  90697. * @param message defines the message of the error
  90698. * @param request defines the optional web request
  90699. */
  90700. constructor(message: string,
  90701. /** defines the optional web request */
  90702. request?: WebRequest | undefined);
  90703. }
  90704. /**
  90705. * Class used to define a retry strategy when error happens while loading assets
  90706. */
  90707. export class RetryStrategy {
  90708. /**
  90709. * Function used to defines an exponential back off strategy
  90710. * @param maxRetries defines the maximum number of retries (3 by default)
  90711. * @param baseInterval defines the interval between retries
  90712. * @returns the strategy function to use
  90713. */
  90714. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90715. }
  90716. /**
  90717. * File request interface
  90718. */
  90719. export interface IFileRequest {
  90720. /**
  90721. * Raised when the request is complete (success or error).
  90722. */
  90723. onCompleteObservable: Observable<IFileRequest>;
  90724. /**
  90725. * Aborts the request for a file.
  90726. */
  90727. abort: () => void;
  90728. }
  90729. /**
  90730. * Class containing a set of static utilities functions
  90731. */
  90732. export class Tools {
  90733. /**
  90734. * Gets or sets the base URL to use to load assets
  90735. */
  90736. static BaseUrl: string;
  90737. /**
  90738. * Enable/Disable Custom HTTP Request Headers globally.
  90739. * default = false
  90740. * @see CustomRequestHeaders
  90741. */
  90742. static UseCustomRequestHeaders: boolean;
  90743. /**
  90744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90745. * i.e. when loading files, where the server/service expects an Authorization header
  90746. */
  90747. static CustomRequestHeaders: {
  90748. [key: string]: string;
  90749. };
  90750. /**
  90751. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90752. */
  90753. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90754. /**
  90755. * Default behaviour for cors in the application.
  90756. * It can be a string if the expected behavior is identical in the entire app.
  90757. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90758. */
  90759. static CorsBehavior: string | ((url: string | string[]) => string);
  90760. /**
  90761. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90762. * @ignorenaming
  90763. */
  90764. static UseFallbackTexture: boolean;
  90765. /**
  90766. * Use this object to register external classes like custom textures or material
  90767. * to allow the laoders to instantiate them
  90768. */
  90769. static RegisteredExternalClasses: {
  90770. [key: string]: Object;
  90771. };
  90772. /**
  90773. * Texture content used if a texture cannot loaded
  90774. * @ignorenaming
  90775. */
  90776. static fallbackTexture: string;
  90777. /**
  90778. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90779. * @param u defines the coordinate on X axis
  90780. * @param v defines the coordinate on Y axis
  90781. * @param width defines the width of the source data
  90782. * @param height defines the height of the source data
  90783. * @param pixels defines the source byte array
  90784. * @param color defines the output color
  90785. */
  90786. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90787. /**
  90788. * Interpolates between a and b via alpha
  90789. * @param a The lower value (returned when alpha = 0)
  90790. * @param b The upper value (returned when alpha = 1)
  90791. * @param alpha The interpolation-factor
  90792. * @return The mixed value
  90793. */
  90794. static Mix(a: number, b: number, alpha: number): number;
  90795. /**
  90796. * Tries to instantiate a new object from a given class name
  90797. * @param className defines the class name to instantiate
  90798. * @returns the new object or null if the system was not able to do the instantiation
  90799. */
  90800. static Instantiate(className: string): any;
  90801. /**
  90802. * Provides a slice function that will work even on IE
  90803. * @param data defines the array to slice
  90804. * @param start defines the start of the data (optional)
  90805. * @param end defines the end of the data (optional)
  90806. * @returns the new sliced array
  90807. */
  90808. static Slice<T>(data: T, start?: number, end?: number): T;
  90809. /**
  90810. * Polyfill for setImmediate
  90811. * @param action defines the action to execute after the current execution block
  90812. */
  90813. static SetImmediate(action: () => void): void;
  90814. /**
  90815. * Function indicating if a number is an exponent of 2
  90816. * @param value defines the value to test
  90817. * @returns true if the value is an exponent of 2
  90818. */
  90819. static IsExponentOfTwo(value: number): boolean;
  90820. private static _tmpFloatArray;
  90821. /**
  90822. * Returns the nearest 32-bit single precision float representation of a Number
  90823. * @param value A Number. If the parameter is of a different type, it will get converted
  90824. * to a number or to NaN if it cannot be converted
  90825. * @returns number
  90826. */
  90827. static FloatRound(value: number): number;
  90828. /**
  90829. * Find the next highest power of two.
  90830. * @param x Number to start search from.
  90831. * @return Next highest power of two.
  90832. */
  90833. static CeilingPOT(x: number): number;
  90834. /**
  90835. * Find the next lowest power of two.
  90836. * @param x Number to start search from.
  90837. * @return Next lowest power of two.
  90838. */
  90839. static FloorPOT(x: number): number;
  90840. /**
  90841. * Find the nearest power of two.
  90842. * @param x Number to start search from.
  90843. * @return Next nearest power of two.
  90844. */
  90845. static NearestPOT(x: number): number;
  90846. /**
  90847. * Get the closest exponent of two
  90848. * @param value defines the value to approximate
  90849. * @param max defines the maximum value to return
  90850. * @param mode defines how to define the closest value
  90851. * @returns closest exponent of two of the given value
  90852. */
  90853. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90854. /**
  90855. * Extracts the filename from a path
  90856. * @param path defines the path to use
  90857. * @returns the filename
  90858. */
  90859. static GetFilename(path: string): string;
  90860. /**
  90861. * Extracts the "folder" part of a path (everything before the filename).
  90862. * @param uri The URI to extract the info from
  90863. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90864. * @returns The "folder" part of the path
  90865. */
  90866. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90867. /**
  90868. * Extracts text content from a DOM element hierarchy
  90869. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90870. */
  90871. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90872. /**
  90873. * Convert an angle in radians to degrees
  90874. * @param angle defines the angle to convert
  90875. * @returns the angle in degrees
  90876. */
  90877. static ToDegrees(angle: number): number;
  90878. /**
  90879. * Convert an angle in degrees to radians
  90880. * @param angle defines the angle to convert
  90881. * @returns the angle in radians
  90882. */
  90883. static ToRadians(angle: number): number;
  90884. /**
  90885. * Encode a buffer to a base64 string
  90886. * @param buffer defines the buffer to encode
  90887. * @returns the encoded string
  90888. */
  90889. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90890. /**
  90891. * Extracts minimum and maximum values from a list of indexed positions
  90892. * @param positions defines the positions to use
  90893. * @param indices defines the indices to the positions
  90894. * @param indexStart defines the start index
  90895. * @param indexCount defines the end index
  90896. * @param bias defines bias value to add to the result
  90897. * @return minimum and maximum values
  90898. */
  90899. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90900. minimum: Vector3;
  90901. maximum: Vector3;
  90902. };
  90903. /**
  90904. * Extracts minimum and maximum values from a list of positions
  90905. * @param positions defines the positions to use
  90906. * @param start defines the start index in the positions array
  90907. * @param count defines the number of positions to handle
  90908. * @param bias defines bias value to add to the result
  90909. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90910. * @return minimum and maximum values
  90911. */
  90912. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90913. minimum: Vector3;
  90914. maximum: Vector3;
  90915. };
  90916. /**
  90917. * Returns an array if obj is not an array
  90918. * @param obj defines the object to evaluate as an array
  90919. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90920. * @returns either obj directly if obj is an array or a new array containing obj
  90921. */
  90922. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90923. /**
  90924. * Gets the pointer prefix to use
  90925. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90926. */
  90927. static GetPointerPrefix(): string;
  90928. /**
  90929. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90930. * @param func - the function to be called
  90931. * @param requester - the object that will request the next frame. Falls back to window.
  90932. * @returns frame number
  90933. */
  90934. static QueueNewFrame(func: () => void, requester?: any): number;
  90935. /**
  90936. * Ask the browser to promote the current element to fullscreen rendering mode
  90937. * @param element defines the DOM element to promote
  90938. */
  90939. static RequestFullscreen(element: HTMLElement): void;
  90940. /**
  90941. * Asks the browser to exit fullscreen mode
  90942. */
  90943. static ExitFullscreen(): void;
  90944. /**
  90945. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90946. * @param url define the url we are trying
  90947. * @param element define the dom element where to configure the cors policy
  90948. */
  90949. static SetCorsBehavior(url: string | string[], element: {
  90950. crossOrigin: string | null;
  90951. }): void;
  90952. /**
  90953. * Removes unwanted characters from an url
  90954. * @param url defines the url to clean
  90955. * @returns the cleaned url
  90956. */
  90957. static CleanUrl(url: string): string;
  90958. /**
  90959. * Gets or sets a function used to pre-process url before using them to load assets
  90960. */
  90961. static PreprocessUrl: (url: string) => string;
  90962. /**
  90963. * Loads an image as an HTMLImageElement.
  90964. * @param input url string, ArrayBuffer, or Blob to load
  90965. * @param onLoad callback called when the image successfully loads
  90966. * @param onError callback called when the image fails to load
  90967. * @param offlineProvider offline provider for caching
  90968. * @returns the HTMLImageElement of the loaded image
  90969. */
  90970. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90971. /**
  90972. * Loads a file
  90973. * @param url url string, ArrayBuffer, or Blob to load
  90974. * @param onSuccess callback called when the file successfully loads
  90975. * @param onProgress callback called while file is loading (if the server supports this mode)
  90976. * @param offlineProvider defines the offline provider for caching
  90977. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90978. * @param onError callback called when the file fails to load
  90979. * @returns a file request object
  90980. */
  90981. 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;
  90982. /**
  90983. * Load a script (identified by an url). When the url returns, the
  90984. * content of this file is added into a new script element, attached to the DOM (body element)
  90985. * @param scriptUrl defines the url of the script to laod
  90986. * @param onSuccess defines the callback called when the script is loaded
  90987. * @param onError defines the callback to call if an error occurs
  90988. * @param scriptId defines the id of the script element
  90989. */
  90990. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90991. /**
  90992. * Load an asynchronous script (identified by an url). When the url returns, the
  90993. * content of this file is added into a new script element, attached to the DOM (body element)
  90994. * @param scriptUrl defines the url of the script to laod
  90995. * @param scriptId defines the id of the script element
  90996. * @returns a promise request object
  90997. */
  90998. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90999. /**
  91000. * Loads a file from a blob
  91001. * @param fileToLoad defines the blob to use
  91002. * @param callback defines the callback to call when data is loaded
  91003. * @param progressCallback defines the callback to call during loading process
  91004. * @returns a file request object
  91005. */
  91006. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  91007. /**
  91008. * Loads a file
  91009. * @param fileToLoad defines the file to load
  91010. * @param callback defines the callback to call when data is loaded
  91011. * @param progressCallBack defines the callback to call during loading process
  91012. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  91013. * @returns a file request object
  91014. */
  91015. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  91016. /**
  91017. * Creates a data url from a given string content
  91018. * @param content defines the content to convert
  91019. * @returns the new data url link
  91020. */
  91021. static FileAsURL(content: string): string;
  91022. /**
  91023. * Format the given number to a specific decimal format
  91024. * @param value defines the number to format
  91025. * @param decimals defines the number of decimals to use
  91026. * @returns the formatted string
  91027. */
  91028. static Format(value: number, decimals?: number): string;
  91029. /**
  91030. * Checks if a given vector is inside a specific range
  91031. * @param v defines the vector to test
  91032. * @param min defines the minimum range
  91033. * @param max defines the maximum range
  91034. */
  91035. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  91036. /**
  91037. * Tries to copy an object by duplicating every property
  91038. * @param source defines the source object
  91039. * @param destination defines the target object
  91040. * @param doNotCopyList defines a list of properties to avoid
  91041. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  91042. */
  91043. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  91044. /**
  91045. * Gets a boolean indicating if the given object has no own property
  91046. * @param obj defines the object to test
  91047. * @returns true if object has no own property
  91048. */
  91049. static IsEmpty(obj: any): boolean;
  91050. /**
  91051. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  91052. * @param str Source string
  91053. * @param suffix Suffix to search for in the source string
  91054. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  91055. */
  91056. static EndsWith(str: string, suffix: string): boolean;
  91057. /**
  91058. * Function used to register events at window level
  91059. * @param events defines the events to register
  91060. */
  91061. static RegisterTopRootEvents(events: {
  91062. name: string;
  91063. handler: Nullable<(e: FocusEvent) => any>;
  91064. }[]): void;
  91065. /**
  91066. * Function used to unregister events from window level
  91067. * @param events defines the events to unregister
  91068. */
  91069. static UnregisterTopRootEvents(events: {
  91070. name: string;
  91071. handler: Nullable<(e: FocusEvent) => any>;
  91072. }[]): void;
  91073. /**
  91074. * @ignore
  91075. */
  91076. static _ScreenshotCanvas: HTMLCanvasElement;
  91077. /**
  91078. * Dumps the current bound framebuffer
  91079. * @param width defines the rendering width
  91080. * @param height defines the rendering height
  91081. * @param engine defines the hosting engine
  91082. * @param successCallback defines the callback triggered once the data are available
  91083. * @param mimeType defines the mime type of the result
  91084. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  91085. */
  91086. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91087. /**
  91088. * Converts the canvas data to blob.
  91089. * This acts as a polyfill for browsers not supporting the to blob function.
  91090. * @param canvas Defines the canvas to extract the data from
  91091. * @param successCallback Defines the callback triggered once the data are available
  91092. * @param mimeType Defines the mime type of the result
  91093. */
  91094. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  91095. /**
  91096. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  91097. * @param successCallback defines the callback triggered once the data are available
  91098. * @param mimeType defines the mime type of the result
  91099. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  91100. */
  91101. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  91102. /**
  91103. * Downloads a blob in the browser
  91104. * @param blob defines the blob to download
  91105. * @param fileName defines the name of the downloaded file
  91106. */
  91107. static Download(blob: Blob, fileName: string): void;
  91108. /**
  91109. * Captures a screenshot of the current rendering
  91110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91111. * @param engine defines the rendering engine
  91112. * @param camera defines the source camera
  91113. * @param size This parameter can be set to a single number or to an object with the
  91114. * following (optional) properties: precision, width, height. If a single number is passed,
  91115. * it will be used for both width and height. If an object is passed, the screenshot size
  91116. * will be derived from the parameters. The precision property is a multiplier allowing
  91117. * rendering at a higher or lower resolution
  91118. * @param successCallback defines the callback receives a single parameter which contains the
  91119. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91120. * src parameter of an <img> to display it
  91121. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  91122. * Check your browser for supported MIME types
  91123. */
  91124. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  91125. /**
  91126. * Generates an image screenshot from the specified camera.
  91127. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  91128. * @param engine The engine to use for rendering
  91129. * @param camera The camera to use for rendering
  91130. * @param size This parameter can be set to a single number or to an object with the
  91131. * following (optional) properties: precision, width, height. If a single number is passed,
  91132. * it will be used for both width and height. If an object is passed, the screenshot size
  91133. * will be derived from the parameters. The precision property is a multiplier allowing
  91134. * rendering at a higher or lower resolution
  91135. * @param successCallback The callback receives a single parameter which contains the
  91136. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  91137. * src parameter of an <img> to display it
  91138. * @param mimeType The MIME type of the screenshot image (default: image/png).
  91139. * Check your browser for supported MIME types
  91140. * @param samples Texture samples (default: 1)
  91141. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  91142. * @param fileName A name for for the downloaded file.
  91143. */
  91144. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  91145. /**
  91146. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91147. * Be aware Math.random() could cause collisions, but:
  91148. * "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"
  91149. * @returns a pseudo random id
  91150. */
  91151. static RandomId(): string;
  91152. /**
  91153. * Test if the given uri is a base64 string
  91154. * @param uri The uri to test
  91155. * @return True if the uri is a base64 string or false otherwise
  91156. */
  91157. static IsBase64(uri: string): boolean;
  91158. /**
  91159. * Decode the given base64 uri.
  91160. * @param uri The uri to decode
  91161. * @return The decoded base64 data.
  91162. */
  91163. static DecodeBase64(uri: string): ArrayBuffer;
  91164. /**
  91165. * Gets the absolute url.
  91166. * @param url the input url
  91167. * @return the absolute url
  91168. */
  91169. static GetAbsoluteUrl(url: string): string;
  91170. /**
  91171. * No log
  91172. */
  91173. static readonly NoneLogLevel: number;
  91174. /**
  91175. * Only message logs
  91176. */
  91177. static readonly MessageLogLevel: number;
  91178. /**
  91179. * Only warning logs
  91180. */
  91181. static readonly WarningLogLevel: number;
  91182. /**
  91183. * Only error logs
  91184. */
  91185. static readonly ErrorLogLevel: number;
  91186. /**
  91187. * All logs
  91188. */
  91189. static readonly AllLogLevel: number;
  91190. /**
  91191. * Gets a value indicating the number of loading errors
  91192. * @ignorenaming
  91193. */
  91194. static readonly errorsCount: number;
  91195. /**
  91196. * Callback called when a new log is added
  91197. */
  91198. static OnNewCacheEntry: (entry: string) => void;
  91199. /**
  91200. * Log a message to the console
  91201. * @param message defines the message to log
  91202. */
  91203. static Log(message: string): void;
  91204. /**
  91205. * Write a warning message to the console
  91206. * @param message defines the message to log
  91207. */
  91208. static Warn(message: string): void;
  91209. /**
  91210. * Write an error message to the console
  91211. * @param message defines the message to log
  91212. */
  91213. static Error(message: string): void;
  91214. /**
  91215. * Gets current log cache (list of logs)
  91216. */
  91217. static readonly LogCache: string;
  91218. /**
  91219. * Clears the log cache
  91220. */
  91221. static ClearLogCache(): void;
  91222. /**
  91223. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  91224. */
  91225. static LogLevels: number;
  91226. /**
  91227. * Checks if the loaded document was accessed via `file:`-Protocol.
  91228. * @returns boolean
  91229. */
  91230. static IsFileURL(): boolean;
  91231. /**
  91232. * Checks if the window object exists
  91233. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  91234. */
  91235. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  91236. /**
  91237. * No performance log
  91238. */
  91239. static readonly PerformanceNoneLogLevel: number;
  91240. /**
  91241. * Use user marks to log performance
  91242. */
  91243. static readonly PerformanceUserMarkLogLevel: number;
  91244. /**
  91245. * Log performance to the console
  91246. */
  91247. static readonly PerformanceConsoleLogLevel: number;
  91248. private static _performance;
  91249. /**
  91250. * Sets the current performance log level
  91251. */
  91252. static PerformanceLogLevel: number;
  91253. private static _StartPerformanceCounterDisabled;
  91254. private static _EndPerformanceCounterDisabled;
  91255. private static _StartUserMark;
  91256. private static _EndUserMark;
  91257. private static _StartPerformanceConsole;
  91258. private static _EndPerformanceConsole;
  91259. /**
  91260. * Starts a performance counter
  91261. */
  91262. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91263. /**
  91264. * Ends a specific performance coutner
  91265. */
  91266. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  91267. /**
  91268. * Gets either window.performance.now() if supported or Date.now() else
  91269. */
  91270. static readonly Now: number;
  91271. /**
  91272. * This method will return the name of the class used to create the instance of the given object.
  91273. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  91274. * @param object the object to get the class name from
  91275. * @param isType defines if the object is actually a type
  91276. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  91277. */
  91278. static GetClassName(object: any, isType?: boolean): string;
  91279. /**
  91280. * Gets the first element of an array satisfying a given predicate
  91281. * @param array defines the array to browse
  91282. * @param predicate defines the predicate to use
  91283. * @returns null if not found or the element
  91284. */
  91285. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  91286. /**
  91287. * This method will return the name of the full name of the class, including its owning module (if any).
  91288. * 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).
  91289. * @param object the object to get the class name from
  91290. * @param isType defines if the object is actually a type
  91291. * @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.
  91292. * @ignorenaming
  91293. */
  91294. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  91295. /**
  91296. * Returns a promise that resolves after the given amount of time.
  91297. * @param delay Number of milliseconds to delay
  91298. * @returns Promise that resolves after the given amount of time
  91299. */
  91300. static DelayAsync(delay: number): Promise<void>;
  91301. /**
  91302. * Gets the current gradient from an array of IValueGradient
  91303. * @param ratio defines the current ratio to get
  91304. * @param gradients defines the array of IValueGradient
  91305. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91306. */
  91307. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91308. }
  91309. /**
  91310. * This class is used to track a performance counter which is number based.
  91311. * The user has access to many properties which give statistics of different nature.
  91312. *
  91313. * The implementer can track two kinds of Performance Counter: time and count.
  91314. * 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.
  91315. * 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.
  91316. */
  91317. export class PerfCounter {
  91318. /**
  91319. * Gets or sets a global boolean to turn on and off all the counters
  91320. */
  91321. static Enabled: boolean;
  91322. /**
  91323. * Returns the smallest value ever
  91324. */
  91325. readonly min: number;
  91326. /**
  91327. * Returns the biggest value ever
  91328. */
  91329. readonly max: number;
  91330. /**
  91331. * Returns the average value since the performance counter is running
  91332. */
  91333. readonly average: number;
  91334. /**
  91335. * Returns the average value of the last second the counter was monitored
  91336. */
  91337. readonly lastSecAverage: number;
  91338. /**
  91339. * Returns the current value
  91340. */
  91341. readonly current: number;
  91342. /**
  91343. * Gets the accumulated total
  91344. */
  91345. readonly total: number;
  91346. /**
  91347. * Gets the total value count
  91348. */
  91349. readonly count: number;
  91350. /**
  91351. * Creates a new counter
  91352. */
  91353. constructor();
  91354. /**
  91355. * Call this method to start monitoring a new frame.
  91356. * 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.
  91357. */
  91358. fetchNewFrame(): void;
  91359. /**
  91360. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  91361. * @param newCount the count value to add to the monitored count
  91362. * @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.
  91363. */
  91364. addCount(newCount: number, fetchResult: boolean): void;
  91365. /**
  91366. * Start monitoring this performance counter
  91367. */
  91368. beginMonitoring(): void;
  91369. /**
  91370. * Compute the time lapsed since the previous beginMonitoring() call.
  91371. * @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
  91372. */
  91373. endMonitoring(newFrame?: boolean): void;
  91374. private _fetchResult;
  91375. private _startMonitoringTime;
  91376. private _min;
  91377. private _max;
  91378. private _average;
  91379. private _current;
  91380. private _totalValueCount;
  91381. private _totalAccumulated;
  91382. private _lastSecAverage;
  91383. private _lastSecAccumulated;
  91384. private _lastSecTime;
  91385. private _lastSecValueCount;
  91386. }
  91387. /**
  91388. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  91389. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  91390. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  91391. * @param name The name of the class, case should be preserved
  91392. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  91393. */
  91394. export function className(name: string, module?: string): (target: Object) => void;
  91395. /**
  91396. * An implementation of a loop for asynchronous functions.
  91397. */
  91398. export class AsyncLoop {
  91399. /**
  91400. * Defines the number of iterations for the loop
  91401. */
  91402. iterations: number;
  91403. /**
  91404. * Defines the current index of the loop.
  91405. */
  91406. index: number;
  91407. private _done;
  91408. private _fn;
  91409. private _successCallback;
  91410. /**
  91411. * Constructor.
  91412. * @param iterations the number of iterations.
  91413. * @param func the function to run each iteration
  91414. * @param successCallback the callback that will be called upon succesful execution
  91415. * @param offset starting offset.
  91416. */
  91417. constructor(
  91418. /**
  91419. * Defines the number of iterations for the loop
  91420. */
  91421. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91422. /**
  91423. * Execute the next iteration. Must be called after the last iteration was finished.
  91424. */
  91425. executeNext(): void;
  91426. /**
  91427. * Break the loop and run the success callback.
  91428. */
  91429. breakLoop(): void;
  91430. /**
  91431. * Create and run an async loop.
  91432. * @param iterations the number of iterations.
  91433. * @param fn the function to run each iteration
  91434. * @param successCallback the callback that will be called upon succesful execution
  91435. * @param offset starting offset.
  91436. * @returns the created async loop object
  91437. */
  91438. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91439. /**
  91440. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91441. * @param iterations total number of iterations
  91442. * @param syncedIterations number of synchronous iterations in each async iteration.
  91443. * @param fn the function to call each iteration.
  91444. * @param callback a success call back that will be called when iterating stops.
  91445. * @param breakFunction a break condition (optional)
  91446. * @param timeout timeout settings for the setTimeout function. default - 0.
  91447. * @returns the created async loop object
  91448. */
  91449. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91450. }
  91451. }
  91452. declare module BABYLON {
  91453. /** @hidden */
  91454. export interface ICollisionCoordinator {
  91455. createCollider(): Collider;
  91456. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91457. init(scene: Scene): void;
  91458. }
  91459. /** @hidden */
  91460. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91461. private _scene;
  91462. private _scaledPosition;
  91463. private _scaledVelocity;
  91464. private _finalPosition;
  91465. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91466. createCollider(): Collider;
  91467. init(scene: Scene): void;
  91468. private _collideWithWorld;
  91469. }
  91470. }
  91471. declare module BABYLON {
  91472. /**
  91473. * Class used to manage all inputs for the scene.
  91474. */
  91475. export class InputManager {
  91476. /** The distance in pixel that you have to move to prevent some events */
  91477. static DragMovementThreshold: number;
  91478. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91479. static LongPressDelay: number;
  91480. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91481. static DoubleClickDelay: number;
  91482. /** If you need to check double click without raising a single click at first click, enable this flag */
  91483. static ExclusiveDoubleClickMode: boolean;
  91484. private _wheelEventName;
  91485. private _onPointerMove;
  91486. private _onPointerDown;
  91487. private _onPointerUp;
  91488. private _initClickEvent;
  91489. private _initActionManager;
  91490. private _delayedSimpleClick;
  91491. private _delayedSimpleClickTimeout;
  91492. private _previousDelayedSimpleClickTimeout;
  91493. private _meshPickProceed;
  91494. private _previousButtonPressed;
  91495. private _currentPickResult;
  91496. private _previousPickResult;
  91497. private _totalPointersPressed;
  91498. private _doubleClickOccured;
  91499. private _pointerOverMesh;
  91500. private _pickedDownMesh;
  91501. private _pickedUpMesh;
  91502. private _pointerX;
  91503. private _pointerY;
  91504. private _unTranslatedPointerX;
  91505. private _unTranslatedPointerY;
  91506. private _startingPointerPosition;
  91507. private _previousStartingPointerPosition;
  91508. private _startingPointerTime;
  91509. private _previousStartingPointerTime;
  91510. private _pointerCaptures;
  91511. private _onKeyDown;
  91512. private _onKeyUp;
  91513. private _onCanvasFocusObserver;
  91514. private _onCanvasBlurObserver;
  91515. private _scene;
  91516. /**
  91517. * Creates a new InputManager
  91518. * @param scene defines the hosting scene
  91519. */
  91520. constructor(scene: Scene);
  91521. /**
  91522. * Gets the mesh that is currently under the pointer
  91523. */
  91524. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91525. /**
  91526. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  91527. */
  91528. readonly unTranslatedPointer: Vector2;
  91529. /**
  91530. * Gets or sets the current on-screen X position of the pointer
  91531. */
  91532. pointerX: number;
  91533. /**
  91534. * Gets or sets the current on-screen Y position of the pointer
  91535. */
  91536. pointerY: number;
  91537. private _updatePointerPosition;
  91538. private _processPointerMove;
  91539. private _setRayOnPointerInfo;
  91540. private _checkPrePointerObservable;
  91541. /**
  91542. * Use this method to simulate a pointer move on a mesh
  91543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91546. */
  91547. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91548. /**
  91549. * Use this method to simulate a pointer down on a mesh
  91550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91553. */
  91554. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  91555. private _processPointerDown;
  91556. /** @hidden */
  91557. _isPointerSwiping(): boolean;
  91558. /**
  91559. * Use this method to simulate a pointer up on a mesh
  91560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91563. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91564. */
  91565. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  91566. private _processPointerUp;
  91567. /**
  91568. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91569. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91570. * @returns true if the pointer was captured
  91571. */
  91572. isPointerCaptured(pointerId?: number): boolean;
  91573. /**
  91574. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91575. * @param attachUp defines if you want to attach events to pointerup
  91576. * @param attachDown defines if you want to attach events to pointerdown
  91577. * @param attachMove defines if you want to attach events to pointermove
  91578. */
  91579. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91580. /**
  91581. * Detaches all event handlers
  91582. */
  91583. detachControl(): void;
  91584. /**
  91585. * Force the value of meshUnderPointer
  91586. * @param mesh defines the mesh to use
  91587. */
  91588. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91589. /**
  91590. * Gets the mesh under the pointer
  91591. * @returns a Mesh or null if no mesh is under the pointer
  91592. */
  91593. getPointerOverMesh(): Nullable<AbstractMesh>;
  91594. }
  91595. }
  91596. declare module BABYLON {
  91597. /**
  91598. * This class defines the direct association between an animation and a target
  91599. */
  91600. export class TargetedAnimation {
  91601. /**
  91602. * Animation to perform
  91603. */
  91604. animation: Animation;
  91605. /**
  91606. * Target to animate
  91607. */
  91608. target: any;
  91609. }
  91610. /**
  91611. * Use this class to create coordinated animations on multiple targets
  91612. */
  91613. export class AnimationGroup implements IDisposable {
  91614. /** The name of the animation group */
  91615. name: string;
  91616. private _scene;
  91617. private _targetedAnimations;
  91618. private _animatables;
  91619. private _from;
  91620. private _to;
  91621. private _isStarted;
  91622. private _isPaused;
  91623. private _speedRatio;
  91624. /**
  91625. * Gets or sets the unique id of the node
  91626. */
  91627. uniqueId: number;
  91628. /**
  91629. * This observable will notify when one animation have ended
  91630. */
  91631. onAnimationEndObservable: Observable<TargetedAnimation>;
  91632. /**
  91633. * Observer raised when one animation loops
  91634. */
  91635. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91636. /**
  91637. * This observable will notify when all animations have ended.
  91638. */
  91639. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91640. /**
  91641. * This observable will notify when all animations have paused.
  91642. */
  91643. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91644. /**
  91645. * This observable will notify when all animations are playing.
  91646. */
  91647. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91648. /**
  91649. * Gets the first frame
  91650. */
  91651. readonly from: number;
  91652. /**
  91653. * Gets the last frame
  91654. */
  91655. readonly to: number;
  91656. /**
  91657. * Define if the animations are started
  91658. */
  91659. readonly isStarted: boolean;
  91660. /**
  91661. * Gets a value indicating that the current group is playing
  91662. */
  91663. readonly isPlaying: boolean;
  91664. /**
  91665. * Gets or sets the speed ratio to use for all animations
  91666. */
  91667. /**
  91668. * Gets or sets the speed ratio to use for all animations
  91669. */
  91670. speedRatio: number;
  91671. /**
  91672. * Gets the targeted animations for this animation group
  91673. */
  91674. readonly targetedAnimations: Array<TargetedAnimation>;
  91675. /**
  91676. * returning the list of animatables controlled by this animation group.
  91677. */
  91678. readonly animatables: Array<Animatable>;
  91679. /**
  91680. * Instantiates a new Animation Group.
  91681. * This helps managing several animations at once.
  91682. * @see http://doc.babylonjs.com/how_to/group
  91683. * @param name Defines the name of the group
  91684. * @param scene Defines the scene the group belongs to
  91685. */
  91686. constructor(
  91687. /** The name of the animation group */
  91688. name: string, scene?: Nullable<Scene>);
  91689. /**
  91690. * Add an animation (with its target) in the group
  91691. * @param animation defines the animation we want to add
  91692. * @param target defines the target of the animation
  91693. * @returns the TargetedAnimation object
  91694. */
  91695. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91696. /**
  91697. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91698. * It can add constant keys at begin or end
  91699. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91700. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91701. * @returns the animation group
  91702. */
  91703. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91704. /**
  91705. * Start all animations on given targets
  91706. * @param loop defines if animations must loop
  91707. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91708. * @param from defines the from key (optional)
  91709. * @param to defines the to key (optional)
  91710. * @returns the current animation group
  91711. */
  91712. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91713. /**
  91714. * Pause all animations
  91715. * @returns the animation group
  91716. */
  91717. pause(): AnimationGroup;
  91718. /**
  91719. * Play all animations to initial state
  91720. * This function will start() the animations if they were not started or will restart() them if they were paused
  91721. * @param loop defines if animations must loop
  91722. * @returns the animation group
  91723. */
  91724. play(loop?: boolean): AnimationGroup;
  91725. /**
  91726. * Reset all animations to initial state
  91727. * @returns the animation group
  91728. */
  91729. reset(): AnimationGroup;
  91730. /**
  91731. * Restart animations from key 0
  91732. * @returns the animation group
  91733. */
  91734. restart(): AnimationGroup;
  91735. /**
  91736. * Stop all animations
  91737. * @returns the animation group
  91738. */
  91739. stop(): AnimationGroup;
  91740. /**
  91741. * Set animation weight for all animatables
  91742. * @param weight defines the weight to use
  91743. * @return the animationGroup
  91744. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91745. */
  91746. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91747. /**
  91748. * Synchronize and normalize all animatables with a source animatable
  91749. * @param root defines the root animatable to synchronize with
  91750. * @return the animationGroup
  91751. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91752. */
  91753. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91754. /**
  91755. * Goes to a specific frame in this animation group
  91756. * @param frame the frame number to go to
  91757. * @return the animationGroup
  91758. */
  91759. goToFrame(frame: number): AnimationGroup;
  91760. /**
  91761. * Dispose all associated resources
  91762. */
  91763. dispose(): void;
  91764. private _checkAnimationGroupEnded;
  91765. /**
  91766. * Clone the current animation group and returns a copy
  91767. * @param newName defines the name of the new group
  91768. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91769. * @returns the new aniamtion group
  91770. */
  91771. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91772. /**
  91773. * Returns a new AnimationGroup object parsed from the source provided.
  91774. * @param parsedAnimationGroup defines the source
  91775. * @param scene defines the scene that will receive the animationGroup
  91776. * @returns a new AnimationGroup
  91777. */
  91778. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91779. /**
  91780. * Returns the string "AnimationGroup"
  91781. * @returns "AnimationGroup"
  91782. */
  91783. getClassName(): string;
  91784. /**
  91785. * Creates a detailled string about the object
  91786. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91787. * @returns a string representing the object
  91788. */
  91789. toString(fullDetails?: boolean): string;
  91790. }
  91791. }
  91792. declare module BABYLON {
  91793. /**
  91794. * Define an interface for all classes that will hold resources
  91795. */
  91796. export interface IDisposable {
  91797. /**
  91798. * Releases all held resources
  91799. */
  91800. dispose(): void;
  91801. }
  91802. /** Interface defining initialization parameters for Scene class */
  91803. export interface SceneOptions {
  91804. /**
  91805. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91806. * It will improve performance when the number of geometries becomes important.
  91807. */
  91808. useGeometryUniqueIdsMap?: boolean;
  91809. /**
  91810. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91811. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91812. */
  91813. useMaterialMeshMap?: boolean;
  91814. /**
  91815. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91816. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91817. */
  91818. useClonedMeshhMap?: boolean;
  91819. }
  91820. /**
  91821. * Represents a scene to be rendered by the engine.
  91822. * @see http://doc.babylonjs.com/features/scene
  91823. */
  91824. export class Scene extends AbstractScene implements IAnimatable {
  91825. private static _uniqueIdCounter;
  91826. /** The fog is deactivated */
  91827. static readonly FOGMODE_NONE: number;
  91828. /** The fog density is following an exponential function */
  91829. static readonly FOGMODE_EXP: number;
  91830. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91831. static readonly FOGMODE_EXP2: number;
  91832. /** The fog density is following a linear function. */
  91833. static readonly FOGMODE_LINEAR: number;
  91834. /**
  91835. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91837. */
  91838. static MinDeltaTime: number;
  91839. /**
  91840. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91841. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91842. */
  91843. static MaxDeltaTime: number;
  91844. /**
  91845. * Factory used to create the default material.
  91846. * @param name The name of the material to create
  91847. * @param scene The scene to create the material for
  91848. * @returns The default material
  91849. */
  91850. static DefaultMaterialFactory(scene: Scene): Material;
  91851. /**
  91852. * Factory used to create the a collision coordinator.
  91853. * @returns The collision coordinator
  91854. */
  91855. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91856. /** @hidden */
  91857. _inputManager: InputManager;
  91858. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91859. cameraToUseForPointers: Nullable<Camera>;
  91860. /** @hidden */
  91861. readonly _isScene: boolean;
  91862. /**
  91863. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91864. */
  91865. autoClear: boolean;
  91866. /**
  91867. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91868. */
  91869. autoClearDepthAndStencil: boolean;
  91870. /**
  91871. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91872. */
  91873. clearColor: Color4;
  91874. /**
  91875. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91876. */
  91877. ambientColor: Color3;
  91878. /**
  91879. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91880. * It should only be one of the following (if not the default embedded one):
  91881. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91882. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91883. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91884. * The material properties need to be setup according to the type of texture in use.
  91885. */
  91886. environmentBRDFTexture: BaseTexture;
  91887. /** @hidden */
  91888. protected _environmentTexture: Nullable<BaseTexture>;
  91889. /**
  91890. * Texture used in all pbr material as the reflection texture.
  91891. * As in the majority of the scene they are the same (exception for multi room and so on),
  91892. * this is easier to reference from here than from all the materials.
  91893. */
  91894. /**
  91895. * Texture used in all pbr material as the reflection texture.
  91896. * As in the majority of the scene they are the same (exception for multi room and so on),
  91897. * this is easier to set here than in all the materials.
  91898. */
  91899. environmentTexture: Nullable<BaseTexture>;
  91900. /** @hidden */
  91901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91902. /**
  91903. * Default image processing configuration used either in the rendering
  91904. * Forward main pass or through the imageProcessingPostProcess if present.
  91905. * As in the majority of the scene they are the same (exception for multi camera),
  91906. * this is easier to reference from here than from all the materials and post process.
  91907. *
  91908. * No setter as we it is a shared configuration, you can set the values instead.
  91909. */
  91910. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91911. private _forceWireframe;
  91912. /**
  91913. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91914. */
  91915. forceWireframe: boolean;
  91916. private _forcePointsCloud;
  91917. /**
  91918. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91919. */
  91920. forcePointsCloud: boolean;
  91921. /**
  91922. * Gets or sets the active clipplane 1
  91923. */
  91924. clipPlane: Nullable<Plane>;
  91925. /**
  91926. * Gets or sets the active clipplane 2
  91927. */
  91928. clipPlane2: Nullable<Plane>;
  91929. /**
  91930. * Gets or sets the active clipplane 3
  91931. */
  91932. clipPlane3: Nullable<Plane>;
  91933. /**
  91934. * Gets or sets the active clipplane 4
  91935. */
  91936. clipPlane4: Nullable<Plane>;
  91937. /**
  91938. * Gets or sets a boolean indicating if animations are enabled
  91939. */
  91940. animationsEnabled: boolean;
  91941. private _animationPropertiesOverride;
  91942. /**
  91943. * Gets or sets the animation properties override
  91944. */
  91945. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91946. /**
  91947. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91948. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91949. */
  91950. useConstantAnimationDeltaTime: boolean;
  91951. /**
  91952. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91953. * Please note that it requires to run a ray cast through the scene on every frame
  91954. */
  91955. constantlyUpdateMeshUnderPointer: boolean;
  91956. /**
  91957. * Defines the HTML cursor to use when hovering over interactive elements
  91958. */
  91959. hoverCursor: string;
  91960. /**
  91961. * Defines the HTML default cursor to use (empty by default)
  91962. */
  91963. defaultCursor: string;
  91964. /**
  91965. * This is used to call preventDefault() on pointer down
  91966. * in order to block unwanted artifacts like system double clicks
  91967. */
  91968. preventDefaultOnPointerDown: boolean;
  91969. /**
  91970. * This is used to call preventDefault() on pointer up
  91971. * in order to block unwanted artifacts like system double clicks
  91972. */
  91973. preventDefaultOnPointerUp: boolean;
  91974. /**
  91975. * Gets or sets user defined metadata
  91976. */
  91977. metadata: any;
  91978. /**
  91979. * For internal use only. Please do not use.
  91980. */
  91981. reservedDataStore: any;
  91982. /**
  91983. * Gets the name of the plugin used to load this scene (null by default)
  91984. */
  91985. loadingPluginName: string;
  91986. /**
  91987. * Use this array to add regular expressions used to disable offline support for specific urls
  91988. */
  91989. disableOfflineSupportExceptionRules: RegExp[];
  91990. /**
  91991. * An event triggered when the scene is disposed.
  91992. */
  91993. onDisposeObservable: Observable<Scene>;
  91994. private _onDisposeObserver;
  91995. /** Sets a function to be executed when this scene is disposed. */
  91996. onDispose: () => void;
  91997. /**
  91998. * An event triggered before rendering the scene (right after animations and physics)
  91999. */
  92000. onBeforeRenderObservable: Observable<Scene>;
  92001. private _onBeforeRenderObserver;
  92002. /** Sets a function to be executed before rendering this scene */
  92003. beforeRender: Nullable<() => void>;
  92004. /**
  92005. * An event triggered after rendering the scene
  92006. */
  92007. onAfterRenderObservable: Observable<Scene>;
  92008. private _onAfterRenderObserver;
  92009. /** Sets a function to be executed after rendering this scene */
  92010. afterRender: Nullable<() => void>;
  92011. /**
  92012. * An event triggered before animating the scene
  92013. */
  92014. onBeforeAnimationsObservable: Observable<Scene>;
  92015. /**
  92016. * An event triggered after animations processing
  92017. */
  92018. onAfterAnimationsObservable: Observable<Scene>;
  92019. /**
  92020. * An event triggered before draw calls are ready to be sent
  92021. */
  92022. onBeforeDrawPhaseObservable: Observable<Scene>;
  92023. /**
  92024. * An event triggered after draw calls have been sent
  92025. */
  92026. onAfterDrawPhaseObservable: Observable<Scene>;
  92027. /**
  92028. * An event triggered when the scene is ready
  92029. */
  92030. onReadyObservable: Observable<Scene>;
  92031. /**
  92032. * An event triggered before rendering a camera
  92033. */
  92034. onBeforeCameraRenderObservable: Observable<Camera>;
  92035. private _onBeforeCameraRenderObserver;
  92036. /** Sets a function to be executed before rendering a camera*/
  92037. beforeCameraRender: () => void;
  92038. /**
  92039. * An event triggered after rendering a camera
  92040. */
  92041. onAfterCameraRenderObservable: Observable<Camera>;
  92042. private _onAfterCameraRenderObserver;
  92043. /** Sets a function to be executed after rendering a camera*/
  92044. afterCameraRender: () => void;
  92045. /**
  92046. * An event triggered when active meshes evaluation is about to start
  92047. */
  92048. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  92049. /**
  92050. * An event triggered when active meshes evaluation is done
  92051. */
  92052. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  92053. /**
  92054. * An event triggered when particles rendering is about to start
  92055. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92056. */
  92057. onBeforeParticlesRenderingObservable: Observable<Scene>;
  92058. /**
  92059. * An event triggered when particles rendering is done
  92060. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  92061. */
  92062. onAfterParticlesRenderingObservable: Observable<Scene>;
  92063. /**
  92064. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  92065. */
  92066. onDataLoadedObservable: Observable<Scene>;
  92067. /**
  92068. * An event triggered when a camera is created
  92069. */
  92070. onNewCameraAddedObservable: Observable<Camera>;
  92071. /**
  92072. * An event triggered when a camera is removed
  92073. */
  92074. onCameraRemovedObservable: Observable<Camera>;
  92075. /**
  92076. * An event triggered when a light is created
  92077. */
  92078. onNewLightAddedObservable: Observable<Light>;
  92079. /**
  92080. * An event triggered when a light is removed
  92081. */
  92082. onLightRemovedObservable: Observable<Light>;
  92083. /**
  92084. * An event triggered when a geometry is created
  92085. */
  92086. onNewGeometryAddedObservable: Observable<Geometry>;
  92087. /**
  92088. * An event triggered when a geometry is removed
  92089. */
  92090. onGeometryRemovedObservable: Observable<Geometry>;
  92091. /**
  92092. * An event triggered when a transform node is created
  92093. */
  92094. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  92095. /**
  92096. * An event triggered when a transform node is removed
  92097. */
  92098. onTransformNodeRemovedObservable: Observable<TransformNode>;
  92099. /**
  92100. * An event triggered when a mesh is created
  92101. */
  92102. onNewMeshAddedObservable: Observable<AbstractMesh>;
  92103. /**
  92104. * An event triggered when a mesh is removed
  92105. */
  92106. onMeshRemovedObservable: Observable<AbstractMesh>;
  92107. /**
  92108. * An event triggered when a skeleton is created
  92109. */
  92110. onNewSkeletonAddedObservable: Observable<Skeleton>;
  92111. /**
  92112. * An event triggered when a skeleton is removed
  92113. */
  92114. onSkeletonRemovedObservable: Observable<Skeleton>;
  92115. /**
  92116. * An event triggered when a material is created
  92117. */
  92118. onNewMaterialAddedObservable: Observable<Material>;
  92119. /**
  92120. * An event triggered when a material is removed
  92121. */
  92122. onMaterialRemovedObservable: Observable<Material>;
  92123. /**
  92124. * An event triggered when a texture is created
  92125. */
  92126. onNewTextureAddedObservable: Observable<BaseTexture>;
  92127. /**
  92128. * An event triggered when a texture is removed
  92129. */
  92130. onTextureRemovedObservable: Observable<BaseTexture>;
  92131. /**
  92132. * An event triggered when render targets are about to be rendered
  92133. * Can happen multiple times per frame.
  92134. */
  92135. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  92136. /**
  92137. * An event triggered when render targets were rendered.
  92138. * Can happen multiple times per frame.
  92139. */
  92140. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  92141. /**
  92142. * An event triggered before calculating deterministic simulation step
  92143. */
  92144. onBeforeStepObservable: Observable<Scene>;
  92145. /**
  92146. * An event triggered after calculating deterministic simulation step
  92147. */
  92148. onAfterStepObservable: Observable<Scene>;
  92149. /**
  92150. * An event triggered when the activeCamera property is updated
  92151. */
  92152. onActiveCameraChanged: Observable<Scene>;
  92153. /**
  92154. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  92155. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92156. * 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)
  92157. */
  92158. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92159. /**
  92160. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  92161. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  92162. * 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)
  92163. */
  92164. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  92165. /**
  92166. * This Observable will when a mesh has been imported into the scene.
  92167. */
  92168. onMeshImportedObservable: Observable<AbstractMesh>;
  92169. /**
  92170. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  92171. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  92172. */
  92173. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  92174. /** @hidden */
  92175. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  92176. /**
  92177. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  92178. */
  92179. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  92180. /**
  92181. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  92182. */
  92183. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  92184. /**
  92185. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  92186. */
  92187. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  92188. /** Callback called when a pointer move is detected */
  92189. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92190. /** Callback called when a pointer down is detected */
  92191. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  92192. /** Callback called when a pointer up is detected */
  92193. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  92194. /** Callback called when a pointer pick is detected */
  92195. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  92196. /**
  92197. * 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).
  92198. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  92199. */
  92200. onPrePointerObservable: Observable<PointerInfoPre>;
  92201. /**
  92202. * Observable event triggered each time an input event is received from the rendering canvas
  92203. */
  92204. onPointerObservable: Observable<PointerInfo>;
  92205. /**
  92206. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  92207. */
  92208. readonly unTranslatedPointer: Vector2;
  92209. /**
  92210. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  92211. */
  92212. static DragMovementThreshold: number;
  92213. /**
  92214. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  92215. */
  92216. static LongPressDelay: number;
  92217. /**
  92218. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  92219. */
  92220. static DoubleClickDelay: number;
  92221. /** If you need to check double click without raising a single click at first click, enable this flag */
  92222. static ExclusiveDoubleClickMode: boolean;
  92223. /** @hidden */
  92224. _mirroredCameraPosition: Nullable<Vector3>;
  92225. /**
  92226. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  92227. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  92228. */
  92229. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  92230. /**
  92231. * Observable event triggered each time an keyboard event is received from the hosting window
  92232. */
  92233. onKeyboardObservable: Observable<KeyboardInfo>;
  92234. private _useRightHandedSystem;
  92235. /**
  92236. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  92237. */
  92238. useRightHandedSystem: boolean;
  92239. private _timeAccumulator;
  92240. private _currentStepId;
  92241. private _currentInternalStep;
  92242. /**
  92243. * Sets the step Id used by deterministic lock step
  92244. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92245. * @param newStepId defines the step Id
  92246. */
  92247. setStepId(newStepId: number): void;
  92248. /**
  92249. * Gets the step Id used by deterministic lock step
  92250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92251. * @returns the step Id
  92252. */
  92253. getStepId(): number;
  92254. /**
  92255. * Gets the internal step used by deterministic lock step
  92256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92257. * @returns the internal step
  92258. */
  92259. getInternalStep(): number;
  92260. private _fogEnabled;
  92261. /**
  92262. * Gets or sets a boolean indicating if fog is enabled on this scene
  92263. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92264. * (Default is true)
  92265. */
  92266. fogEnabled: boolean;
  92267. private _fogMode;
  92268. /**
  92269. * Gets or sets the fog mode to use
  92270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92271. * | mode | value |
  92272. * | --- | --- |
  92273. * | FOGMODE_NONE | 0 |
  92274. * | FOGMODE_EXP | 1 |
  92275. * | FOGMODE_EXP2 | 2 |
  92276. * | FOGMODE_LINEAR | 3 |
  92277. */
  92278. fogMode: number;
  92279. /**
  92280. * Gets or sets the fog color to use
  92281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92282. * (Default is Color3(0.2, 0.2, 0.3))
  92283. */
  92284. fogColor: Color3;
  92285. /**
  92286. * Gets or sets the fog density to use
  92287. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92288. * (Default is 0.1)
  92289. */
  92290. fogDensity: number;
  92291. /**
  92292. * Gets or sets the fog start distance to use
  92293. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92294. * (Default is 0)
  92295. */
  92296. fogStart: number;
  92297. /**
  92298. * Gets or sets the fog end distance to use
  92299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  92300. * (Default is 1000)
  92301. */
  92302. fogEnd: number;
  92303. private _shadowsEnabled;
  92304. /**
  92305. * Gets or sets a boolean indicating if shadows are enabled on this scene
  92306. */
  92307. shadowsEnabled: boolean;
  92308. private _lightsEnabled;
  92309. /**
  92310. * Gets or sets a boolean indicating if lights are enabled on this scene
  92311. */
  92312. lightsEnabled: boolean;
  92313. /** All of the active cameras added to this scene. */
  92314. activeCameras: Camera[];
  92315. /** @hidden */
  92316. _activeCamera: Nullable<Camera>;
  92317. /** Gets or sets the current active camera */
  92318. activeCamera: Nullable<Camera>;
  92319. private _defaultMaterial;
  92320. /** The default material used on meshes when no material is affected */
  92321. /** The default material used on meshes when no material is affected */
  92322. defaultMaterial: Material;
  92323. private _texturesEnabled;
  92324. /**
  92325. * Gets or sets a boolean indicating if textures are enabled on this scene
  92326. */
  92327. texturesEnabled: boolean;
  92328. /**
  92329. * Gets or sets a boolean indicating if particles are enabled on this scene
  92330. */
  92331. particlesEnabled: boolean;
  92332. /**
  92333. * Gets or sets a boolean indicating if sprites are enabled on this scene
  92334. */
  92335. spritesEnabled: boolean;
  92336. private _skeletonsEnabled;
  92337. /**
  92338. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  92339. */
  92340. skeletonsEnabled: boolean;
  92341. /**
  92342. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  92343. */
  92344. lensFlaresEnabled: boolean;
  92345. /**
  92346. * Gets or sets a boolean indicating if collisions are enabled on this scene
  92347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92348. */
  92349. collisionsEnabled: boolean;
  92350. private _collisionCoordinator;
  92351. /** @hidden */
  92352. readonly collisionCoordinator: ICollisionCoordinator;
  92353. /**
  92354. * Defines the gravity applied to this scene (used only for collisions)
  92355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92356. */
  92357. gravity: Vector3;
  92358. /**
  92359. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  92360. */
  92361. postProcessesEnabled: boolean;
  92362. /**
  92363. * The list of postprocesses added to the scene
  92364. */
  92365. postProcesses: PostProcess[];
  92366. /**
  92367. * Gets the current postprocess manager
  92368. */
  92369. postProcessManager: PostProcessManager;
  92370. /**
  92371. * Gets or sets a boolean indicating if render targets are enabled on this scene
  92372. */
  92373. renderTargetsEnabled: boolean;
  92374. /**
  92375. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  92376. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  92377. */
  92378. dumpNextRenderTargets: boolean;
  92379. /**
  92380. * The list of user defined render targets added to the scene
  92381. */
  92382. customRenderTargets: RenderTargetTexture[];
  92383. /**
  92384. * Defines if texture loading must be delayed
  92385. * If true, textures will only be loaded when they need to be rendered
  92386. */
  92387. useDelayedTextureLoading: boolean;
  92388. /**
  92389. * Gets the list of meshes imported to the scene through SceneLoader
  92390. */
  92391. importedMeshesFiles: String[];
  92392. /**
  92393. * Gets or sets a boolean indicating if probes are enabled on this scene
  92394. */
  92395. probesEnabled: boolean;
  92396. /**
  92397. * Gets or sets the current offline provider to use to store scene data
  92398. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  92399. */
  92400. offlineProvider: IOfflineProvider;
  92401. /**
  92402. * Gets or sets the action manager associated with the scene
  92403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92404. */
  92405. actionManager: AbstractActionManager;
  92406. private _meshesForIntersections;
  92407. /**
  92408. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  92409. */
  92410. proceduralTexturesEnabled: boolean;
  92411. private _engine;
  92412. private _totalVertices;
  92413. /** @hidden */
  92414. _activeIndices: PerfCounter;
  92415. /** @hidden */
  92416. _activeParticles: PerfCounter;
  92417. /** @hidden */
  92418. _activeBones: PerfCounter;
  92419. private _animationRatio;
  92420. /** @hidden */
  92421. _animationTimeLast: number;
  92422. /** @hidden */
  92423. _animationTime: number;
  92424. /**
  92425. * Gets or sets a general scale for animation speed
  92426. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  92427. */
  92428. animationTimeScale: number;
  92429. /** @hidden */
  92430. _cachedMaterial: Nullable<Material>;
  92431. /** @hidden */
  92432. _cachedEffect: Nullable<Effect>;
  92433. /** @hidden */
  92434. _cachedVisibility: Nullable<number>;
  92435. private _renderId;
  92436. private _frameId;
  92437. private _executeWhenReadyTimeoutId;
  92438. private _intermediateRendering;
  92439. private _viewUpdateFlag;
  92440. private _projectionUpdateFlag;
  92441. /** @hidden */
  92442. _toBeDisposed: Nullable<IDisposable>[];
  92443. private _activeRequests;
  92444. /** @hidden */
  92445. _pendingData: any[];
  92446. private _isDisposed;
  92447. /**
  92448. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  92449. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  92450. */
  92451. dispatchAllSubMeshesOfActiveMeshes: boolean;
  92452. private _activeMeshes;
  92453. private _processedMaterials;
  92454. private _renderTargets;
  92455. /** @hidden */
  92456. _activeParticleSystems: SmartArray<IParticleSystem>;
  92457. private _activeSkeletons;
  92458. private _softwareSkinnedMeshes;
  92459. private _renderingManager;
  92460. /** @hidden */
  92461. _activeAnimatables: Animatable[];
  92462. private _transformMatrix;
  92463. private _sceneUbo;
  92464. /** @hidden */
  92465. _viewMatrix: Matrix;
  92466. private _projectionMatrix;
  92467. /** @hidden */
  92468. _forcedViewPosition: Nullable<Vector3>;
  92469. /** @hidden */
  92470. _frustumPlanes: Plane[];
  92471. /**
  92472. * Gets the list of frustum planes (built from the active camera)
  92473. */
  92474. readonly frustumPlanes: Plane[];
  92475. /**
  92476. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  92477. * This is useful if there are more lights that the maximum simulteanous authorized
  92478. */
  92479. requireLightSorting: boolean;
  92480. /** @hidden */
  92481. readonly useMaterialMeshMap: boolean;
  92482. /** @hidden */
  92483. readonly useClonedMeshhMap: boolean;
  92484. private _externalData;
  92485. private _uid;
  92486. /**
  92487. * @hidden
  92488. * Backing store of defined scene components.
  92489. */
  92490. _components: ISceneComponent[];
  92491. /**
  92492. * @hidden
  92493. * Backing store of defined scene components.
  92494. */
  92495. _serializableComponents: ISceneSerializableComponent[];
  92496. /**
  92497. * List of components to register on the next registration step.
  92498. */
  92499. private _transientComponents;
  92500. /**
  92501. * Registers the transient components if needed.
  92502. */
  92503. private _registerTransientComponents;
  92504. /**
  92505. * @hidden
  92506. * Add a component to the scene.
  92507. * Note that the ccomponent could be registered on th next frame if this is called after
  92508. * the register component stage.
  92509. * @param component Defines the component to add to the scene
  92510. */
  92511. _addComponent(component: ISceneComponent): void;
  92512. /**
  92513. * @hidden
  92514. * Gets a component from the scene.
  92515. * @param name defines the name of the component to retrieve
  92516. * @returns the component or null if not present
  92517. */
  92518. _getComponent(name: string): Nullable<ISceneComponent>;
  92519. /**
  92520. * @hidden
  92521. * Defines the actions happening before camera updates.
  92522. */
  92523. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92524. /**
  92525. * @hidden
  92526. * Defines the actions happening before clear the canvas.
  92527. */
  92528. _beforeClearStage: Stage<SimpleStageAction>;
  92529. /**
  92530. * @hidden
  92531. * Defines the actions when collecting render targets for the frame.
  92532. */
  92533. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92534. /**
  92535. * @hidden
  92536. * Defines the actions happening for one camera in the frame.
  92537. */
  92538. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92539. /**
  92540. * @hidden
  92541. * Defines the actions happening during the per mesh ready checks.
  92542. */
  92543. _isReadyForMeshStage: Stage<MeshStageAction>;
  92544. /**
  92545. * @hidden
  92546. * Defines the actions happening before evaluate active mesh checks.
  92547. */
  92548. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92549. /**
  92550. * @hidden
  92551. * Defines the actions happening during the evaluate sub mesh checks.
  92552. */
  92553. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92554. /**
  92555. * @hidden
  92556. * Defines the actions happening during the active mesh stage.
  92557. */
  92558. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92559. /**
  92560. * @hidden
  92561. * Defines the actions happening during the per camera render target step.
  92562. */
  92563. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92564. /**
  92565. * @hidden
  92566. * Defines the actions happening just before the active camera is drawing.
  92567. */
  92568. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92569. /**
  92570. * @hidden
  92571. * Defines the actions happening just before a render target is drawing.
  92572. */
  92573. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92574. /**
  92575. * @hidden
  92576. * Defines the actions happening just before a rendering group is drawing.
  92577. */
  92578. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92579. /**
  92580. * @hidden
  92581. * Defines the actions happening just before a mesh is drawing.
  92582. */
  92583. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92584. /**
  92585. * @hidden
  92586. * Defines the actions happening just after a mesh has been drawn.
  92587. */
  92588. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92589. /**
  92590. * @hidden
  92591. * Defines the actions happening just after a rendering group has been drawn.
  92592. */
  92593. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92594. /**
  92595. * @hidden
  92596. * Defines the actions happening just after the active camera has been drawn.
  92597. */
  92598. _afterCameraDrawStage: Stage<CameraStageAction>;
  92599. /**
  92600. * @hidden
  92601. * Defines the actions happening just after a render target has been drawn.
  92602. */
  92603. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92604. /**
  92605. * @hidden
  92606. * Defines the actions happening just after rendering all cameras and computing intersections.
  92607. */
  92608. _afterRenderStage: Stage<SimpleStageAction>;
  92609. /**
  92610. * @hidden
  92611. * Defines the actions happening when a pointer move event happens.
  92612. */
  92613. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92614. /**
  92615. * @hidden
  92616. * Defines the actions happening when a pointer down event happens.
  92617. */
  92618. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92619. /**
  92620. * @hidden
  92621. * Defines the actions happening when a pointer up event happens.
  92622. */
  92623. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92624. /**
  92625. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92626. */
  92627. private geometriesByUniqueId;
  92628. /**
  92629. * Creates a new Scene
  92630. * @param engine defines the engine to use to render this scene
  92631. * @param options defines the scene options
  92632. */
  92633. constructor(engine: Engine, options?: SceneOptions);
  92634. /**
  92635. * Gets a string idenfifying the name of the class
  92636. * @returns "Scene" string
  92637. */
  92638. getClassName(): string;
  92639. private _defaultMeshCandidates;
  92640. /**
  92641. * @hidden
  92642. */
  92643. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92644. private _defaultSubMeshCandidates;
  92645. /**
  92646. * @hidden
  92647. */
  92648. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92649. /**
  92650. * Sets the default candidate providers for the scene.
  92651. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92652. * and getCollidingSubMeshCandidates to their default function
  92653. */
  92654. setDefaultCandidateProviders(): void;
  92655. /**
  92656. * Gets the mesh that is currently under the pointer
  92657. */
  92658. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92659. /**
  92660. * Gets or sets the current on-screen X position of the pointer
  92661. */
  92662. pointerX: number;
  92663. /**
  92664. * Gets or sets the current on-screen Y position of the pointer
  92665. */
  92666. pointerY: number;
  92667. /**
  92668. * Gets the cached material (ie. the latest rendered one)
  92669. * @returns the cached material
  92670. */
  92671. getCachedMaterial(): Nullable<Material>;
  92672. /**
  92673. * Gets the cached effect (ie. the latest rendered one)
  92674. * @returns the cached effect
  92675. */
  92676. getCachedEffect(): Nullable<Effect>;
  92677. /**
  92678. * Gets the cached visibility state (ie. the latest rendered one)
  92679. * @returns the cached visibility state
  92680. */
  92681. getCachedVisibility(): Nullable<number>;
  92682. /**
  92683. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92684. * @param material defines the current material
  92685. * @param effect defines the current effect
  92686. * @param visibility defines the current visibility state
  92687. * @returns true if one parameter is not cached
  92688. */
  92689. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92690. /**
  92691. * Gets the engine associated with the scene
  92692. * @returns an Engine
  92693. */
  92694. getEngine(): Engine;
  92695. /**
  92696. * Gets the total number of vertices rendered per frame
  92697. * @returns the total number of vertices rendered per frame
  92698. */
  92699. getTotalVertices(): number;
  92700. /**
  92701. * Gets the performance counter for total vertices
  92702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92703. */
  92704. readonly totalVerticesPerfCounter: PerfCounter;
  92705. /**
  92706. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92707. * @returns the total number of active indices rendered per frame
  92708. */
  92709. getActiveIndices(): number;
  92710. /**
  92711. * Gets the performance counter for active indices
  92712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92713. */
  92714. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92715. /**
  92716. * Gets the total number of active particles rendered per frame
  92717. * @returns the total number of active particles rendered per frame
  92718. */
  92719. getActiveParticles(): number;
  92720. /**
  92721. * Gets the performance counter for active particles
  92722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92723. */
  92724. readonly activeParticlesPerfCounter: PerfCounter;
  92725. /**
  92726. * Gets the total number of active bones rendered per frame
  92727. * @returns the total number of active bones rendered per frame
  92728. */
  92729. getActiveBones(): number;
  92730. /**
  92731. * Gets the performance counter for active bones
  92732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92733. */
  92734. readonly activeBonesPerfCounter: PerfCounter;
  92735. /**
  92736. * Gets the array of active meshes
  92737. * @returns an array of AbstractMesh
  92738. */
  92739. getActiveMeshes(): SmartArray<AbstractMesh>;
  92740. /**
  92741. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92742. * @returns a number
  92743. */
  92744. getAnimationRatio(): number;
  92745. /**
  92746. * Gets an unique Id for the current render phase
  92747. * @returns a number
  92748. */
  92749. getRenderId(): number;
  92750. /**
  92751. * Gets an unique Id for the current frame
  92752. * @returns a number
  92753. */
  92754. getFrameId(): number;
  92755. /** Call this function if you want to manually increment the render Id*/
  92756. incrementRenderId(): void;
  92757. private _createUbo;
  92758. /**
  92759. * Use this method to simulate a pointer move on a mesh
  92760. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92761. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92762. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92763. * @returns the current scene
  92764. */
  92765. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92766. /**
  92767. * Use this method to simulate a pointer down on a mesh
  92768. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92769. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92770. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92771. * @returns the current scene
  92772. */
  92773. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92774. /**
  92775. * Use this method to simulate a pointer up on a mesh
  92776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92779. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92780. * @returns the current scene
  92781. */
  92782. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92783. /**
  92784. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92785. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92786. * @returns true if the pointer was captured
  92787. */
  92788. isPointerCaptured(pointerId?: number): boolean;
  92789. /**
  92790. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92791. * @param attachUp defines if you want to attach events to pointerup
  92792. * @param attachDown defines if you want to attach events to pointerdown
  92793. * @param attachMove defines if you want to attach events to pointermove
  92794. */
  92795. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92796. /** Detaches all event handlers*/
  92797. detachControl(): void;
  92798. /**
  92799. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92800. * Delay loaded resources are not taking in account
  92801. * @return true if all required resources are ready
  92802. */
  92803. isReady(): boolean;
  92804. /** Resets all cached information relative to material (including effect and visibility) */
  92805. resetCachedMaterial(): void;
  92806. /**
  92807. * Registers a function to be called before every frame render
  92808. * @param func defines the function to register
  92809. */
  92810. registerBeforeRender(func: () => void): void;
  92811. /**
  92812. * Unregisters a function called before every frame render
  92813. * @param func defines the function to unregister
  92814. */
  92815. unregisterBeforeRender(func: () => void): void;
  92816. /**
  92817. * Registers a function to be called after every frame render
  92818. * @param func defines the function to register
  92819. */
  92820. registerAfterRender(func: () => void): void;
  92821. /**
  92822. * Unregisters a function called after every frame render
  92823. * @param func defines the function to unregister
  92824. */
  92825. unregisterAfterRender(func: () => void): void;
  92826. private _executeOnceBeforeRender;
  92827. /**
  92828. * The provided function will run before render once and will be disposed afterwards.
  92829. * A timeout delay can be provided so that the function will be executed in N ms.
  92830. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92831. * @param func The function to be executed.
  92832. * @param timeout optional delay in ms
  92833. */
  92834. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92835. /** @hidden */
  92836. _addPendingData(data: any): void;
  92837. /** @hidden */
  92838. _removePendingData(data: any): void;
  92839. /**
  92840. * Returns the number of items waiting to be loaded
  92841. * @returns the number of items waiting to be loaded
  92842. */
  92843. getWaitingItemsCount(): number;
  92844. /**
  92845. * Returns a boolean indicating if the scene is still loading data
  92846. */
  92847. readonly isLoading: boolean;
  92848. /**
  92849. * Registers a function to be executed when the scene is ready
  92850. * @param {Function} func - the function to be executed
  92851. */
  92852. executeWhenReady(func: () => void): void;
  92853. /**
  92854. * Returns a promise that resolves when the scene is ready
  92855. * @returns A promise that resolves when the scene is ready
  92856. */
  92857. whenReadyAsync(): Promise<void>;
  92858. /** @hidden */
  92859. _checkIsReady(): void;
  92860. /**
  92861. * Gets all animatable attached to the scene
  92862. */
  92863. readonly animatables: Animatable[];
  92864. /**
  92865. * Resets the last animation time frame.
  92866. * Useful to override when animations start running when loading a scene for the first time.
  92867. */
  92868. resetLastAnimationTimeFrame(): void;
  92869. /**
  92870. * Gets the current view matrix
  92871. * @returns a Matrix
  92872. */
  92873. getViewMatrix(): Matrix;
  92874. /**
  92875. * Gets the current projection matrix
  92876. * @returns a Matrix
  92877. */
  92878. getProjectionMatrix(): Matrix;
  92879. /**
  92880. * Gets the current transform matrix
  92881. * @returns a Matrix made of View * Projection
  92882. */
  92883. getTransformMatrix(): Matrix;
  92884. /**
  92885. * Sets the current transform matrix
  92886. * @param viewL defines the View matrix to use
  92887. * @param projectionL defines the Projection matrix to use
  92888. * @param viewR defines the right View matrix to use (if provided)
  92889. * @param projectionR defines the right Projection matrix to use (if provided)
  92890. */
  92891. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92892. /**
  92893. * Gets the uniform buffer used to store scene data
  92894. * @returns a UniformBuffer
  92895. */
  92896. getSceneUniformBuffer(): UniformBuffer;
  92897. /**
  92898. * Gets an unique (relatively to the current scene) Id
  92899. * @returns an unique number for the scene
  92900. */
  92901. getUniqueId(): number;
  92902. /**
  92903. * Add a mesh to the list of scene's meshes
  92904. * @param newMesh defines the mesh to add
  92905. * @param recursive if all child meshes should also be added to the scene
  92906. */
  92907. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92908. /**
  92909. * Remove a mesh for the list of scene's meshes
  92910. * @param toRemove defines the mesh to remove
  92911. * @param recursive if all child meshes should also be removed from the scene
  92912. * @returns the index where the mesh was in the mesh list
  92913. */
  92914. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92915. /**
  92916. * Add a transform node to the list of scene's transform nodes
  92917. * @param newTransformNode defines the transform node to add
  92918. */
  92919. addTransformNode(newTransformNode: TransformNode): void;
  92920. /**
  92921. * Remove a transform node for the list of scene's transform nodes
  92922. * @param toRemove defines the transform node to remove
  92923. * @returns the index where the transform node was in the transform node list
  92924. */
  92925. removeTransformNode(toRemove: TransformNode): number;
  92926. /**
  92927. * Remove a skeleton for the list of scene's skeletons
  92928. * @param toRemove defines the skeleton to remove
  92929. * @returns the index where the skeleton was in the skeleton list
  92930. */
  92931. removeSkeleton(toRemove: Skeleton): number;
  92932. /**
  92933. * Remove a morph target for the list of scene's morph targets
  92934. * @param toRemove defines the morph target to remove
  92935. * @returns the index where the morph target was in the morph target list
  92936. */
  92937. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92938. /**
  92939. * Remove a light for the list of scene's lights
  92940. * @param toRemove defines the light to remove
  92941. * @returns the index where the light was in the light list
  92942. */
  92943. removeLight(toRemove: Light): number;
  92944. /**
  92945. * Remove a camera for the list of scene's cameras
  92946. * @param toRemove defines the camera to remove
  92947. * @returns the index where the camera was in the camera list
  92948. */
  92949. removeCamera(toRemove: Camera): number;
  92950. /**
  92951. * Remove a particle system for the list of scene's particle systems
  92952. * @param toRemove defines the particle system to remove
  92953. * @returns the index where the particle system was in the particle system list
  92954. */
  92955. removeParticleSystem(toRemove: IParticleSystem): number;
  92956. /**
  92957. * Remove a animation for the list of scene's animations
  92958. * @param toRemove defines the animation to remove
  92959. * @returns the index where the animation was in the animation list
  92960. */
  92961. removeAnimation(toRemove: Animation): number;
  92962. /**
  92963. * Will stop the animation of the given target
  92964. * @param target - the target
  92965. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  92966. * @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)
  92967. */
  92968. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  92969. /**
  92970. * Removes the given animation group from this scene.
  92971. * @param toRemove The animation group to remove
  92972. * @returns The index of the removed animation group
  92973. */
  92974. removeAnimationGroup(toRemove: AnimationGroup): number;
  92975. /**
  92976. * Removes the given multi-material from this scene.
  92977. * @param toRemove The multi-material to remove
  92978. * @returns The index of the removed multi-material
  92979. */
  92980. removeMultiMaterial(toRemove: MultiMaterial): number;
  92981. /**
  92982. * Removes the given material from this scene.
  92983. * @param toRemove The material to remove
  92984. * @returns The index of the removed material
  92985. */
  92986. removeMaterial(toRemove: Material): number;
  92987. /**
  92988. * Removes the given action manager from this scene.
  92989. * @param toRemove The action manager to remove
  92990. * @returns The index of the removed action manager
  92991. */
  92992. removeActionManager(toRemove: AbstractActionManager): number;
  92993. /**
  92994. * Removes the given texture from this scene.
  92995. * @param toRemove The texture to remove
  92996. * @returns The index of the removed texture
  92997. */
  92998. removeTexture(toRemove: BaseTexture): number;
  92999. /**
  93000. * Adds the given light to this scene
  93001. * @param newLight The light to add
  93002. */
  93003. addLight(newLight: Light): void;
  93004. /**
  93005. * Sorts the list list based on light priorities
  93006. */
  93007. sortLightsByPriority(): void;
  93008. /**
  93009. * Adds the given camera to this scene
  93010. * @param newCamera The camera to add
  93011. */
  93012. addCamera(newCamera: Camera): void;
  93013. /**
  93014. * Adds the given skeleton to this scene
  93015. * @param newSkeleton The skeleton to add
  93016. */
  93017. addSkeleton(newSkeleton: Skeleton): void;
  93018. /**
  93019. * Adds the given particle system to this scene
  93020. * @param newParticleSystem The particle system to add
  93021. */
  93022. addParticleSystem(newParticleSystem: IParticleSystem): void;
  93023. /**
  93024. * Adds the given animation to this scene
  93025. * @param newAnimation The animation to add
  93026. */
  93027. addAnimation(newAnimation: Animation): void;
  93028. /**
  93029. * Adds the given animation group to this scene.
  93030. * @param newAnimationGroup The animation group to add
  93031. */
  93032. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  93033. /**
  93034. * Adds the given multi-material to this scene
  93035. * @param newMultiMaterial The multi-material to add
  93036. */
  93037. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  93038. /**
  93039. * Adds the given material to this scene
  93040. * @param newMaterial The material to add
  93041. */
  93042. addMaterial(newMaterial: Material): void;
  93043. /**
  93044. * Adds the given morph target to this scene
  93045. * @param newMorphTargetManager The morph target to add
  93046. */
  93047. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  93048. /**
  93049. * Adds the given geometry to this scene
  93050. * @param newGeometry The geometry to add
  93051. */
  93052. addGeometry(newGeometry: Geometry): void;
  93053. /**
  93054. * Adds the given action manager to this scene
  93055. * @param newActionManager The action manager to add
  93056. */
  93057. addActionManager(newActionManager: AbstractActionManager): void;
  93058. /**
  93059. * Adds the given texture to this scene.
  93060. * @param newTexture The texture to add
  93061. */
  93062. addTexture(newTexture: BaseTexture): void;
  93063. /**
  93064. * Switch active camera
  93065. * @param newCamera defines the new active camera
  93066. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  93067. */
  93068. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  93069. /**
  93070. * sets the active camera of the scene using its ID
  93071. * @param id defines the camera's ID
  93072. * @return the new active camera or null if none found.
  93073. */
  93074. setActiveCameraByID(id: string): Nullable<Camera>;
  93075. /**
  93076. * sets the active camera of the scene using its name
  93077. * @param name defines the camera's name
  93078. * @returns the new active camera or null if none found.
  93079. */
  93080. setActiveCameraByName(name: string): Nullable<Camera>;
  93081. /**
  93082. * get an animation group using its name
  93083. * @param name defines the material's name
  93084. * @return the animation group or null if none found.
  93085. */
  93086. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  93087. /**
  93088. * Get a material using its unique id
  93089. * @param uniqueId defines the material's unique id
  93090. * @return the material or null if none found.
  93091. */
  93092. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  93093. /**
  93094. * get a material using its id
  93095. * @param id defines the material's ID
  93096. * @return the material or null if none found.
  93097. */
  93098. getMaterialByID(id: string): Nullable<Material>;
  93099. /**
  93100. * Gets a material using its name
  93101. * @param name defines the material's name
  93102. * @return the material or null if none found.
  93103. */
  93104. getMaterialByName(name: string): Nullable<Material>;
  93105. /**
  93106. * Gets a camera using its id
  93107. * @param id defines the id to look for
  93108. * @returns the camera or null if not found
  93109. */
  93110. getCameraByID(id: string): Nullable<Camera>;
  93111. /**
  93112. * Gets a camera using its unique id
  93113. * @param uniqueId defines the unique id to look for
  93114. * @returns the camera or null if not found
  93115. */
  93116. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  93117. /**
  93118. * Gets a camera using its name
  93119. * @param name defines the camera's name
  93120. * @return the camera or null if none found.
  93121. */
  93122. getCameraByName(name: string): Nullable<Camera>;
  93123. /**
  93124. * Gets a bone using its id
  93125. * @param id defines the bone's id
  93126. * @return the bone or null if not found
  93127. */
  93128. getBoneByID(id: string): Nullable<Bone>;
  93129. /**
  93130. * Gets a bone using its id
  93131. * @param name defines the bone's name
  93132. * @return the bone or null if not found
  93133. */
  93134. getBoneByName(name: string): Nullable<Bone>;
  93135. /**
  93136. * Gets a light node using its name
  93137. * @param name defines the the light's name
  93138. * @return the light or null if none found.
  93139. */
  93140. getLightByName(name: string): Nullable<Light>;
  93141. /**
  93142. * Gets a light node using its id
  93143. * @param id defines the light's id
  93144. * @return the light or null if none found.
  93145. */
  93146. getLightByID(id: string): Nullable<Light>;
  93147. /**
  93148. * Gets a light node using its scene-generated unique ID
  93149. * @param uniqueId defines the light's unique id
  93150. * @return the light or null if none found.
  93151. */
  93152. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  93153. /**
  93154. * Gets a particle system by id
  93155. * @param id defines the particle system id
  93156. * @return the corresponding system or null if none found
  93157. */
  93158. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  93159. /**
  93160. * Gets a geometry using its ID
  93161. * @param id defines the geometry's id
  93162. * @return the geometry or null if none found.
  93163. */
  93164. getGeometryByID(id: string): Nullable<Geometry>;
  93165. private _getGeometryByUniqueID;
  93166. /**
  93167. * Add a new geometry to this scene
  93168. * @param geometry defines the geometry to be added to the scene.
  93169. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  93170. * @return a boolean defining if the geometry was added or not
  93171. */
  93172. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  93173. /**
  93174. * Removes an existing geometry
  93175. * @param geometry defines the geometry to be removed from the scene
  93176. * @return a boolean defining if the geometry was removed or not
  93177. */
  93178. removeGeometry(geometry: Geometry): boolean;
  93179. /**
  93180. * Gets the list of geometries attached to the scene
  93181. * @returns an array of Geometry
  93182. */
  93183. getGeometries(): Geometry[];
  93184. /**
  93185. * Gets the first added mesh found of a given ID
  93186. * @param id defines the id to search for
  93187. * @return the mesh found or null if not found at all
  93188. */
  93189. getMeshByID(id: string): Nullable<AbstractMesh>;
  93190. /**
  93191. * Gets a list of meshes using their id
  93192. * @param id defines the id to search for
  93193. * @returns a list of meshes
  93194. */
  93195. getMeshesByID(id: string): Array<AbstractMesh>;
  93196. /**
  93197. * Gets the first added transform node found of a given ID
  93198. * @param id defines the id to search for
  93199. * @return the found transform node or null if not found at all.
  93200. */
  93201. getTransformNodeByID(id: string): Nullable<TransformNode>;
  93202. /**
  93203. * Gets a transform node with its auto-generated unique id
  93204. * @param uniqueId efines the unique id to search for
  93205. * @return the found transform node or null if not found at all.
  93206. */
  93207. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  93208. /**
  93209. * Gets a list of transform nodes using their id
  93210. * @param id defines the id to search for
  93211. * @returns a list of transform nodes
  93212. */
  93213. getTransformNodesByID(id: string): Array<TransformNode>;
  93214. /**
  93215. * Gets a mesh with its auto-generated unique id
  93216. * @param uniqueId defines the unique id to search for
  93217. * @return the found mesh or null if not found at all.
  93218. */
  93219. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  93220. /**
  93221. * Gets a the last added mesh using a given id
  93222. * @param id defines the id to search for
  93223. * @return the found mesh or null if not found at all.
  93224. */
  93225. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  93226. /**
  93227. * Gets a the last added node (Mesh, Camera, Light) using a given id
  93228. * @param id defines the id to search for
  93229. * @return the found node or null if not found at all
  93230. */
  93231. getLastEntryByID(id: string): Nullable<Node>;
  93232. /**
  93233. * Gets a node (Mesh, Camera, Light) using a given id
  93234. * @param id defines the id to search for
  93235. * @return the found node or null if not found at all
  93236. */
  93237. getNodeByID(id: string): Nullable<Node>;
  93238. /**
  93239. * Gets a node (Mesh, Camera, Light) using a given name
  93240. * @param name defines the name to search for
  93241. * @return the found node or null if not found at all.
  93242. */
  93243. getNodeByName(name: string): Nullable<Node>;
  93244. /**
  93245. * Gets a mesh using a given name
  93246. * @param name defines the name to search for
  93247. * @return the found mesh or null if not found at all.
  93248. */
  93249. getMeshByName(name: string): Nullable<AbstractMesh>;
  93250. /**
  93251. * Gets a transform node using a given name
  93252. * @param name defines the name to search for
  93253. * @return the found transform node or null if not found at all.
  93254. */
  93255. getTransformNodeByName(name: string): Nullable<TransformNode>;
  93256. /**
  93257. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  93258. * @param id defines the id to search for
  93259. * @return the found skeleton or null if not found at all.
  93260. */
  93261. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  93262. /**
  93263. * Gets a skeleton using a given auto generated unique id
  93264. * @param uniqueId defines the unique id to search for
  93265. * @return the found skeleton or null if not found at all.
  93266. */
  93267. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  93268. /**
  93269. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  93270. * @param id defines the id to search for
  93271. * @return the found skeleton or null if not found at all.
  93272. */
  93273. getSkeletonById(id: string): Nullable<Skeleton>;
  93274. /**
  93275. * Gets a skeleton using a given name
  93276. * @param name defines the name to search for
  93277. * @return the found skeleton or null if not found at all.
  93278. */
  93279. getSkeletonByName(name: string): Nullable<Skeleton>;
  93280. /**
  93281. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  93282. * @param id defines the id to search for
  93283. * @return the found morph target manager or null if not found at all.
  93284. */
  93285. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  93286. /**
  93287. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  93288. * @param id defines the id to search for
  93289. * @return the found morph target or null if not found at all.
  93290. */
  93291. getMorphTargetById(id: string): Nullable<MorphTarget>;
  93292. /**
  93293. * Gets a boolean indicating if the given mesh is active
  93294. * @param mesh defines the mesh to look for
  93295. * @returns true if the mesh is in the active list
  93296. */
  93297. isActiveMesh(mesh: AbstractMesh): boolean;
  93298. /**
  93299. * Return a unique id as a string which can serve as an identifier for the scene
  93300. */
  93301. readonly uid: string;
  93302. /**
  93303. * Add an externaly attached data from its key.
  93304. * This method call will fail and return false, if such key already exists.
  93305. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  93306. * @param key the unique key that identifies the data
  93307. * @param data the data object to associate to the key for this Engine instance
  93308. * @return true if no such key were already present and the data was added successfully, false otherwise
  93309. */
  93310. addExternalData<T>(key: string, data: T): boolean;
  93311. /**
  93312. * Get an externaly attached data from its key
  93313. * @param key the unique key that identifies the data
  93314. * @return the associated data, if present (can be null), or undefined if not present
  93315. */
  93316. getExternalData<T>(key: string): Nullable<T>;
  93317. /**
  93318. * Get an externaly attached data from its key, create it using a factory if it's not already present
  93319. * @param key the unique key that identifies the data
  93320. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  93321. * @return the associated data, can be null if the factory returned null.
  93322. */
  93323. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  93324. /**
  93325. * Remove an externaly attached data from the Engine instance
  93326. * @param key the unique key that identifies the data
  93327. * @return true if the data was successfully removed, false if it doesn't exist
  93328. */
  93329. removeExternalData(key: string): boolean;
  93330. private _evaluateSubMesh;
  93331. /**
  93332. * Clear the processed materials smart array preventing retention point in material dispose.
  93333. */
  93334. freeProcessedMaterials(): void;
  93335. private _preventFreeActiveMeshesAndRenderingGroups;
  93336. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  93337. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  93338. * when disposing several meshes in a row or a hierarchy of meshes.
  93339. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  93340. */
  93341. blockfreeActiveMeshesAndRenderingGroups: boolean;
  93342. /**
  93343. * Clear the active meshes smart array preventing retention point in mesh dispose.
  93344. */
  93345. freeActiveMeshes(): void;
  93346. /**
  93347. * Clear the info related to rendering groups preventing retention points during dispose.
  93348. */
  93349. freeRenderingGroups(): void;
  93350. /** @hidden */
  93351. _isInIntermediateRendering(): boolean;
  93352. /**
  93353. * Lambda returning the list of potentially active meshes.
  93354. */
  93355. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  93356. /**
  93357. * Lambda returning the list of potentially active sub meshes.
  93358. */
  93359. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  93360. /**
  93361. * Lambda returning the list of potentially intersecting sub meshes.
  93362. */
  93363. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  93364. /**
  93365. * Lambda returning the list of potentially colliding sub meshes.
  93366. */
  93367. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  93368. private _activeMeshesFrozen;
  93369. /**
  93370. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  93371. * @returns the current scene
  93372. */
  93373. freezeActiveMeshes(): Scene;
  93374. /**
  93375. * Use this function to restart evaluating active meshes on every frame
  93376. * @returns the current scene
  93377. */
  93378. unfreezeActiveMeshes(): Scene;
  93379. private _evaluateActiveMeshes;
  93380. private _activeMesh;
  93381. /**
  93382. * Update the transform matrix to update from the current active camera
  93383. * @param force defines a boolean used to force the update even if cache is up to date
  93384. */
  93385. updateTransformMatrix(force?: boolean): void;
  93386. private _bindFrameBuffer;
  93387. /** @hidden */
  93388. _allowPostProcessClearColor: boolean;
  93389. /** @hidden */
  93390. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  93391. private _processSubCameras;
  93392. private _checkIntersections;
  93393. /** @hidden */
  93394. _advancePhysicsEngineStep(step: number): void;
  93395. /**
  93396. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  93397. */
  93398. getDeterministicFrameTime: () => number;
  93399. /** @hidden */
  93400. _animate(): void;
  93401. /** Execute all animations (for a frame) */
  93402. animate(): void;
  93403. /**
  93404. * Render the scene
  93405. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  93406. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  93407. */
  93408. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  93409. /**
  93410. * Freeze all materials
  93411. * A frozen material will not be updatable but should be faster to render
  93412. */
  93413. freezeMaterials(): void;
  93414. /**
  93415. * Unfreeze all materials
  93416. * A frozen material will not be updatable but should be faster to render
  93417. */
  93418. unfreezeMaterials(): void;
  93419. /**
  93420. * Releases all held ressources
  93421. */
  93422. dispose(): void;
  93423. /**
  93424. * Gets if the scene is already disposed
  93425. */
  93426. readonly isDisposed: boolean;
  93427. /**
  93428. * Call this function to reduce memory footprint of the scene.
  93429. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  93430. */
  93431. clearCachedVertexData(): void;
  93432. /**
  93433. * This function will remove the local cached buffer data from texture.
  93434. * It will save memory but will prevent the texture from being rebuilt
  93435. */
  93436. cleanCachedTextureBuffer(): void;
  93437. /**
  93438. * Get the world extend vectors with an optional filter
  93439. *
  93440. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  93441. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  93442. */
  93443. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  93444. min: Vector3;
  93445. max: Vector3;
  93446. };
  93447. /**
  93448. * Creates a ray that can be used to pick in the scene
  93449. * @param x defines the x coordinate of the origin (on-screen)
  93450. * @param y defines the y coordinate of the origin (on-screen)
  93451. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93452. * @param camera defines the camera to use for the picking
  93453. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93454. * @returns a Ray
  93455. */
  93456. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  93457. /**
  93458. * Creates a ray that can be used to pick in the scene
  93459. * @param x defines the x coordinate of the origin (on-screen)
  93460. * @param y defines the y coordinate of the origin (on-screen)
  93461. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  93462. * @param result defines the ray where to store the picking ray
  93463. * @param camera defines the camera to use for the picking
  93464. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  93465. * @returns the current scene
  93466. */
  93467. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  93468. /**
  93469. * Creates a ray that can be used to pick in the scene
  93470. * @param x defines the x coordinate of the origin (on-screen)
  93471. * @param y defines the y coordinate of the origin (on-screen)
  93472. * @param camera defines the camera to use for the picking
  93473. * @returns a Ray
  93474. */
  93475. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  93476. /**
  93477. * Creates a ray that can be used to pick in the scene
  93478. * @param x defines the x coordinate of the origin (on-screen)
  93479. * @param y defines the y coordinate of the origin (on-screen)
  93480. * @param result defines the ray where to store the picking ray
  93481. * @param camera defines the camera to use for the picking
  93482. * @returns the current scene
  93483. */
  93484. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  93485. /** Launch a ray to try to pick a mesh in the scene
  93486. * @param x position on screen
  93487. * @param y position on screen
  93488. * @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
  93489. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  93490. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93492. * @returns a PickingInfo
  93493. */
  93494. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  93495. /** Use the given ray to pick a mesh in the scene
  93496. * @param ray The ray to use to pick meshes
  93497. * @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
  93498. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  93499. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93500. * @returns a PickingInfo
  93501. */
  93502. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  93503. /**
  93504. * Launch a ray to try to pick a mesh in the scene
  93505. * @param x X position on screen
  93506. * @param y Y position on screen
  93507. * @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
  93508. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  93509. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93510. * @returns an array of PickingInfo
  93511. */
  93512. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93513. /**
  93514. * Launch a ray to try to pick a mesh in the scene
  93515. * @param ray Ray to use
  93516. * @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
  93517. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93518. * @returns an array of PickingInfo
  93519. */
  93520. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93521. /**
  93522. * Force the value of meshUnderPointer
  93523. * @param mesh defines the mesh to use
  93524. */
  93525. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93526. /**
  93527. * Gets the mesh under the pointer
  93528. * @returns a Mesh or null if no mesh is under the pointer
  93529. */
  93530. getPointerOverMesh(): Nullable<AbstractMesh>;
  93531. /** @hidden */
  93532. _rebuildGeometries(): void;
  93533. /** @hidden */
  93534. _rebuildTextures(): void;
  93535. private _getByTags;
  93536. /**
  93537. * Get a list of meshes by tags
  93538. * @param tagsQuery defines the tags query to use
  93539. * @param forEach defines a predicate used to filter results
  93540. * @returns an array of Mesh
  93541. */
  93542. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93543. /**
  93544. * Get a list of cameras by tags
  93545. * @param tagsQuery defines the tags query to use
  93546. * @param forEach defines a predicate used to filter results
  93547. * @returns an array of Camera
  93548. */
  93549. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93550. /**
  93551. * Get a list of lights by tags
  93552. * @param tagsQuery defines the tags query to use
  93553. * @param forEach defines a predicate used to filter results
  93554. * @returns an array of Light
  93555. */
  93556. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93557. /**
  93558. * Get a list of materials by tags
  93559. * @param tagsQuery defines the tags query to use
  93560. * @param forEach defines a predicate used to filter results
  93561. * @returns an array of Material
  93562. */
  93563. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93564. /**
  93565. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93566. * This allowed control for front to back rendering or reversly depending of the special needs.
  93567. *
  93568. * @param renderingGroupId The rendering group id corresponding to its index
  93569. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93570. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93571. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93572. */
  93573. 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;
  93574. /**
  93575. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93576. *
  93577. * @param renderingGroupId The rendering group id corresponding to its index
  93578. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93579. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93580. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93581. */
  93582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93583. /**
  93584. * Gets the current auto clear configuration for one rendering group of the rendering
  93585. * manager.
  93586. * @param index the rendering group index to get the information for
  93587. * @returns The auto clear setup for the requested rendering group
  93588. */
  93589. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93590. private _blockMaterialDirtyMechanism;
  93591. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93592. blockMaterialDirtyMechanism: boolean;
  93593. /**
  93594. * Will flag all materials as dirty to trigger new shader compilation
  93595. * @param flag defines the flag used to specify which material part must be marked as dirty
  93596. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93597. */
  93598. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93599. /** @hidden */
  93600. _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;
  93601. /** @hidden */
  93602. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93603. }
  93604. }
  93605. declare module BABYLON {
  93606. /**
  93607. * Set of assets to keep when moving a scene into an asset container.
  93608. */
  93609. export class KeepAssets extends AbstractScene {
  93610. }
  93611. /**
  93612. * Container with a set of assets that can be added or removed from a scene.
  93613. */
  93614. export class AssetContainer extends AbstractScene {
  93615. /**
  93616. * The scene the AssetContainer belongs to.
  93617. */
  93618. scene: Scene;
  93619. /**
  93620. * Instantiates an AssetContainer.
  93621. * @param scene The scene the AssetContainer belongs to.
  93622. */
  93623. constructor(scene: Scene);
  93624. /**
  93625. * Adds all the assets from the container to the scene.
  93626. */
  93627. addAllToScene(): void;
  93628. /**
  93629. * Removes all the assets in the container from the scene
  93630. */
  93631. removeAllFromScene(): void;
  93632. /**
  93633. * Disposes all the assets in the container
  93634. */
  93635. dispose(): void;
  93636. private _moveAssets;
  93637. /**
  93638. * Removes all the assets contained in the scene and adds them to the container.
  93639. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93640. */
  93641. moveAllFromScene(keepAssets?: KeepAssets): void;
  93642. /**
  93643. * 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.
  93644. * @returns the root mesh
  93645. */
  93646. createRootMesh(): Mesh;
  93647. }
  93648. }
  93649. declare module BABYLON {
  93650. /**
  93651. * Defines how the parser contract is defined.
  93652. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93653. */
  93654. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93655. /**
  93656. * Defines how the individual parser contract is defined.
  93657. * These parser can parse an individual asset
  93658. */
  93659. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93660. /**
  93661. * Base class of the scene acting as a container for the different elements composing a scene.
  93662. * This class is dynamically extended by the different components of the scene increasing
  93663. * flexibility and reducing coupling
  93664. */
  93665. export abstract class AbstractScene {
  93666. /**
  93667. * Stores the list of available parsers in the application.
  93668. */
  93669. private static _BabylonFileParsers;
  93670. /**
  93671. * Stores the list of available individual parsers in the application.
  93672. */
  93673. private static _IndividualBabylonFileParsers;
  93674. /**
  93675. * Adds a parser in the list of available ones
  93676. * @param name Defines the name of the parser
  93677. * @param parser Defines the parser to add
  93678. */
  93679. static AddParser(name: string, parser: BabylonFileParser): void;
  93680. /**
  93681. * Gets a general parser from the list of avaialble ones
  93682. * @param name Defines the name of the parser
  93683. * @returns the requested parser or null
  93684. */
  93685. static GetParser(name: string): Nullable<BabylonFileParser>;
  93686. /**
  93687. * Adds n individual parser in the list of available ones
  93688. * @param name Defines the name of the parser
  93689. * @param parser Defines the parser to add
  93690. */
  93691. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93692. /**
  93693. * Gets an individual parser from the list of avaialble ones
  93694. * @param name Defines the name of the parser
  93695. * @returns the requested parser or null
  93696. */
  93697. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93698. /**
  93699. * Parser json data and populate both a scene and its associated container object
  93700. * @param jsonData Defines the data to parse
  93701. * @param scene Defines the scene to parse the data for
  93702. * @param container Defines the container attached to the parsing sequence
  93703. * @param rootUrl Defines the root url of the data
  93704. */
  93705. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93706. /**
  93707. * Gets the list of root nodes (ie. nodes with no parent)
  93708. */
  93709. rootNodes: Node[];
  93710. /** All of the cameras added to this scene
  93711. * @see http://doc.babylonjs.com/babylon101/cameras
  93712. */
  93713. cameras: Camera[];
  93714. /**
  93715. * All of the lights added to this scene
  93716. * @see http://doc.babylonjs.com/babylon101/lights
  93717. */
  93718. lights: Light[];
  93719. /**
  93720. * All of the (abstract) meshes added to this scene
  93721. */
  93722. meshes: AbstractMesh[];
  93723. /**
  93724. * The list of skeletons added to the scene
  93725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93726. */
  93727. skeletons: Skeleton[];
  93728. /**
  93729. * All of the particle systems added to this scene
  93730. * @see http://doc.babylonjs.com/babylon101/particles
  93731. */
  93732. particleSystems: IParticleSystem[];
  93733. /**
  93734. * Gets a list of Animations associated with the scene
  93735. */
  93736. animations: Animation[];
  93737. /**
  93738. * All of the animation groups added to this scene
  93739. * @see http://doc.babylonjs.com/how_to/group
  93740. */
  93741. animationGroups: AnimationGroup[];
  93742. /**
  93743. * All of the multi-materials added to this scene
  93744. * @see http://doc.babylonjs.com/how_to/multi_materials
  93745. */
  93746. multiMaterials: MultiMaterial[];
  93747. /**
  93748. * All of the materials added to this scene
  93749. * In the context of a Scene, it is not supposed to be modified manually.
  93750. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93751. * Note also that the order of the Material wihin the array is not significant and might change.
  93752. * @see http://doc.babylonjs.com/babylon101/materials
  93753. */
  93754. materials: Material[];
  93755. /**
  93756. * The list of morph target managers added to the scene
  93757. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93758. */
  93759. morphTargetManagers: MorphTargetManager[];
  93760. /**
  93761. * The list of geometries used in the scene.
  93762. */
  93763. geometries: Geometry[];
  93764. /**
  93765. * All of the tranform nodes added to this scene
  93766. * In the context of a Scene, it is not supposed to be modified manually.
  93767. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93768. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93769. * @see http://doc.babylonjs.com/how_to/transformnode
  93770. */
  93771. transformNodes: TransformNode[];
  93772. /**
  93773. * ActionManagers available on the scene.
  93774. */
  93775. actionManagers: AbstractActionManager[];
  93776. /**
  93777. * Textures to keep.
  93778. */
  93779. textures: BaseTexture[];
  93780. /**
  93781. * Environment texture for the scene
  93782. */
  93783. environmentTexture: Nullable<BaseTexture>;
  93784. }
  93785. }
  93786. declare module BABYLON {
  93787. /**
  93788. * Defines a sound that can be played in the application.
  93789. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93791. */
  93792. export class Sound {
  93793. /**
  93794. * The name of the sound in the scene.
  93795. */
  93796. name: string;
  93797. /**
  93798. * Does the sound autoplay once loaded.
  93799. */
  93800. autoplay: boolean;
  93801. /**
  93802. * Does the sound loop after it finishes playing once.
  93803. */
  93804. loop: boolean;
  93805. /**
  93806. * Does the sound use a custom attenuation curve to simulate the falloff
  93807. * happening when the source gets further away from the camera.
  93808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93809. */
  93810. useCustomAttenuation: boolean;
  93811. /**
  93812. * The sound track id this sound belongs to.
  93813. */
  93814. soundTrackId: number;
  93815. /**
  93816. * Is this sound currently played.
  93817. */
  93818. isPlaying: boolean;
  93819. /**
  93820. * Is this sound currently paused.
  93821. */
  93822. isPaused: boolean;
  93823. /**
  93824. * Does this sound enables spatial sound.
  93825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93826. */
  93827. spatialSound: boolean;
  93828. /**
  93829. * Define the reference distance the sound should be heard perfectly.
  93830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93831. */
  93832. refDistance: number;
  93833. /**
  93834. * Define the roll off factor of spatial sounds.
  93835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93836. */
  93837. rolloffFactor: number;
  93838. /**
  93839. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93841. */
  93842. maxDistance: number;
  93843. /**
  93844. * Define the distance attenuation model the sound will follow.
  93845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93846. */
  93847. distanceModel: string;
  93848. /**
  93849. * @hidden
  93850. * Back Compat
  93851. **/
  93852. onended: () => any;
  93853. /**
  93854. * Observable event when the current playing sound finishes.
  93855. */
  93856. onEndedObservable: Observable<Sound>;
  93857. private _panningModel;
  93858. private _playbackRate;
  93859. private _streaming;
  93860. private _startTime;
  93861. private _startOffset;
  93862. private _position;
  93863. /** @hidden */
  93864. _positionInEmitterSpace: boolean;
  93865. private _localDirection;
  93866. private _volume;
  93867. private _isReadyToPlay;
  93868. private _isDirectional;
  93869. private _readyToPlayCallback;
  93870. private _audioBuffer;
  93871. private _soundSource;
  93872. private _streamingSource;
  93873. private _soundPanner;
  93874. private _soundGain;
  93875. private _inputAudioNode;
  93876. private _outputAudioNode;
  93877. private _coneInnerAngle;
  93878. private _coneOuterAngle;
  93879. private _coneOuterGain;
  93880. private _scene;
  93881. private _connectedTransformNode;
  93882. private _customAttenuationFunction;
  93883. private _registerFunc;
  93884. private _isOutputConnected;
  93885. private _htmlAudioElement;
  93886. private _urlType;
  93887. /** @hidden */
  93888. static _SceneComponentInitialization: (scene: Scene) => void;
  93889. /**
  93890. * Create a sound and attach it to a scene
  93891. * @param name Name of your sound
  93892. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93893. * @param scene defines the scene the sound belongs to
  93894. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93895. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93896. */
  93897. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93898. /**
  93899. * Release the sound and its associated resources
  93900. */
  93901. dispose(): void;
  93902. /**
  93903. * Gets if the sounds is ready to be played or not.
  93904. * @returns true if ready, otherwise false
  93905. */
  93906. isReady(): boolean;
  93907. private _soundLoaded;
  93908. /**
  93909. * Sets the data of the sound from an audiobuffer
  93910. * @param audioBuffer The audioBuffer containing the data
  93911. */
  93912. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93913. /**
  93914. * Updates the current sounds options such as maxdistance, loop...
  93915. * @param options A JSON object containing values named as the object properties
  93916. */
  93917. updateOptions(options: any): void;
  93918. private _createSpatialParameters;
  93919. private _updateSpatialParameters;
  93920. /**
  93921. * Switch the panning model to HRTF:
  93922. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93924. */
  93925. switchPanningModelToHRTF(): void;
  93926. /**
  93927. * Switch the panning model to Equal Power:
  93928. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93930. */
  93931. switchPanningModelToEqualPower(): void;
  93932. private _switchPanningModel;
  93933. /**
  93934. * Connect this sound to a sound track audio node like gain...
  93935. * @param soundTrackAudioNode the sound track audio node to connect to
  93936. */
  93937. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93938. /**
  93939. * Transform this sound into a directional source
  93940. * @param coneInnerAngle Size of the inner cone in degree
  93941. * @param coneOuterAngle Size of the outer cone in degree
  93942. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93943. */
  93944. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93945. /**
  93946. * Gets or sets the inner angle for the directional cone.
  93947. */
  93948. /**
  93949. * Gets or sets the inner angle for the directional cone.
  93950. */
  93951. directionalConeInnerAngle: number;
  93952. /**
  93953. * Gets or sets the outer angle for the directional cone.
  93954. */
  93955. /**
  93956. * Gets or sets the outer angle for the directional cone.
  93957. */
  93958. directionalConeOuterAngle: number;
  93959. /**
  93960. * Sets the position of the emitter if spatial sound is enabled
  93961. * @param newPosition Defines the new posisiton
  93962. */
  93963. setPosition(newPosition: Vector3): void;
  93964. /**
  93965. * Sets the local direction of the emitter if spatial sound is enabled
  93966. * @param newLocalDirection Defines the new local direction
  93967. */
  93968. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93969. private _updateDirection;
  93970. /** @hidden */
  93971. updateDistanceFromListener(): void;
  93972. /**
  93973. * Sets a new custom attenuation function for the sound.
  93974. * @param callback Defines the function used for the attenuation
  93975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93976. */
  93977. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93978. /**
  93979. * Play the sound
  93980. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93981. * @param offset (optional) Start the sound setting it at a specific time
  93982. */
  93983. play(time?: number, offset?: number): void;
  93984. private _onended;
  93985. /**
  93986. * Stop the sound
  93987. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93988. */
  93989. stop(time?: number): void;
  93990. /**
  93991. * Put the sound in pause
  93992. */
  93993. pause(): void;
  93994. /**
  93995. * Sets a dedicated volume for this sounds
  93996. * @param newVolume Define the new volume of the sound
  93997. * @param time Define in how long the sound should be at this value
  93998. */
  93999. setVolume(newVolume: number, time?: number): void;
  94000. /**
  94001. * Set the sound play back rate
  94002. * @param newPlaybackRate Define the playback rate the sound should be played at
  94003. */
  94004. setPlaybackRate(newPlaybackRate: number): void;
  94005. /**
  94006. * Gets the volume of the sound.
  94007. * @returns the volume of the sound
  94008. */
  94009. getVolume(): number;
  94010. /**
  94011. * Attach the sound to a dedicated mesh
  94012. * @param transformNode The transform node to connect the sound with
  94013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94014. */
  94015. attachToMesh(transformNode: TransformNode): void;
  94016. /**
  94017. * Detach the sound from the previously attached mesh
  94018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  94019. */
  94020. detachFromMesh(): void;
  94021. private _onRegisterAfterWorldMatrixUpdate;
  94022. /**
  94023. * Clone the current sound in the scene.
  94024. * @returns the new sound clone
  94025. */
  94026. clone(): Nullable<Sound>;
  94027. /**
  94028. * Gets the current underlying audio buffer containing the data
  94029. * @returns the audio buffer
  94030. */
  94031. getAudioBuffer(): Nullable<AudioBuffer>;
  94032. /**
  94033. * Serializes the Sound in a JSON representation
  94034. * @returns the JSON representation of the sound
  94035. */
  94036. serialize(): any;
  94037. /**
  94038. * Parse a JSON representation of a sound to innstantiate in a given scene
  94039. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  94040. * @param scene Define the scene the new parsed sound should be created in
  94041. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  94042. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  94043. * @returns the newly parsed sound
  94044. */
  94045. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  94046. }
  94047. }
  94048. declare module BABYLON {
  94049. /**
  94050. * This defines an action helpful to play a defined sound on a triggered action.
  94051. */
  94052. export class PlaySoundAction extends Action {
  94053. private _sound;
  94054. /**
  94055. * Instantiate the action
  94056. * @param triggerOptions defines the trigger options
  94057. * @param sound defines the sound to play
  94058. * @param condition defines the trigger related conditions
  94059. */
  94060. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94061. /** @hidden */
  94062. _prepare(): void;
  94063. /**
  94064. * Execute the action and play the sound.
  94065. */
  94066. execute(): void;
  94067. /**
  94068. * Serializes the actions and its related information.
  94069. * @param parent defines the object to serialize in
  94070. * @returns the serialized object
  94071. */
  94072. serialize(parent: any): any;
  94073. }
  94074. /**
  94075. * This defines an action helpful to stop a defined sound on a triggered action.
  94076. */
  94077. export class StopSoundAction extends Action {
  94078. private _sound;
  94079. /**
  94080. * Instantiate the action
  94081. * @param triggerOptions defines the trigger options
  94082. * @param sound defines the sound to stop
  94083. * @param condition defines the trigger related conditions
  94084. */
  94085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  94086. /** @hidden */
  94087. _prepare(): void;
  94088. /**
  94089. * Execute the action and stop the sound.
  94090. */
  94091. execute(): void;
  94092. /**
  94093. * Serializes the actions and its related information.
  94094. * @param parent defines the object to serialize in
  94095. * @returns the serialized object
  94096. */
  94097. serialize(parent: any): any;
  94098. }
  94099. }
  94100. declare module BABYLON {
  94101. /**
  94102. * This defines an action responsible to change the value of a property
  94103. * by interpolating between its current value and the newly set one once triggered.
  94104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94105. */
  94106. export class InterpolateValueAction extends Action {
  94107. /**
  94108. * Defines the path of the property where the value should be interpolated
  94109. */
  94110. propertyPath: string;
  94111. /**
  94112. * Defines the target value at the end of the interpolation.
  94113. */
  94114. value: any;
  94115. /**
  94116. * Defines the time it will take for the property to interpolate to the value.
  94117. */
  94118. duration: number;
  94119. /**
  94120. * Defines if the other scene animations should be stopped when the action has been triggered
  94121. */
  94122. stopOtherAnimations?: boolean;
  94123. /**
  94124. * Defines a callback raised once the interpolation animation has been done.
  94125. */
  94126. onInterpolationDone?: () => void;
  94127. /**
  94128. * Observable triggered once the interpolation animation has been done.
  94129. */
  94130. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  94131. private _target;
  94132. private _effectiveTarget;
  94133. private _property;
  94134. /**
  94135. * Instantiate the action
  94136. * @param triggerOptions defines the trigger options
  94137. * @param target defines the object containing the value to interpolate
  94138. * @param propertyPath defines the path to the property in the target object
  94139. * @param value defines the target value at the end of the interpolation
  94140. * @param duration deines the time it will take for the property to interpolate to the value.
  94141. * @param condition defines the trigger related conditions
  94142. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  94143. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  94144. */
  94145. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  94146. /** @hidden */
  94147. _prepare(): void;
  94148. /**
  94149. * Execute the action starts the value interpolation.
  94150. */
  94151. execute(): void;
  94152. /**
  94153. * Serializes the actions and its related information.
  94154. * @param parent defines the object to serialize in
  94155. * @returns the serialized object
  94156. */
  94157. serialize(parent: any): any;
  94158. }
  94159. }
  94160. declare module BABYLON {
  94161. /**
  94162. * Options allowed during the creation of a sound track.
  94163. */
  94164. export interface ISoundTrackOptions {
  94165. /**
  94166. * The volume the sound track should take during creation
  94167. */
  94168. volume?: number;
  94169. /**
  94170. * Define if the sound track is the main sound track of the scene
  94171. */
  94172. mainTrack?: boolean;
  94173. }
  94174. /**
  94175. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  94176. * It will be also used in a future release to apply effects on a specific track.
  94177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94178. */
  94179. export class SoundTrack {
  94180. /**
  94181. * The unique identifier of the sound track in the scene.
  94182. */
  94183. id: number;
  94184. /**
  94185. * The list of sounds included in the sound track.
  94186. */
  94187. soundCollection: Array<Sound>;
  94188. private _outputAudioNode;
  94189. private _scene;
  94190. private _isMainTrack;
  94191. private _connectedAnalyser;
  94192. private _options;
  94193. private _isInitialized;
  94194. /**
  94195. * Creates a new sound track.
  94196. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  94197. * @param scene Define the scene the sound track belongs to
  94198. * @param options
  94199. */
  94200. constructor(scene: Scene, options?: ISoundTrackOptions);
  94201. private _initializeSoundTrackAudioGraph;
  94202. /**
  94203. * Release the sound track and its associated resources
  94204. */
  94205. dispose(): void;
  94206. /**
  94207. * Adds a sound to this sound track
  94208. * @param sound define the cound to add
  94209. * @ignoreNaming
  94210. */
  94211. AddSound(sound: Sound): void;
  94212. /**
  94213. * Removes a sound to this sound track
  94214. * @param sound define the cound to remove
  94215. * @ignoreNaming
  94216. */
  94217. RemoveSound(sound: Sound): void;
  94218. /**
  94219. * Set a global volume for the full sound track.
  94220. * @param newVolume Define the new volume of the sound track
  94221. */
  94222. setVolume(newVolume: number): void;
  94223. /**
  94224. * Switch the panning model to HRTF:
  94225. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  94226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94227. */
  94228. switchPanningModelToHRTF(): void;
  94229. /**
  94230. * Switch the panning model to Equal Power:
  94231. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  94232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  94233. */
  94234. switchPanningModelToEqualPower(): void;
  94235. /**
  94236. * Connect the sound track to an audio analyser allowing some amazing
  94237. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94239. * @param analyser The analyser to connect to the engine
  94240. */
  94241. connectToAnalyser(analyser: Analyser): void;
  94242. }
  94243. }
  94244. declare module BABYLON {
  94245. interface AbstractScene {
  94246. /**
  94247. * The list of sounds used in the scene.
  94248. */
  94249. sounds: Nullable<Array<Sound>>;
  94250. }
  94251. interface Scene {
  94252. /**
  94253. * @hidden
  94254. * Backing field
  94255. */
  94256. _mainSoundTrack: SoundTrack;
  94257. /**
  94258. * The main sound track played by the scene.
  94259. * It cotains your primary collection of sounds.
  94260. */
  94261. mainSoundTrack: SoundTrack;
  94262. /**
  94263. * The list of sound tracks added to the scene
  94264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94265. */
  94266. soundTracks: Nullable<Array<SoundTrack>>;
  94267. /**
  94268. * Gets a sound using a given name
  94269. * @param name defines the name to search for
  94270. * @return the found sound or null if not found at all.
  94271. */
  94272. getSoundByName(name: string): Nullable<Sound>;
  94273. /**
  94274. * Gets or sets if audio support is enabled
  94275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94276. */
  94277. audioEnabled: boolean;
  94278. /**
  94279. * Gets or sets if audio will be output to headphones
  94280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94281. */
  94282. headphone: boolean;
  94283. }
  94284. /**
  94285. * Defines the sound scene component responsible to manage any sounds
  94286. * in a given scene.
  94287. */
  94288. export class AudioSceneComponent implements ISceneSerializableComponent {
  94289. /**
  94290. * The component name helpfull to identify the component in the list of scene components.
  94291. */
  94292. readonly name: string;
  94293. /**
  94294. * The scene the component belongs to.
  94295. */
  94296. scene: Scene;
  94297. private _audioEnabled;
  94298. /**
  94299. * Gets whether audio is enabled or not.
  94300. * Please use related enable/disable method to switch state.
  94301. */
  94302. readonly audioEnabled: boolean;
  94303. private _headphone;
  94304. /**
  94305. * Gets whether audio is outputing to headphone or not.
  94306. * Please use the according Switch methods to change output.
  94307. */
  94308. readonly headphone: boolean;
  94309. /**
  94310. * Creates a new instance of the component for the given scene
  94311. * @param scene Defines the scene to register the component in
  94312. */
  94313. constructor(scene: Scene);
  94314. /**
  94315. * Registers the component in a given scene
  94316. */
  94317. register(): void;
  94318. /**
  94319. * Rebuilds the elements related to this component in case of
  94320. * context lost for instance.
  94321. */
  94322. rebuild(): void;
  94323. /**
  94324. * Serializes the component data to the specified json object
  94325. * @param serializationObject The object to serialize to
  94326. */
  94327. serialize(serializationObject: any): void;
  94328. /**
  94329. * Adds all the element from the container to the scene
  94330. * @param container the container holding the elements
  94331. */
  94332. addFromContainer(container: AbstractScene): void;
  94333. /**
  94334. * Removes all the elements in the container from the scene
  94335. * @param container contains the elements to remove
  94336. * @param dispose if the removed element should be disposed (default: false)
  94337. */
  94338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  94339. /**
  94340. * Disposes the component and the associated ressources.
  94341. */
  94342. dispose(): void;
  94343. /**
  94344. * Disables audio in the associated scene.
  94345. */
  94346. disableAudio(): void;
  94347. /**
  94348. * Enables audio in the associated scene.
  94349. */
  94350. enableAudio(): void;
  94351. /**
  94352. * Switch audio to headphone output.
  94353. */
  94354. switchAudioModeForHeadphones(): void;
  94355. /**
  94356. * Switch audio to normal speakers.
  94357. */
  94358. switchAudioModeForNormalSpeakers(): void;
  94359. private _afterRender;
  94360. }
  94361. }
  94362. declare module BABYLON {
  94363. /**
  94364. * Wraps one or more Sound objects and selects one with random weight for playback.
  94365. */
  94366. export class WeightedSound {
  94367. /** When true a Sound will be selected and played when the current playing Sound completes. */
  94368. loop: boolean;
  94369. private _coneInnerAngle;
  94370. private _coneOuterAngle;
  94371. private _volume;
  94372. /** A Sound is currently playing. */
  94373. isPlaying: boolean;
  94374. /** A Sound is currently paused. */
  94375. isPaused: boolean;
  94376. private _sounds;
  94377. private _weights;
  94378. private _currentIndex?;
  94379. /**
  94380. * Creates a new WeightedSound from the list of sounds given.
  94381. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  94382. * @param sounds Array of Sounds that will be selected from.
  94383. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  94384. */
  94385. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  94386. /**
  94387. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  94388. */
  94389. /**
  94390. * The size of cone in degress for a directional sound in which there will be no attenuation.
  94391. */
  94392. directionalConeInnerAngle: number;
  94393. /**
  94394. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94395. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94396. */
  94397. /**
  94398. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  94399. * Listener angles between innerAngle and outerAngle will falloff linearly.
  94400. */
  94401. directionalConeOuterAngle: number;
  94402. /**
  94403. * Playback volume.
  94404. */
  94405. /**
  94406. * Playback volume.
  94407. */
  94408. volume: number;
  94409. private _onended;
  94410. /**
  94411. * Suspend playback
  94412. */
  94413. pause(): void;
  94414. /**
  94415. * Stop playback
  94416. */
  94417. stop(): void;
  94418. /**
  94419. * Start playback.
  94420. * @param startOffset Position the clip head at a specific time in seconds.
  94421. */
  94422. play(startOffset?: number): void;
  94423. }
  94424. }
  94425. declare module BABYLON {
  94426. /**
  94427. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  94428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94429. */
  94430. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  94431. /**
  94432. * Gets the name of the behavior.
  94433. */
  94434. readonly name: string;
  94435. /**
  94436. * The easing function used by animations
  94437. */
  94438. static EasingFunction: BackEase;
  94439. /**
  94440. * The easing mode used by animations
  94441. */
  94442. static EasingMode: number;
  94443. /**
  94444. * The duration of the animation, in milliseconds
  94445. */
  94446. transitionDuration: number;
  94447. /**
  94448. * Length of the distance animated by the transition when lower radius is reached
  94449. */
  94450. lowerRadiusTransitionRange: number;
  94451. /**
  94452. * Length of the distance animated by the transition when upper radius is reached
  94453. */
  94454. upperRadiusTransitionRange: number;
  94455. private _autoTransitionRange;
  94456. /**
  94457. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94458. */
  94459. /**
  94460. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  94461. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  94462. */
  94463. autoTransitionRange: boolean;
  94464. private _attachedCamera;
  94465. private _onAfterCheckInputsObserver;
  94466. private _onMeshTargetChangedObserver;
  94467. /**
  94468. * Initializes the behavior.
  94469. */
  94470. init(): void;
  94471. /**
  94472. * Attaches the behavior to its arc rotate camera.
  94473. * @param camera Defines the camera to attach the behavior to
  94474. */
  94475. attach(camera: ArcRotateCamera): void;
  94476. /**
  94477. * Detaches the behavior from its current arc rotate camera.
  94478. */
  94479. detach(): void;
  94480. private _radiusIsAnimating;
  94481. private _radiusBounceTransition;
  94482. private _animatables;
  94483. private _cachedWheelPrecision;
  94484. /**
  94485. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  94486. * @param radiusLimit The limit to check against.
  94487. * @return Bool to indicate if at limit.
  94488. */
  94489. private _isRadiusAtLimit;
  94490. /**
  94491. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  94492. * @param radiusDelta The delta by which to animate to. Can be negative.
  94493. */
  94494. private _applyBoundRadiusAnimation;
  94495. /**
  94496. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  94497. */
  94498. protected _clearAnimationLocks(): void;
  94499. /**
  94500. * Stops and removes all animations that have been applied to the camera
  94501. */
  94502. stopAllAnimations(): void;
  94503. }
  94504. }
  94505. declare module BABYLON {
  94506. /**
  94507. * 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.
  94508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94509. */
  94510. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  94511. /**
  94512. * Gets the name of the behavior.
  94513. */
  94514. readonly name: string;
  94515. private _mode;
  94516. private _radiusScale;
  94517. private _positionScale;
  94518. private _defaultElevation;
  94519. private _elevationReturnTime;
  94520. private _elevationReturnWaitTime;
  94521. private _zoomStopsAnimation;
  94522. private _framingTime;
  94523. /**
  94524. * The easing function used by animations
  94525. */
  94526. static EasingFunction: ExponentialEase;
  94527. /**
  94528. * The easing mode used by animations
  94529. */
  94530. static EasingMode: number;
  94531. /**
  94532. * Sets the current mode used by the behavior
  94533. */
  94534. /**
  94535. * Gets current mode used by the behavior.
  94536. */
  94537. mode: number;
  94538. /**
  94539. * Sets the scale applied to the radius (1 by default)
  94540. */
  94541. /**
  94542. * Gets the scale applied to the radius
  94543. */
  94544. radiusScale: number;
  94545. /**
  94546. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94547. */
  94548. /**
  94549. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94550. */
  94551. positionScale: number;
  94552. /**
  94553. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94554. * behaviour is triggered, in radians.
  94555. */
  94556. /**
  94557. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94558. * behaviour is triggered, in radians.
  94559. */
  94560. defaultElevation: number;
  94561. /**
  94562. * Sets the time (in milliseconds) taken to return to the default beta position.
  94563. * Negative value indicates camera should not return to default.
  94564. */
  94565. /**
  94566. * Gets the time (in milliseconds) taken to return to the default beta position.
  94567. * Negative value indicates camera should not return to default.
  94568. */
  94569. elevationReturnTime: number;
  94570. /**
  94571. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94572. */
  94573. /**
  94574. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94575. */
  94576. elevationReturnWaitTime: number;
  94577. /**
  94578. * Sets the flag that indicates if user zooming should stop animation.
  94579. */
  94580. /**
  94581. * Gets the flag that indicates if user zooming should stop animation.
  94582. */
  94583. zoomStopsAnimation: boolean;
  94584. /**
  94585. * Sets the transition time when framing the mesh, in milliseconds
  94586. */
  94587. /**
  94588. * Gets the transition time when framing the mesh, in milliseconds
  94589. */
  94590. framingTime: number;
  94591. /**
  94592. * Define if the behavior should automatically change the configured
  94593. * camera limits and sensibilities.
  94594. */
  94595. autoCorrectCameraLimitsAndSensibility: boolean;
  94596. private _onPrePointerObservableObserver;
  94597. private _onAfterCheckInputsObserver;
  94598. private _onMeshTargetChangedObserver;
  94599. private _attachedCamera;
  94600. private _isPointerDown;
  94601. private _lastInteractionTime;
  94602. /**
  94603. * Initializes the behavior.
  94604. */
  94605. init(): void;
  94606. /**
  94607. * Attaches the behavior to its arc rotate camera.
  94608. * @param camera Defines the camera to attach the behavior to
  94609. */
  94610. attach(camera: ArcRotateCamera): void;
  94611. /**
  94612. * Detaches the behavior from its current arc rotate camera.
  94613. */
  94614. detach(): void;
  94615. private _animatables;
  94616. private _betaIsAnimating;
  94617. private _betaTransition;
  94618. private _radiusTransition;
  94619. private _vectorTransition;
  94620. /**
  94621. * Targets the given mesh and updates zoom level accordingly.
  94622. * @param mesh The mesh to target.
  94623. * @param radius Optional. If a cached radius position already exists, overrides default.
  94624. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94627. */
  94628. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94629. /**
  94630. * Targets the given mesh with its children and updates zoom level accordingly.
  94631. * @param mesh The mesh to target.
  94632. * @param radius Optional. If a cached radius position already exists, overrides default.
  94633. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94634. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94635. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94636. */
  94637. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94638. /**
  94639. * Targets the given meshes with their children and updates zoom level accordingly.
  94640. * @param meshes The mesh to target.
  94641. * @param radius Optional. If a cached radius position already exists, overrides default.
  94642. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94643. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94644. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94645. */
  94646. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94647. /**
  94648. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94649. * @param minimumWorld Determines the smaller position of the bounding box extend
  94650. * @param maximumWorld Determines the bigger position of the bounding box extend
  94651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94653. */
  94654. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94655. /**
  94656. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94657. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94658. * frustum width.
  94659. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94660. * to fully enclose the mesh in the viewing frustum.
  94661. */
  94662. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94663. /**
  94664. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94665. * is automatically returned to its default position (expected to be above ground plane).
  94666. */
  94667. private _maintainCameraAboveGround;
  94668. /**
  94669. * Returns the frustum slope based on the canvas ratio and camera FOV
  94670. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94671. */
  94672. private _getFrustumSlope;
  94673. /**
  94674. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94675. */
  94676. private _clearAnimationLocks;
  94677. /**
  94678. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94679. */
  94680. private _applyUserInteraction;
  94681. /**
  94682. * Stops and removes all animations that have been applied to the camera
  94683. */
  94684. stopAllAnimations(): void;
  94685. /**
  94686. * Gets a value indicating if the user is moving the camera
  94687. */
  94688. readonly isUserIsMoving: boolean;
  94689. /**
  94690. * The camera can move all the way towards the mesh.
  94691. */
  94692. static IgnoreBoundsSizeMode: number;
  94693. /**
  94694. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94695. */
  94696. static FitFrustumSidesMode: number;
  94697. }
  94698. }
  94699. declare module BABYLON {
  94700. /**
  94701. * Base class for Camera Pointer Inputs.
  94702. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94703. * for example usage.
  94704. */
  94705. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94706. /**
  94707. * Defines the camera the input is attached to.
  94708. */
  94709. abstract camera: Camera;
  94710. /**
  94711. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94712. */
  94713. protected _altKey: boolean;
  94714. protected _ctrlKey: boolean;
  94715. protected _metaKey: boolean;
  94716. protected _shiftKey: boolean;
  94717. /**
  94718. * Which mouse buttons were pressed at time of last mouse event.
  94719. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94720. */
  94721. protected _buttonsPressed: number;
  94722. /**
  94723. * Defines the buttons associated with the input to handle camera move.
  94724. */
  94725. buttons: number[];
  94726. /**
  94727. * Attach the input controls to a specific dom element to get the input from.
  94728. * @param element Defines the element the controls should be listened from
  94729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94730. */
  94731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94732. /**
  94733. * Detach the current controls from the specified dom element.
  94734. * @param element Defines the element to stop listening the inputs from
  94735. */
  94736. detachControl(element: Nullable<HTMLElement>): void;
  94737. /**
  94738. * Gets the class name of the current input.
  94739. * @returns the class name
  94740. */
  94741. getClassName(): string;
  94742. /**
  94743. * Get the friendly name associated with the input class.
  94744. * @returns the input friendly name
  94745. */
  94746. getSimpleName(): string;
  94747. /**
  94748. * Called on pointer POINTERDOUBLETAP event.
  94749. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94750. */
  94751. protected onDoubleTap(type: string): void;
  94752. /**
  94753. * Called on pointer POINTERMOVE event if only a single touch is active.
  94754. * Override this method to provide functionality.
  94755. */
  94756. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94757. /**
  94758. * Called on pointer POINTERMOVE event if multiple touches are active.
  94759. * Override this method to provide functionality.
  94760. */
  94761. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94762. /**
  94763. * Called on JS contextmenu event.
  94764. * Override this method to provide functionality.
  94765. */
  94766. protected onContextMenu(evt: PointerEvent): void;
  94767. /**
  94768. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94769. * press.
  94770. * Override this method to provide functionality.
  94771. */
  94772. protected onButtonDown(evt: PointerEvent): void;
  94773. /**
  94774. * Called each time a new POINTERUP event occurs. Ie, for each button
  94775. * release.
  94776. * Override this method to provide functionality.
  94777. */
  94778. protected onButtonUp(evt: PointerEvent): void;
  94779. /**
  94780. * Called when window becomes inactive.
  94781. * Override this method to provide functionality.
  94782. */
  94783. protected onLostFocus(): void;
  94784. private _pointerInput;
  94785. private _observer;
  94786. private _onLostFocus;
  94787. private pointA;
  94788. private pointB;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * Manage the pointers inputs to control an arc rotate camera.
  94794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94795. */
  94796. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94797. /**
  94798. * Defines the camera the input is attached to.
  94799. */
  94800. camera: ArcRotateCamera;
  94801. /**
  94802. * Gets the class name of the current input.
  94803. * @returns the class name
  94804. */
  94805. getClassName(): string;
  94806. /**
  94807. * Defines the buttons associated with the input to handle camera move.
  94808. */
  94809. buttons: number[];
  94810. /**
  94811. * Defines the pointer angular sensibility along the X axis or how fast is
  94812. * the camera rotating.
  94813. */
  94814. angularSensibilityX: number;
  94815. /**
  94816. * Defines the pointer angular sensibility along the Y axis or how fast is
  94817. * the camera rotating.
  94818. */
  94819. angularSensibilityY: number;
  94820. /**
  94821. * Defines the pointer pinch precision or how fast is the camera zooming.
  94822. */
  94823. pinchPrecision: number;
  94824. /**
  94825. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94826. * from 0.
  94827. * It defines the percentage of current camera.radius to use as delta when
  94828. * pinch zoom is used.
  94829. */
  94830. pinchDeltaPercentage: number;
  94831. /**
  94832. * Defines the pointer panning sensibility or how fast is the camera moving.
  94833. */
  94834. panningSensibility: number;
  94835. /**
  94836. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94837. */
  94838. multiTouchPanning: boolean;
  94839. /**
  94840. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94841. * zoom (pinch) through multitouch.
  94842. */
  94843. multiTouchPanAndZoom: boolean;
  94844. /**
  94845. * Revers pinch action direction.
  94846. */
  94847. pinchInwards: boolean;
  94848. private _isPanClick;
  94849. private _twoFingerActivityCount;
  94850. private _isPinching;
  94851. /**
  94852. * Called on pointer POINTERMOVE event if only a single touch is active.
  94853. */
  94854. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94855. /**
  94856. * Called on pointer POINTERDOUBLETAP event.
  94857. */
  94858. protected onDoubleTap(type: string): void;
  94859. /**
  94860. * Called on pointer POINTERMOVE event if multiple touches are active.
  94861. */
  94862. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94863. /**
  94864. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94865. * press.
  94866. */
  94867. protected onButtonDown(evt: PointerEvent): void;
  94868. /**
  94869. * Called each time a new POINTERUP event occurs. Ie, for each button
  94870. * release.
  94871. */
  94872. protected onButtonUp(evt: PointerEvent): void;
  94873. /**
  94874. * Called when window becomes inactive.
  94875. */
  94876. protected onLostFocus(): void;
  94877. }
  94878. }
  94879. declare module BABYLON {
  94880. /**
  94881. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94883. */
  94884. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94885. /**
  94886. * Defines the camera the input is attached to.
  94887. */
  94888. camera: ArcRotateCamera;
  94889. /**
  94890. * Defines the list of key codes associated with the up action (increase alpha)
  94891. */
  94892. keysUp: number[];
  94893. /**
  94894. * Defines the list of key codes associated with the down action (decrease alpha)
  94895. */
  94896. keysDown: number[];
  94897. /**
  94898. * Defines the list of key codes associated with the left action (increase beta)
  94899. */
  94900. keysLeft: number[];
  94901. /**
  94902. * Defines the list of key codes associated with the right action (decrease beta)
  94903. */
  94904. keysRight: number[];
  94905. /**
  94906. * Defines the list of key codes associated with the reset action.
  94907. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94908. */
  94909. keysReset: number[];
  94910. /**
  94911. * Defines the panning sensibility of the inputs.
  94912. * (How fast is the camera paning)
  94913. */
  94914. panningSensibility: number;
  94915. /**
  94916. * Defines the zooming sensibility of the inputs.
  94917. * (How fast is the camera zooming)
  94918. */
  94919. zoomingSensibility: number;
  94920. /**
  94921. * Defines wether maintaining the alt key down switch the movement mode from
  94922. * orientation to zoom.
  94923. */
  94924. useAltToZoom: boolean;
  94925. /**
  94926. * Rotation speed of the camera
  94927. */
  94928. angularSpeed: number;
  94929. private _keys;
  94930. private _ctrlPressed;
  94931. private _altPressed;
  94932. private _onCanvasBlurObserver;
  94933. private _onKeyboardObserver;
  94934. private _engine;
  94935. private _scene;
  94936. /**
  94937. * Attach the input controls to a specific dom element to get the input from.
  94938. * @param element Defines the element the controls should be listened from
  94939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94940. */
  94941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94942. /**
  94943. * Detach the current controls from the specified dom element.
  94944. * @param element Defines the element to stop listening the inputs from
  94945. */
  94946. detachControl(element: Nullable<HTMLElement>): void;
  94947. /**
  94948. * Update the current camera state depending on the inputs that have been used this frame.
  94949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94950. */
  94951. checkInputs(): void;
  94952. /**
  94953. * Gets the class name of the current intput.
  94954. * @returns the class name
  94955. */
  94956. getClassName(): string;
  94957. /**
  94958. * Get the friendly name associated with the input class.
  94959. * @returns the input friendly name
  94960. */
  94961. getSimpleName(): string;
  94962. }
  94963. }
  94964. declare module BABYLON {
  94965. /**
  94966. * Manage the mouse wheel inputs to control an arc rotate camera.
  94967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94968. */
  94969. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94970. /**
  94971. * Defines the camera the input is attached to.
  94972. */
  94973. camera: ArcRotateCamera;
  94974. /**
  94975. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94976. */
  94977. wheelPrecision: number;
  94978. /**
  94979. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94980. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94981. */
  94982. wheelDeltaPercentage: number;
  94983. private _wheel;
  94984. private _observer;
  94985. /**
  94986. * Attach the input controls to a specific dom element to get the input from.
  94987. * @param element Defines the element the controls should be listened from
  94988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94989. */
  94990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94991. /**
  94992. * Detach the current controls from the specified dom element.
  94993. * @param element Defines the element to stop listening the inputs from
  94994. */
  94995. detachControl(element: Nullable<HTMLElement>): void;
  94996. /**
  94997. * Gets the class name of the current intput.
  94998. * @returns the class name
  94999. */
  95000. getClassName(): string;
  95001. /**
  95002. * Get the friendly name associated with the input class.
  95003. * @returns the input friendly name
  95004. */
  95005. getSimpleName(): string;
  95006. }
  95007. }
  95008. declare module BABYLON {
  95009. /**
  95010. * Default Inputs manager for the ArcRotateCamera.
  95011. * It groups all the default supported inputs for ease of use.
  95012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95013. */
  95014. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  95015. /**
  95016. * Instantiates a new ArcRotateCameraInputsManager.
  95017. * @param camera Defines the camera the inputs belong to
  95018. */
  95019. constructor(camera: ArcRotateCamera);
  95020. /**
  95021. * Add mouse wheel input support to the input manager.
  95022. * @returns the current input manager
  95023. */
  95024. addMouseWheel(): ArcRotateCameraInputsManager;
  95025. /**
  95026. * Add pointers input support to the input manager.
  95027. * @returns the current input manager
  95028. */
  95029. addPointers(): ArcRotateCameraInputsManager;
  95030. /**
  95031. * Add keyboard input support to the input manager.
  95032. * @returns the current input manager
  95033. */
  95034. addKeyboard(): ArcRotateCameraInputsManager;
  95035. }
  95036. }
  95037. declare module BABYLON {
  95038. /**
  95039. * This represents an orbital type of camera.
  95040. *
  95041. * 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.
  95042. * 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.
  95043. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  95044. */
  95045. export class ArcRotateCamera extends TargetCamera {
  95046. /**
  95047. * Defines the rotation angle of the camera along the longitudinal axis.
  95048. */
  95049. alpha: number;
  95050. /**
  95051. * Defines the rotation angle of the camera along the latitudinal axis.
  95052. */
  95053. beta: number;
  95054. /**
  95055. * Defines the radius of the camera from it s target point.
  95056. */
  95057. radius: number;
  95058. protected _target: Vector3;
  95059. protected _targetHost: Nullable<AbstractMesh>;
  95060. /**
  95061. * Defines the target point of the camera.
  95062. * The camera looks towards it form the radius distance.
  95063. */
  95064. target: Vector3;
  95065. /**
  95066. * Define the current local position of the camera in the scene
  95067. */
  95068. position: Vector3;
  95069. protected _upVector: Vector3;
  95070. protected _upToYMatrix: Matrix;
  95071. protected _YToUpMatrix: Matrix;
  95072. /**
  95073. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  95074. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  95075. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  95076. */
  95077. upVector: Vector3;
  95078. /**
  95079. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  95080. */
  95081. setMatUp(): void;
  95082. /**
  95083. * Current inertia value on the longitudinal axis.
  95084. * The bigger this number the longer it will take for the camera to stop.
  95085. */
  95086. inertialAlphaOffset: number;
  95087. /**
  95088. * Current inertia value on the latitudinal axis.
  95089. * The bigger this number the longer it will take for the camera to stop.
  95090. */
  95091. inertialBetaOffset: number;
  95092. /**
  95093. * Current inertia value on the radius axis.
  95094. * The bigger this number the longer it will take for the camera to stop.
  95095. */
  95096. inertialRadiusOffset: number;
  95097. /**
  95098. * Minimum allowed angle on the longitudinal axis.
  95099. * This can help limiting how the Camera is able to move in the scene.
  95100. */
  95101. lowerAlphaLimit: Nullable<number>;
  95102. /**
  95103. * Maximum allowed angle on the longitudinal axis.
  95104. * This can help limiting how the Camera is able to move in the scene.
  95105. */
  95106. upperAlphaLimit: Nullable<number>;
  95107. /**
  95108. * Minimum allowed angle on the latitudinal axis.
  95109. * This can help limiting how the Camera is able to move in the scene.
  95110. */
  95111. lowerBetaLimit: number;
  95112. /**
  95113. * Maximum allowed angle on the latitudinal axis.
  95114. * This can help limiting how the Camera is able to move in the scene.
  95115. */
  95116. upperBetaLimit: number;
  95117. /**
  95118. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  95119. * This can help limiting how the Camera is able to move in the scene.
  95120. */
  95121. lowerRadiusLimit: Nullable<number>;
  95122. /**
  95123. * Maximum allowed distance of the camera to the target (The camera can not get further).
  95124. * This can help limiting how the Camera is able to move in the scene.
  95125. */
  95126. upperRadiusLimit: Nullable<number>;
  95127. /**
  95128. * Defines the current inertia value used during panning of the camera along the X axis.
  95129. */
  95130. inertialPanningX: number;
  95131. /**
  95132. * Defines the current inertia value used during panning of the camera along the Y axis.
  95133. */
  95134. inertialPanningY: number;
  95135. /**
  95136. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  95137. * Basically if your fingers moves away from more than this distance you will be considered
  95138. * in pinch mode.
  95139. */
  95140. pinchToPanMaxDistance: number;
  95141. /**
  95142. * Defines the maximum distance the camera can pan.
  95143. * This could help keeping the cammera always in your scene.
  95144. */
  95145. panningDistanceLimit: Nullable<number>;
  95146. /**
  95147. * Defines the target of the camera before paning.
  95148. */
  95149. panningOriginTarget: Vector3;
  95150. /**
  95151. * Defines the value of the inertia used during panning.
  95152. * 0 would mean stop inertia and one would mean no decelleration at all.
  95153. */
  95154. panningInertia: number;
  95155. /**
  95156. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  95157. */
  95158. angularSensibilityX: number;
  95159. /**
  95160. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  95161. */
  95162. angularSensibilityY: number;
  95163. /**
  95164. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  95165. */
  95166. pinchPrecision: number;
  95167. /**
  95168. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  95169. * It will be used instead of pinchDeltaPrecision if different from 0.
  95170. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95171. */
  95172. pinchDeltaPercentage: number;
  95173. /**
  95174. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  95175. */
  95176. panningSensibility: number;
  95177. /**
  95178. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  95179. */
  95180. keysUp: number[];
  95181. /**
  95182. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  95183. */
  95184. keysDown: number[];
  95185. /**
  95186. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  95187. */
  95188. keysLeft: number[];
  95189. /**
  95190. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  95191. */
  95192. keysRight: number[];
  95193. /**
  95194. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  95195. */
  95196. wheelPrecision: number;
  95197. /**
  95198. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  95199. * It will be used instead of pinchDeltaPrecision if different from 0.
  95200. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  95201. */
  95202. wheelDeltaPercentage: number;
  95203. /**
  95204. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  95205. */
  95206. zoomOnFactor: number;
  95207. /**
  95208. * Defines a screen offset for the camera position.
  95209. */
  95210. targetScreenOffset: Vector2;
  95211. /**
  95212. * Allows the camera to be completely reversed.
  95213. * If false the camera can not arrive upside down.
  95214. */
  95215. allowUpsideDown: boolean;
  95216. /**
  95217. * Define if double tap/click is used to restore the previously saved state of the camera.
  95218. */
  95219. useInputToRestoreState: boolean;
  95220. /** @hidden */
  95221. _viewMatrix: Matrix;
  95222. /** @hidden */
  95223. _useCtrlForPanning: boolean;
  95224. /** @hidden */
  95225. _panningMouseButton: number;
  95226. /**
  95227. * Defines the input associated to the camera.
  95228. */
  95229. inputs: ArcRotateCameraInputsManager;
  95230. /** @hidden */
  95231. _reset: () => void;
  95232. /**
  95233. * Defines the allowed panning axis.
  95234. */
  95235. panningAxis: Vector3;
  95236. protected _localDirection: Vector3;
  95237. protected _transformedDirection: Vector3;
  95238. private _bouncingBehavior;
  95239. /**
  95240. * Gets the bouncing behavior of the camera if it has been enabled.
  95241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95242. */
  95243. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  95244. /**
  95245. * Defines if the bouncing behavior of the camera is enabled on the camera.
  95246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  95247. */
  95248. useBouncingBehavior: boolean;
  95249. private _framingBehavior;
  95250. /**
  95251. * Gets the framing behavior of the camera if it has been enabled.
  95252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95253. */
  95254. readonly framingBehavior: Nullable<FramingBehavior>;
  95255. /**
  95256. * Defines if the framing behavior of the camera is enabled on the camera.
  95257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  95258. */
  95259. useFramingBehavior: boolean;
  95260. private _autoRotationBehavior;
  95261. /**
  95262. * Gets the auto rotation behavior of the camera if it has been enabled.
  95263. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95264. */
  95265. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  95266. /**
  95267. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  95268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95269. */
  95270. useAutoRotationBehavior: boolean;
  95271. /**
  95272. * Observable triggered when the mesh target has been changed on the camera.
  95273. */
  95274. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  95275. /**
  95276. * Event raised when the camera is colliding with a mesh.
  95277. */
  95278. onCollide: (collidedMesh: AbstractMesh) => void;
  95279. /**
  95280. * Defines whether the camera should check collision with the objects oh the scene.
  95281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  95282. */
  95283. checkCollisions: boolean;
  95284. /**
  95285. * Defines the collision radius of the camera.
  95286. * This simulates a sphere around the camera.
  95287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95288. */
  95289. collisionRadius: Vector3;
  95290. protected _collider: Collider;
  95291. protected _previousPosition: Vector3;
  95292. protected _collisionVelocity: Vector3;
  95293. protected _newPosition: Vector3;
  95294. protected _previousAlpha: number;
  95295. protected _previousBeta: number;
  95296. protected _previousRadius: number;
  95297. protected _collisionTriggered: boolean;
  95298. protected _targetBoundingCenter: Nullable<Vector3>;
  95299. private _computationVector;
  95300. /**
  95301. * Instantiates a new ArcRotateCamera in a given scene
  95302. * @param name Defines the name of the camera
  95303. * @param alpha Defines the camera rotation along the logitudinal axis
  95304. * @param beta Defines the camera rotation along the latitudinal axis
  95305. * @param radius Defines the camera distance from its target
  95306. * @param target Defines the camera target
  95307. * @param scene Defines the scene the camera belongs to
  95308. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95309. */
  95310. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95311. /** @hidden */
  95312. _initCache(): void;
  95313. /** @hidden */
  95314. _updateCache(ignoreParentClass?: boolean): void;
  95315. protected _getTargetPosition(): Vector3;
  95316. private _storedAlpha;
  95317. private _storedBeta;
  95318. private _storedRadius;
  95319. private _storedTarget;
  95320. /**
  95321. * Stores the current state of the camera (alpha, beta, radius and target)
  95322. * @returns the camera itself
  95323. */
  95324. storeState(): Camera;
  95325. /**
  95326. * @hidden
  95327. * Restored camera state. You must call storeState() first
  95328. */
  95329. _restoreStateValues(): boolean;
  95330. /** @hidden */
  95331. _isSynchronizedViewMatrix(): boolean;
  95332. /**
  95333. * Attached controls to the current camera.
  95334. * @param element Defines the element the controls should be listened from
  95335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95336. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  95337. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  95338. */
  95339. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  95340. /**
  95341. * Detach the current controls from the camera.
  95342. * The camera will stop reacting to inputs.
  95343. * @param element Defines the element to stop listening the inputs from
  95344. */
  95345. detachControl(element: HTMLElement): void;
  95346. /** @hidden */
  95347. _checkInputs(): void;
  95348. protected _checkLimits(): void;
  95349. /**
  95350. * Rebuilds angles (alpha, beta) and radius from the give position and target
  95351. */
  95352. rebuildAnglesAndRadius(): void;
  95353. /**
  95354. * Use a position to define the current camera related information like aplha, beta and radius
  95355. * @param position Defines the position to set the camera at
  95356. */
  95357. setPosition(position: Vector3): void;
  95358. /**
  95359. * Defines the target the camera should look at.
  95360. * This will automatically adapt alpha beta and radius to fit within the new target.
  95361. * @param target Defines the new target as a Vector or a mesh
  95362. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  95363. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  95364. */
  95365. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  95366. /** @hidden */
  95367. _getViewMatrix(): Matrix;
  95368. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  95369. /**
  95370. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  95371. * @param meshes Defines the mesh to zoom on
  95372. * @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)
  95373. */
  95374. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  95375. /**
  95376. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  95377. * The target will be changed but the radius
  95378. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  95379. * @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)
  95380. */
  95381. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  95382. min: Vector3;
  95383. max: Vector3;
  95384. distance: number;
  95385. }, doNotUpdateMaxZ?: boolean): void;
  95386. /**
  95387. * @override
  95388. * Override Camera.createRigCamera
  95389. */
  95390. createRigCamera(name: string, cameraIndex: number): Camera;
  95391. /**
  95392. * @hidden
  95393. * @override
  95394. * Override Camera._updateRigCameras
  95395. */
  95396. _updateRigCameras(): void;
  95397. /**
  95398. * Destroy the camera and release the current resources hold by it.
  95399. */
  95400. dispose(): void;
  95401. /**
  95402. * Gets the current object class name.
  95403. * @return the class name
  95404. */
  95405. getClassName(): string;
  95406. }
  95407. }
  95408. declare module BABYLON {
  95409. /**
  95410. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  95411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  95412. */
  95413. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  95414. /**
  95415. * Gets the name of the behavior.
  95416. */
  95417. readonly name: string;
  95418. private _zoomStopsAnimation;
  95419. private _idleRotationSpeed;
  95420. private _idleRotationWaitTime;
  95421. private _idleRotationSpinupTime;
  95422. /**
  95423. * Sets the flag that indicates if user zooming should stop animation.
  95424. */
  95425. /**
  95426. * Gets the flag that indicates if user zooming should stop animation.
  95427. */
  95428. zoomStopsAnimation: boolean;
  95429. /**
  95430. * Sets the default speed at which the camera rotates around the model.
  95431. */
  95432. /**
  95433. * Gets the default speed at which the camera rotates around the model.
  95434. */
  95435. idleRotationSpeed: number;
  95436. /**
  95437. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  95438. */
  95439. /**
  95440. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  95441. */
  95442. idleRotationWaitTime: number;
  95443. /**
  95444. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95445. */
  95446. /**
  95447. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  95448. */
  95449. idleRotationSpinupTime: number;
  95450. /**
  95451. * Gets a value indicating if the camera is currently rotating because of this behavior
  95452. */
  95453. readonly rotationInProgress: boolean;
  95454. private _onPrePointerObservableObserver;
  95455. private _onAfterCheckInputsObserver;
  95456. private _attachedCamera;
  95457. private _isPointerDown;
  95458. private _lastFrameTime;
  95459. private _lastInteractionTime;
  95460. private _cameraRotationSpeed;
  95461. /**
  95462. * Initializes the behavior.
  95463. */
  95464. init(): void;
  95465. /**
  95466. * Attaches the behavior to its arc rotate camera.
  95467. * @param camera Defines the camera to attach the behavior to
  95468. */
  95469. attach(camera: ArcRotateCamera): void;
  95470. /**
  95471. * Detaches the behavior from its current arc rotate camera.
  95472. */
  95473. detach(): void;
  95474. /**
  95475. * Returns true if user is scrolling.
  95476. * @return true if user is scrolling.
  95477. */
  95478. private _userIsZooming;
  95479. private _lastFrameRadius;
  95480. private _shouldAnimationStopForInteraction;
  95481. /**
  95482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  95483. */
  95484. private _applyUserInteraction;
  95485. private _userIsMoving;
  95486. }
  95487. }
  95488. declare module BABYLON {
  95489. /**
  95490. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  95491. */
  95492. export class AttachToBoxBehavior implements Behavior<Mesh> {
  95493. private ui;
  95494. /**
  95495. * The name of the behavior
  95496. */
  95497. name: string;
  95498. /**
  95499. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  95500. */
  95501. distanceAwayFromFace: number;
  95502. /**
  95503. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  95504. */
  95505. distanceAwayFromBottomOfFace: number;
  95506. private _faceVectors;
  95507. private _target;
  95508. private _scene;
  95509. private _onRenderObserver;
  95510. private _tmpMatrix;
  95511. private _tmpVector;
  95512. /**
  95513. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  95514. * @param ui The transform node that should be attched to the mesh
  95515. */
  95516. constructor(ui: TransformNode);
  95517. /**
  95518. * Initializes the behavior
  95519. */
  95520. init(): void;
  95521. private _closestFace;
  95522. private _zeroVector;
  95523. private _lookAtTmpMatrix;
  95524. private _lookAtToRef;
  95525. /**
  95526. * Attaches the AttachToBoxBehavior to the passed in mesh
  95527. * @param target The mesh that the specified node will be attached to
  95528. */
  95529. attach(target: Mesh): void;
  95530. /**
  95531. * Detaches the behavior from the mesh
  95532. */
  95533. detach(): void;
  95534. }
  95535. }
  95536. declare module BABYLON {
  95537. /**
  95538. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95539. */
  95540. export class FadeInOutBehavior implements Behavior<Mesh> {
  95541. /**
  95542. * Time in milliseconds to delay before fading in (Default: 0)
  95543. */
  95544. delay: number;
  95545. /**
  95546. * Time in milliseconds for the mesh to fade in (Default: 300)
  95547. */
  95548. fadeInTime: number;
  95549. private _millisecondsPerFrame;
  95550. private _hovered;
  95551. private _hoverValue;
  95552. private _ownerNode;
  95553. /**
  95554. * Instatiates the FadeInOutBehavior
  95555. */
  95556. constructor();
  95557. /**
  95558. * The name of the behavior
  95559. */
  95560. readonly name: string;
  95561. /**
  95562. * Initializes the behavior
  95563. */
  95564. init(): void;
  95565. /**
  95566. * Attaches the fade behavior on the passed in mesh
  95567. * @param ownerNode The mesh that will be faded in/out once attached
  95568. */
  95569. attach(ownerNode: Mesh): void;
  95570. /**
  95571. * Detaches the behavior from the mesh
  95572. */
  95573. detach(): void;
  95574. /**
  95575. * Triggers the mesh to begin fading in or out
  95576. * @param value if the object should fade in or out (true to fade in)
  95577. */
  95578. fadeIn(value: boolean): void;
  95579. private _update;
  95580. private _setAllVisibility;
  95581. }
  95582. }
  95583. declare module BABYLON {
  95584. /**
  95585. * Class containing a set of static utilities functions for managing Pivots
  95586. * @hidden
  95587. */
  95588. export class PivotTools {
  95589. private static _PivotCached;
  95590. private static _OldPivotPoint;
  95591. private static _PivotTranslation;
  95592. private static _PivotTmpVector;
  95593. /** @hidden */
  95594. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95595. /** @hidden */
  95596. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95597. }
  95598. }
  95599. declare module BABYLON {
  95600. /**
  95601. * Class containing static functions to help procedurally build meshes
  95602. */
  95603. export class PlaneBuilder {
  95604. /**
  95605. * Creates a plane mesh
  95606. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95607. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95608. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95612. * @param name defines the name of the mesh
  95613. * @param options defines the options used to create the mesh
  95614. * @param scene defines the hosting scene
  95615. * @returns the plane mesh
  95616. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95617. */
  95618. static CreatePlane(name: string, options: {
  95619. size?: number;
  95620. width?: number;
  95621. height?: number;
  95622. sideOrientation?: number;
  95623. frontUVs?: Vector4;
  95624. backUVs?: Vector4;
  95625. updatable?: boolean;
  95626. sourcePlane?: Plane;
  95627. }, scene?: Nullable<Scene>): Mesh;
  95628. }
  95629. }
  95630. declare module BABYLON {
  95631. /**
  95632. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95633. */
  95634. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95635. private static _AnyMouseID;
  95636. private _attachedNode;
  95637. private _dragPlane;
  95638. private _scene;
  95639. private _pointerObserver;
  95640. private _beforeRenderObserver;
  95641. private static _planeScene;
  95642. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95643. /**
  95644. * 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)
  95645. */
  95646. maxDragAngle: number;
  95647. /**
  95648. * @hidden
  95649. */
  95650. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95651. /**
  95652. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95653. */
  95654. currentDraggingPointerID: number;
  95655. /**
  95656. * The last position where the pointer hit the drag plane in world space
  95657. */
  95658. lastDragPosition: Vector3;
  95659. /**
  95660. * If the behavior is currently in a dragging state
  95661. */
  95662. dragging: boolean;
  95663. /**
  95664. * 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)
  95665. */
  95666. dragDeltaRatio: number;
  95667. /**
  95668. * If the drag plane orientation should be updated during the dragging (Default: true)
  95669. */
  95670. updateDragPlane: boolean;
  95671. private _debugMode;
  95672. private _moving;
  95673. /**
  95674. * Fires each time the attached mesh is dragged with the pointer
  95675. * * delta between last drag position and current drag position in world space
  95676. * * dragDistance along the drag axis
  95677. * * dragPlaneNormal normal of the current drag plane used during the drag
  95678. * * dragPlanePoint in world space where the drag intersects the drag plane
  95679. */
  95680. onDragObservable: Observable<{
  95681. delta: Vector3;
  95682. dragPlanePoint: Vector3;
  95683. dragPlaneNormal: Vector3;
  95684. dragDistance: number;
  95685. pointerId: number;
  95686. }>;
  95687. /**
  95688. * Fires each time a drag begins (eg. mouse down on mesh)
  95689. */
  95690. onDragStartObservable: Observable<{
  95691. dragPlanePoint: Vector3;
  95692. pointerId: number;
  95693. }>;
  95694. /**
  95695. * Fires each time a drag ends (eg. mouse release after drag)
  95696. */
  95697. onDragEndObservable: Observable<{
  95698. dragPlanePoint: Vector3;
  95699. pointerId: number;
  95700. }>;
  95701. /**
  95702. * If the attached mesh should be moved when dragged
  95703. */
  95704. moveAttached: boolean;
  95705. /**
  95706. * If the drag behavior will react to drag events (Default: true)
  95707. */
  95708. enabled: boolean;
  95709. /**
  95710. * If camera controls should be detached during the drag
  95711. */
  95712. detachCameraControls: boolean;
  95713. /**
  95714. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95715. */
  95716. useObjectOrienationForDragging: boolean;
  95717. private _options;
  95718. /**
  95719. * Creates a pointer drag behavior that can be attached to a mesh
  95720. * @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)
  95721. */
  95722. constructor(options?: {
  95723. dragAxis?: Vector3;
  95724. dragPlaneNormal?: Vector3;
  95725. });
  95726. /**
  95727. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95728. */
  95729. validateDrag: (targetPosition: Vector3) => boolean;
  95730. /**
  95731. * The name of the behavior
  95732. */
  95733. readonly name: string;
  95734. /**
  95735. * Initializes the behavior
  95736. */
  95737. init(): void;
  95738. private _tmpVector;
  95739. private _alternatePickedPoint;
  95740. private _worldDragAxis;
  95741. private _targetPosition;
  95742. private _attachedElement;
  95743. /**
  95744. * Attaches the drag behavior the passed in mesh
  95745. * @param ownerNode The mesh that will be dragged around once attached
  95746. */
  95747. attach(ownerNode: AbstractMesh): void;
  95748. /**
  95749. * Force relase the drag action by code.
  95750. */
  95751. releaseDrag(): void;
  95752. private _startDragRay;
  95753. private _lastPointerRay;
  95754. /**
  95755. * Simulates the start of a pointer drag event on the behavior
  95756. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95757. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95758. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95759. */
  95760. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95761. private _startDrag;
  95762. private _dragDelta;
  95763. private _moveDrag;
  95764. private _pickWithRayOnDragPlane;
  95765. private _pointA;
  95766. private _pointB;
  95767. private _pointC;
  95768. private _lineA;
  95769. private _lineB;
  95770. private _localAxis;
  95771. private _lookAt;
  95772. private _updateDragPlanePosition;
  95773. /**
  95774. * Detaches the behavior from the mesh
  95775. */
  95776. detach(): void;
  95777. }
  95778. }
  95779. declare module BABYLON {
  95780. /**
  95781. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95782. */
  95783. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95784. private _dragBehaviorA;
  95785. private _dragBehaviorB;
  95786. private _startDistance;
  95787. private _initialScale;
  95788. private _targetScale;
  95789. private _ownerNode;
  95790. private _sceneRenderObserver;
  95791. /**
  95792. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95793. */
  95794. constructor();
  95795. /**
  95796. * The name of the behavior
  95797. */
  95798. readonly name: string;
  95799. /**
  95800. * Initializes the behavior
  95801. */
  95802. init(): void;
  95803. private _getCurrentDistance;
  95804. /**
  95805. * Attaches the scale behavior the passed in mesh
  95806. * @param ownerNode The mesh that will be scaled around once attached
  95807. */
  95808. attach(ownerNode: Mesh): void;
  95809. /**
  95810. * Detaches the behavior from the mesh
  95811. */
  95812. detach(): void;
  95813. }
  95814. }
  95815. declare module BABYLON {
  95816. /**
  95817. * 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
  95818. */
  95819. export class SixDofDragBehavior implements Behavior<Mesh> {
  95820. private static _virtualScene;
  95821. private _ownerNode;
  95822. private _sceneRenderObserver;
  95823. private _scene;
  95824. private _targetPosition;
  95825. private _virtualOriginMesh;
  95826. private _virtualDragMesh;
  95827. private _pointerObserver;
  95828. private _moving;
  95829. private _startingOrientation;
  95830. /**
  95831. * 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)
  95832. */
  95833. private zDragFactor;
  95834. /**
  95835. * If the object should rotate to face the drag origin
  95836. */
  95837. rotateDraggedObject: boolean;
  95838. /**
  95839. * If the behavior is currently in a dragging state
  95840. */
  95841. dragging: boolean;
  95842. /**
  95843. * 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)
  95844. */
  95845. dragDeltaRatio: number;
  95846. /**
  95847. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95848. */
  95849. currentDraggingPointerID: number;
  95850. /**
  95851. * If camera controls should be detached during the drag
  95852. */
  95853. detachCameraControls: boolean;
  95854. /**
  95855. * Fires each time a drag starts
  95856. */
  95857. onDragStartObservable: Observable<{}>;
  95858. /**
  95859. * Fires each time a drag ends (eg. mouse release after drag)
  95860. */
  95861. onDragEndObservable: Observable<{}>;
  95862. /**
  95863. * 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
  95864. */
  95865. constructor();
  95866. /**
  95867. * The name of the behavior
  95868. */
  95869. readonly name: string;
  95870. /**
  95871. * Initializes the behavior
  95872. */
  95873. init(): void;
  95874. /**
  95875. * Attaches the scale behavior the passed in mesh
  95876. * @param ownerNode The mesh that will be scaled around once attached
  95877. */
  95878. attach(ownerNode: Mesh): void;
  95879. /**
  95880. * Detaches the behavior from the mesh
  95881. */
  95882. detach(): void;
  95883. }
  95884. }
  95885. declare module BABYLON {
  95886. /**
  95887. * Class used to apply inverse kinematics to bones
  95888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95889. */
  95890. export class BoneIKController {
  95891. private static _tmpVecs;
  95892. private static _tmpQuat;
  95893. private static _tmpMats;
  95894. /**
  95895. * Gets or sets the target mesh
  95896. */
  95897. targetMesh: AbstractMesh;
  95898. /** Gets or sets the mesh used as pole */
  95899. poleTargetMesh: AbstractMesh;
  95900. /**
  95901. * Gets or sets the bone used as pole
  95902. */
  95903. poleTargetBone: Nullable<Bone>;
  95904. /**
  95905. * Gets or sets the target position
  95906. */
  95907. targetPosition: Vector3;
  95908. /**
  95909. * Gets or sets the pole target position
  95910. */
  95911. poleTargetPosition: Vector3;
  95912. /**
  95913. * Gets or sets the pole target local offset
  95914. */
  95915. poleTargetLocalOffset: Vector3;
  95916. /**
  95917. * Gets or sets the pole angle
  95918. */
  95919. poleAngle: number;
  95920. /**
  95921. * Gets or sets the mesh associated with the controller
  95922. */
  95923. mesh: AbstractMesh;
  95924. /**
  95925. * 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)
  95926. */
  95927. slerpAmount: number;
  95928. private _bone1Quat;
  95929. private _bone1Mat;
  95930. private _bone2Ang;
  95931. private _bone1;
  95932. private _bone2;
  95933. private _bone1Length;
  95934. private _bone2Length;
  95935. private _maxAngle;
  95936. private _maxReach;
  95937. private _rightHandedSystem;
  95938. private _bendAxis;
  95939. private _slerping;
  95940. private _adjustRoll;
  95941. /**
  95942. * Gets or sets maximum allowed angle
  95943. */
  95944. maxAngle: number;
  95945. /**
  95946. * Creates a new BoneIKController
  95947. * @param mesh defines the mesh to control
  95948. * @param bone defines the bone to control
  95949. * @param options defines options to set up the controller
  95950. */
  95951. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95952. targetMesh?: AbstractMesh;
  95953. poleTargetMesh?: AbstractMesh;
  95954. poleTargetBone?: Bone;
  95955. poleTargetLocalOffset?: Vector3;
  95956. poleAngle?: number;
  95957. bendAxis?: Vector3;
  95958. maxAngle?: number;
  95959. slerpAmount?: number;
  95960. });
  95961. private _setMaxAngle;
  95962. /**
  95963. * Force the controller to update the bones
  95964. */
  95965. update(): void;
  95966. }
  95967. }
  95968. declare module BABYLON {
  95969. /**
  95970. * Class used to make a bone look toward a point in space
  95971. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95972. */
  95973. export class BoneLookController {
  95974. private static _tmpVecs;
  95975. private static _tmpQuat;
  95976. private static _tmpMats;
  95977. /**
  95978. * The target Vector3 that the bone will look at
  95979. */
  95980. target: Vector3;
  95981. /**
  95982. * The mesh that the bone is attached to
  95983. */
  95984. mesh: AbstractMesh;
  95985. /**
  95986. * The bone that will be looking to the target
  95987. */
  95988. bone: Bone;
  95989. /**
  95990. * The up axis of the coordinate system that is used when the bone is rotated
  95991. */
  95992. upAxis: Vector3;
  95993. /**
  95994. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95995. */
  95996. upAxisSpace: Space;
  95997. /**
  95998. * Used to make an adjustment to the yaw of the bone
  95999. */
  96000. adjustYaw: number;
  96001. /**
  96002. * Used to make an adjustment to the pitch of the bone
  96003. */
  96004. adjustPitch: number;
  96005. /**
  96006. * Used to make an adjustment to the roll of the bone
  96007. */
  96008. adjustRoll: number;
  96009. /**
  96010. * 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)
  96011. */
  96012. slerpAmount: number;
  96013. private _minYaw;
  96014. private _maxYaw;
  96015. private _minPitch;
  96016. private _maxPitch;
  96017. private _minYawSin;
  96018. private _minYawCos;
  96019. private _maxYawSin;
  96020. private _maxYawCos;
  96021. private _midYawConstraint;
  96022. private _minPitchTan;
  96023. private _maxPitchTan;
  96024. private _boneQuat;
  96025. private _slerping;
  96026. private _transformYawPitch;
  96027. private _transformYawPitchInv;
  96028. private _firstFrameSkipped;
  96029. private _yawRange;
  96030. private _fowardAxis;
  96031. /**
  96032. * Gets or sets the minimum yaw angle that the bone can look to
  96033. */
  96034. minYaw: number;
  96035. /**
  96036. * Gets or sets the maximum yaw angle that the bone can look to
  96037. */
  96038. maxYaw: number;
  96039. /**
  96040. * Gets or sets the minimum pitch angle that the bone can look to
  96041. */
  96042. minPitch: number;
  96043. /**
  96044. * Gets or sets the maximum pitch angle that the bone can look to
  96045. */
  96046. maxPitch: number;
  96047. /**
  96048. * Create a BoneLookController
  96049. * @param mesh the mesh that the bone belongs to
  96050. * @param bone the bone that will be looking to the target
  96051. * @param target the target Vector3 to look at
  96052. * @param options optional settings:
  96053. * * maxYaw: the maximum angle the bone will yaw to
  96054. * * minYaw: the minimum angle the bone will yaw to
  96055. * * maxPitch: the maximum angle the bone will pitch to
  96056. * * minPitch: the minimum angle the bone will yaw to
  96057. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  96058. * * upAxis: the up axis of the coordinate system
  96059. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  96060. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  96061. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  96062. * * adjustYaw: used to make an adjustment to the yaw of the bone
  96063. * * adjustPitch: used to make an adjustment to the pitch of the bone
  96064. * * adjustRoll: used to make an adjustment to the roll of the bone
  96065. **/
  96066. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  96067. maxYaw?: number;
  96068. minYaw?: number;
  96069. maxPitch?: number;
  96070. minPitch?: number;
  96071. slerpAmount?: number;
  96072. upAxis?: Vector3;
  96073. upAxisSpace?: Space;
  96074. yawAxis?: Vector3;
  96075. pitchAxis?: Vector3;
  96076. adjustYaw?: number;
  96077. adjustPitch?: number;
  96078. adjustRoll?: number;
  96079. });
  96080. /**
  96081. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  96082. */
  96083. update(): void;
  96084. private _getAngleDiff;
  96085. private _getAngleBetween;
  96086. private _isAngleBetween;
  96087. }
  96088. }
  96089. declare module BABYLON {
  96090. /**
  96091. * Manage the gamepad inputs to control an arc rotate camera.
  96092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96093. */
  96094. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  96095. /**
  96096. * Defines the camera the input is attached to.
  96097. */
  96098. camera: ArcRotateCamera;
  96099. /**
  96100. * Defines the gamepad the input is gathering event from.
  96101. */
  96102. gamepad: Nullable<Gamepad>;
  96103. /**
  96104. * Defines the gamepad rotation sensiblity.
  96105. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96106. */
  96107. gamepadRotationSensibility: number;
  96108. /**
  96109. * Defines the gamepad move sensiblity.
  96110. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96111. */
  96112. gamepadMoveSensibility: number;
  96113. private _onGamepadConnectedObserver;
  96114. private _onGamepadDisconnectedObserver;
  96115. /**
  96116. * Attach the input controls to a specific dom element to get the input from.
  96117. * @param element Defines the element the controls should be listened from
  96118. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96119. */
  96120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96121. /**
  96122. * Detach the current controls from the specified dom element.
  96123. * @param element Defines the element to stop listening the inputs from
  96124. */
  96125. detachControl(element: Nullable<HTMLElement>): void;
  96126. /**
  96127. * Update the current camera state depending on the inputs that have been used this frame.
  96128. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96129. */
  96130. checkInputs(): void;
  96131. /**
  96132. * Gets the class name of the current intput.
  96133. * @returns the class name
  96134. */
  96135. getClassName(): string;
  96136. /**
  96137. * Get the friendly name associated with the input class.
  96138. * @returns the input friendly name
  96139. */
  96140. getSimpleName(): string;
  96141. }
  96142. }
  96143. declare module BABYLON {
  96144. interface ArcRotateCameraInputsManager {
  96145. /**
  96146. * Add orientation input support to the input manager.
  96147. * @returns the current input manager
  96148. */
  96149. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  96150. }
  96151. /**
  96152. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  96153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96154. */
  96155. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  96156. /**
  96157. * Defines the camera the input is attached to.
  96158. */
  96159. camera: ArcRotateCamera;
  96160. /**
  96161. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  96162. */
  96163. alphaCorrection: number;
  96164. /**
  96165. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  96166. */
  96167. gammaCorrection: number;
  96168. private _alpha;
  96169. private _gamma;
  96170. private _dirty;
  96171. private _deviceOrientationHandler;
  96172. /**
  96173. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  96174. */
  96175. constructor();
  96176. /**
  96177. * Attach the input controls to a specific dom element to get the input from.
  96178. * @param element Defines the element the controls should be listened from
  96179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96180. */
  96181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96182. /** @hidden */
  96183. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  96184. /**
  96185. * Update the current camera state depending on the inputs that have been used this frame.
  96186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96187. */
  96188. checkInputs(): void;
  96189. /**
  96190. * Detach the current controls from the specified dom element.
  96191. * @param element Defines the element to stop listening the inputs from
  96192. */
  96193. detachControl(element: Nullable<HTMLElement>): void;
  96194. /**
  96195. * Gets the class name of the current intput.
  96196. * @returns the class name
  96197. */
  96198. getClassName(): string;
  96199. /**
  96200. * Get the friendly name associated with the input class.
  96201. * @returns the input friendly name
  96202. */
  96203. getSimpleName(): string;
  96204. }
  96205. }
  96206. declare module BABYLON {
  96207. /**
  96208. * Listen to mouse events to control the camera.
  96209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96210. */
  96211. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  96212. /**
  96213. * Defines the camera the input is attached to.
  96214. */
  96215. camera: FlyCamera;
  96216. /**
  96217. * Defines if touch is enabled. (Default is true.)
  96218. */
  96219. touchEnabled: boolean;
  96220. /**
  96221. * Defines the buttons associated with the input to handle camera rotation.
  96222. */
  96223. buttons: number[];
  96224. /**
  96225. * Assign buttons for Yaw control.
  96226. */
  96227. buttonsYaw: number[];
  96228. /**
  96229. * Assign buttons for Pitch control.
  96230. */
  96231. buttonsPitch: number[];
  96232. /**
  96233. * Assign buttons for Roll control.
  96234. */
  96235. buttonsRoll: number[];
  96236. /**
  96237. * Detect if any button is being pressed while mouse is moved.
  96238. * -1 = Mouse locked.
  96239. * 0 = Left button.
  96240. * 1 = Middle Button.
  96241. * 2 = Right Button.
  96242. */
  96243. activeButton: number;
  96244. /**
  96245. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  96246. * Higher values reduce its sensitivity.
  96247. */
  96248. angularSensibility: number;
  96249. private _mousemoveCallback;
  96250. private _observer;
  96251. private _rollObserver;
  96252. private previousPosition;
  96253. private noPreventDefault;
  96254. private element;
  96255. /**
  96256. * Listen to mouse events to control the camera.
  96257. * @param touchEnabled Define if touch is enabled. (Default is true.)
  96258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96259. */
  96260. constructor(touchEnabled?: boolean);
  96261. /**
  96262. * Attach the mouse control to the HTML DOM element.
  96263. * @param element Defines the element that listens to the input events.
  96264. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  96265. */
  96266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96267. /**
  96268. * Detach the current controls from the specified dom element.
  96269. * @param element Defines the element to stop listening the inputs from
  96270. */
  96271. detachControl(element: Nullable<HTMLElement>): void;
  96272. /**
  96273. * Gets the class name of the current input.
  96274. * @returns the class name.
  96275. */
  96276. getClassName(): string;
  96277. /**
  96278. * Get the friendly name associated with the input class.
  96279. * @returns the input's friendly name.
  96280. */
  96281. getSimpleName(): string;
  96282. private _pointerInput;
  96283. private _onMouseMove;
  96284. /**
  96285. * Rotate camera by mouse offset.
  96286. */
  96287. private rotateCamera;
  96288. }
  96289. }
  96290. declare module BABYLON {
  96291. /**
  96292. * Default Inputs manager for the FlyCamera.
  96293. * It groups all the default supported inputs for ease of use.
  96294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96295. */
  96296. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  96297. /**
  96298. * Instantiates a new FlyCameraInputsManager.
  96299. * @param camera Defines the camera the inputs belong to.
  96300. */
  96301. constructor(camera: FlyCamera);
  96302. /**
  96303. * Add keyboard input support to the input manager.
  96304. * @returns the new FlyCameraKeyboardMoveInput().
  96305. */
  96306. addKeyboard(): FlyCameraInputsManager;
  96307. /**
  96308. * Add mouse input support to the input manager.
  96309. * @param touchEnabled Enable touch screen support.
  96310. * @returns the new FlyCameraMouseInput().
  96311. */
  96312. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  96313. }
  96314. }
  96315. declare module BABYLON {
  96316. /**
  96317. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96318. * such as in a 3D Space Shooter or a Flight Simulator.
  96319. */
  96320. export class FlyCamera extends TargetCamera {
  96321. /**
  96322. * Define the collision ellipsoid of the camera.
  96323. * This is helpful for simulating a camera body, like a player's body.
  96324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96325. */
  96326. ellipsoid: Vector3;
  96327. /**
  96328. * Define an offset for the position of the ellipsoid around the camera.
  96329. * This can be helpful if the camera is attached away from the player's body center,
  96330. * such as at its head.
  96331. */
  96332. ellipsoidOffset: Vector3;
  96333. /**
  96334. * Enable or disable collisions of the camera with the rest of the scene objects.
  96335. */
  96336. checkCollisions: boolean;
  96337. /**
  96338. * Enable or disable gravity on the camera.
  96339. */
  96340. applyGravity: boolean;
  96341. /**
  96342. * Define the current direction the camera is moving to.
  96343. */
  96344. cameraDirection: Vector3;
  96345. /**
  96346. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  96347. * This overrides and empties cameraRotation.
  96348. */
  96349. rotationQuaternion: Quaternion;
  96350. /**
  96351. * Track Roll to maintain the wanted Rolling when looking around.
  96352. */
  96353. _trackRoll: number;
  96354. /**
  96355. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  96356. */
  96357. rollCorrect: number;
  96358. /**
  96359. * Mimic a banked turn, Rolling the camera when Yawing.
  96360. * It's recommended to use rollCorrect = 10 for faster banking correction.
  96361. */
  96362. bankedTurn: boolean;
  96363. /**
  96364. * Limit in radians for how much Roll banking will add. (Default: 90°)
  96365. */
  96366. bankedTurnLimit: number;
  96367. /**
  96368. * Value of 0 disables the banked Roll.
  96369. * Value of 1 is equal to the Yaw angle in radians.
  96370. */
  96371. bankedTurnMultiplier: number;
  96372. /**
  96373. * The inputs manager loads all the input sources, such as keyboard and mouse.
  96374. */
  96375. inputs: FlyCameraInputsManager;
  96376. /**
  96377. * Gets the input sensibility for mouse input.
  96378. * Higher values reduce sensitivity.
  96379. */
  96380. /**
  96381. * Sets the input sensibility for a mouse input.
  96382. * Higher values reduce sensitivity.
  96383. */
  96384. angularSensibility: number;
  96385. /**
  96386. * Get the keys for camera movement forward.
  96387. */
  96388. /**
  96389. * Set the keys for camera movement forward.
  96390. */
  96391. keysForward: number[];
  96392. /**
  96393. * Get the keys for camera movement backward.
  96394. */
  96395. keysBackward: number[];
  96396. /**
  96397. * Get the keys for camera movement up.
  96398. */
  96399. /**
  96400. * Set the keys for camera movement up.
  96401. */
  96402. keysUp: number[];
  96403. /**
  96404. * Get the keys for camera movement down.
  96405. */
  96406. /**
  96407. * Set the keys for camera movement down.
  96408. */
  96409. keysDown: number[];
  96410. /**
  96411. * Get the keys for camera movement left.
  96412. */
  96413. /**
  96414. * Set the keys for camera movement left.
  96415. */
  96416. keysLeft: number[];
  96417. /**
  96418. * Set the keys for camera movement right.
  96419. */
  96420. /**
  96421. * Set the keys for camera movement right.
  96422. */
  96423. keysRight: number[];
  96424. /**
  96425. * Event raised when the camera collides with a mesh in the scene.
  96426. */
  96427. onCollide: (collidedMesh: AbstractMesh) => void;
  96428. private _collider;
  96429. private _needMoveForGravity;
  96430. private _oldPosition;
  96431. private _diffPosition;
  96432. private _newPosition;
  96433. /** @hidden */
  96434. _localDirection: Vector3;
  96435. /** @hidden */
  96436. _transformedDirection: Vector3;
  96437. /**
  96438. * Instantiates a FlyCamera.
  96439. * This is a flying camera, designed for 3D movement and rotation in all directions,
  96440. * such as in a 3D Space Shooter or a Flight Simulator.
  96441. * @param name Define the name of the camera in the scene.
  96442. * @param position Define the starting position of the camera in the scene.
  96443. * @param scene Define the scene the camera belongs to.
  96444. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  96445. */
  96446. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96447. /**
  96448. * Attach a control to the HTML DOM element.
  96449. * @param element Defines the element that listens to the input events.
  96450. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  96451. */
  96452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96453. /**
  96454. * Detach a control from the HTML DOM element.
  96455. * The camera will stop reacting to that input.
  96456. * @param element Defines the element that listens to the input events.
  96457. */
  96458. detachControl(element: HTMLElement): void;
  96459. private _collisionMask;
  96460. /**
  96461. * Get the mask that the camera ignores in collision events.
  96462. */
  96463. /**
  96464. * Set the mask that the camera ignores in collision events.
  96465. */
  96466. collisionMask: number;
  96467. /** @hidden */
  96468. _collideWithWorld(displacement: Vector3): void;
  96469. /** @hidden */
  96470. private _onCollisionPositionChange;
  96471. /** @hidden */
  96472. _checkInputs(): void;
  96473. /** @hidden */
  96474. _decideIfNeedsToMove(): boolean;
  96475. /** @hidden */
  96476. _updatePosition(): void;
  96477. /**
  96478. * Restore the Roll to its target value at the rate specified.
  96479. * @param rate - Higher means slower restoring.
  96480. * @hidden
  96481. */
  96482. restoreRoll(rate: number): void;
  96483. /**
  96484. * Destroy the camera and release the current resources held by it.
  96485. */
  96486. dispose(): void;
  96487. /**
  96488. * Get the current object class name.
  96489. * @returns the class name.
  96490. */
  96491. getClassName(): string;
  96492. }
  96493. }
  96494. declare module BABYLON {
  96495. /**
  96496. * Listen to keyboard events to control the camera.
  96497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96498. */
  96499. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  96500. /**
  96501. * Defines the camera the input is attached to.
  96502. */
  96503. camera: FlyCamera;
  96504. /**
  96505. * The list of keyboard keys used to control the forward move of the camera.
  96506. */
  96507. keysForward: number[];
  96508. /**
  96509. * The list of keyboard keys used to control the backward move of the camera.
  96510. */
  96511. keysBackward: number[];
  96512. /**
  96513. * The list of keyboard keys used to control the forward move of the camera.
  96514. */
  96515. keysUp: number[];
  96516. /**
  96517. * The list of keyboard keys used to control the backward move of the camera.
  96518. */
  96519. keysDown: number[];
  96520. /**
  96521. * The list of keyboard keys used to control the right strafe move of the camera.
  96522. */
  96523. keysRight: number[];
  96524. /**
  96525. * The list of keyboard keys used to control the left strafe move of the camera.
  96526. */
  96527. keysLeft: number[];
  96528. private _keys;
  96529. private _onCanvasBlurObserver;
  96530. private _onKeyboardObserver;
  96531. private _engine;
  96532. private _scene;
  96533. /**
  96534. * Attach the input controls to a specific dom element to get the input from.
  96535. * @param element Defines the element the controls should be listened from
  96536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96537. */
  96538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96539. /**
  96540. * Detach the current controls from the specified dom element.
  96541. * @param element Defines the element to stop listening the inputs from
  96542. */
  96543. detachControl(element: Nullable<HTMLElement>): void;
  96544. /**
  96545. * Gets the class name of the current intput.
  96546. * @returns the class name
  96547. */
  96548. getClassName(): string;
  96549. /** @hidden */
  96550. _onLostFocus(e: FocusEvent): void;
  96551. /**
  96552. * Get the friendly name associated with the input class.
  96553. * @returns the input friendly name
  96554. */
  96555. getSimpleName(): string;
  96556. /**
  96557. * Update the current camera state depending on the inputs that have been used this frame.
  96558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96559. */
  96560. checkInputs(): void;
  96561. }
  96562. }
  96563. declare module BABYLON {
  96564. /**
  96565. * Manage the mouse wheel inputs to control a follow camera.
  96566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96567. */
  96568. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96569. /**
  96570. * Defines the camera the input is attached to.
  96571. */
  96572. camera: FollowCamera;
  96573. /**
  96574. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96575. */
  96576. axisControlRadius: boolean;
  96577. /**
  96578. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96579. */
  96580. axisControlHeight: boolean;
  96581. /**
  96582. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96583. */
  96584. axisControlRotation: boolean;
  96585. /**
  96586. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96587. * relation to mouseWheel events.
  96588. */
  96589. wheelPrecision: number;
  96590. /**
  96591. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96592. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96593. */
  96594. wheelDeltaPercentage: number;
  96595. private _wheel;
  96596. private _observer;
  96597. /**
  96598. * Attach the input controls to a specific dom element to get the input from.
  96599. * @param element Defines the element the controls should be listened from
  96600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96601. */
  96602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96603. /**
  96604. * Detach the current controls from the specified dom element.
  96605. * @param element Defines the element to stop listening the inputs from
  96606. */
  96607. detachControl(element: Nullable<HTMLElement>): void;
  96608. /**
  96609. * Gets the class name of the current intput.
  96610. * @returns the class name
  96611. */
  96612. getClassName(): string;
  96613. /**
  96614. * Get the friendly name associated with the input class.
  96615. * @returns the input friendly name
  96616. */
  96617. getSimpleName(): string;
  96618. }
  96619. }
  96620. declare module BABYLON {
  96621. /**
  96622. * Manage the pointers inputs to control an follow camera.
  96623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96624. */
  96625. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96626. /**
  96627. * Defines the camera the input is attached to.
  96628. */
  96629. camera: FollowCamera;
  96630. /**
  96631. * Gets the class name of the current input.
  96632. * @returns the class name
  96633. */
  96634. getClassName(): string;
  96635. /**
  96636. * Defines the pointer angular sensibility along the X axis or how fast is
  96637. * the camera rotating.
  96638. * A negative number will reverse the axis direction.
  96639. */
  96640. angularSensibilityX: number;
  96641. /**
  96642. * Defines the pointer angular sensibility along the Y axis or how fast is
  96643. * the camera rotating.
  96644. * A negative number will reverse the axis direction.
  96645. */
  96646. angularSensibilityY: number;
  96647. /**
  96648. * Defines the pointer pinch precision or how fast is the camera zooming.
  96649. * A negative number will reverse the axis direction.
  96650. */
  96651. pinchPrecision: number;
  96652. /**
  96653. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96654. * from 0.
  96655. * It defines the percentage of current camera.radius to use as delta when
  96656. * pinch zoom is used.
  96657. */
  96658. pinchDeltaPercentage: number;
  96659. /**
  96660. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96661. */
  96662. axisXControlRadius: boolean;
  96663. /**
  96664. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96665. */
  96666. axisXControlHeight: boolean;
  96667. /**
  96668. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96669. */
  96670. axisXControlRotation: boolean;
  96671. /**
  96672. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96673. */
  96674. axisYControlRadius: boolean;
  96675. /**
  96676. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96677. */
  96678. axisYControlHeight: boolean;
  96679. /**
  96680. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96681. */
  96682. axisYControlRotation: boolean;
  96683. /**
  96684. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96685. */
  96686. axisPinchControlRadius: boolean;
  96687. /**
  96688. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96689. */
  96690. axisPinchControlHeight: boolean;
  96691. /**
  96692. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96693. */
  96694. axisPinchControlRotation: boolean;
  96695. /**
  96696. * Log error messages if basic misconfiguration has occurred.
  96697. */
  96698. warningEnable: boolean;
  96699. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96700. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96701. private _warningCounter;
  96702. private _warning;
  96703. }
  96704. }
  96705. declare module BABYLON {
  96706. /**
  96707. * Default Inputs manager for the FollowCamera.
  96708. * It groups all the default supported inputs for ease of use.
  96709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96710. */
  96711. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96712. /**
  96713. * Instantiates a new FollowCameraInputsManager.
  96714. * @param camera Defines the camera the inputs belong to
  96715. */
  96716. constructor(camera: FollowCamera);
  96717. /**
  96718. * Add keyboard input support to the input manager.
  96719. * @returns the current input manager
  96720. */
  96721. addKeyboard(): FollowCameraInputsManager;
  96722. /**
  96723. * Add mouse wheel input support to the input manager.
  96724. * @returns the current input manager
  96725. */
  96726. addMouseWheel(): FollowCameraInputsManager;
  96727. /**
  96728. * Add pointers input support to the input manager.
  96729. * @returns the current input manager
  96730. */
  96731. addPointers(): FollowCameraInputsManager;
  96732. /**
  96733. * Add orientation input support to the input manager.
  96734. * @returns the current input manager
  96735. */
  96736. addVRDeviceOrientation(): FollowCameraInputsManager;
  96737. }
  96738. }
  96739. declare module BABYLON {
  96740. /**
  96741. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96742. * an arc rotate version arcFollowCamera are available.
  96743. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96744. */
  96745. export class FollowCamera extends TargetCamera {
  96746. /**
  96747. * Distance the follow camera should follow an object at
  96748. */
  96749. radius: number;
  96750. /**
  96751. * Minimum allowed distance of the camera to the axis of rotation
  96752. * (The camera can not get closer).
  96753. * This can help limiting how the Camera is able to move in the scene.
  96754. */
  96755. lowerRadiusLimit: Nullable<number>;
  96756. /**
  96757. * Maximum allowed distance of the camera to the axis of rotation
  96758. * (The camera can not get further).
  96759. * This can help limiting how the Camera is able to move in the scene.
  96760. */
  96761. upperRadiusLimit: Nullable<number>;
  96762. /**
  96763. * Define a rotation offset between the camera and the object it follows
  96764. */
  96765. rotationOffset: number;
  96766. /**
  96767. * Minimum allowed angle to camera position relative to target object.
  96768. * This can help limiting how the Camera is able to move in the scene.
  96769. */
  96770. lowerRotationOffsetLimit: Nullable<number>;
  96771. /**
  96772. * Maximum allowed angle to camera position relative to target object.
  96773. * This can help limiting how the Camera is able to move in the scene.
  96774. */
  96775. upperRotationOffsetLimit: Nullable<number>;
  96776. /**
  96777. * Define a height offset between the camera and the object it follows.
  96778. * It can help following an object from the top (like a car chaing a plane)
  96779. */
  96780. heightOffset: number;
  96781. /**
  96782. * Minimum allowed height of camera position relative to target object.
  96783. * This can help limiting how the Camera is able to move in the scene.
  96784. */
  96785. lowerHeightOffsetLimit: Nullable<number>;
  96786. /**
  96787. * Maximum allowed height of camera position relative to target object.
  96788. * This can help limiting how the Camera is able to move in the scene.
  96789. */
  96790. upperHeightOffsetLimit: Nullable<number>;
  96791. /**
  96792. * Define how fast the camera can accelerate to follow it s target.
  96793. */
  96794. cameraAcceleration: number;
  96795. /**
  96796. * Define the speed limit of the camera following an object.
  96797. */
  96798. maxCameraSpeed: number;
  96799. /**
  96800. * Define the target of the camera.
  96801. */
  96802. lockedTarget: Nullable<AbstractMesh>;
  96803. /**
  96804. * Defines the input associated with the camera.
  96805. */
  96806. inputs: FollowCameraInputsManager;
  96807. /**
  96808. * Instantiates the follow camera.
  96809. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96810. * @param name Define the name of the camera in the scene
  96811. * @param position Define the position of the camera
  96812. * @param scene Define the scene the camera belong to
  96813. * @param lockedTarget Define the target of the camera
  96814. */
  96815. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96816. private _follow;
  96817. /**
  96818. * Attached controls to the current camera.
  96819. * @param element Defines the element the controls should be listened from
  96820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96821. */
  96822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96823. /**
  96824. * Detach the current controls from the camera.
  96825. * The camera will stop reacting to inputs.
  96826. * @param element Defines the element to stop listening the inputs from
  96827. */
  96828. detachControl(element: HTMLElement): void;
  96829. /** @hidden */
  96830. _checkInputs(): void;
  96831. private _checkLimits;
  96832. /**
  96833. * Gets the camera class name.
  96834. * @returns the class name
  96835. */
  96836. getClassName(): string;
  96837. }
  96838. /**
  96839. * Arc Rotate version of the follow camera.
  96840. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96841. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96842. */
  96843. export class ArcFollowCamera extends TargetCamera {
  96844. /** The longitudinal angle of the camera */
  96845. alpha: number;
  96846. /** The latitudinal angle of the camera */
  96847. beta: number;
  96848. /** The radius of the camera from its target */
  96849. radius: number;
  96850. /** Define the camera target (the messh it should follow) */
  96851. target: Nullable<AbstractMesh>;
  96852. private _cartesianCoordinates;
  96853. /**
  96854. * Instantiates a new ArcFollowCamera
  96855. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96856. * @param name Define the name of the camera
  96857. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96858. * @param beta Define the rotation angle of the camera around the elevation axis
  96859. * @param radius Define the radius of the camera from its target point
  96860. * @param target Define the target of the camera
  96861. * @param scene Define the scene the camera belongs to
  96862. */
  96863. constructor(name: string,
  96864. /** The longitudinal angle of the camera */
  96865. alpha: number,
  96866. /** The latitudinal angle of the camera */
  96867. beta: number,
  96868. /** The radius of the camera from its target */
  96869. radius: number,
  96870. /** Define the camera target (the messh it should follow) */
  96871. target: Nullable<AbstractMesh>, scene: Scene);
  96872. private _follow;
  96873. /** @hidden */
  96874. _checkInputs(): void;
  96875. /**
  96876. * Returns the class name of the object.
  96877. * It is mostly used internally for serialization purposes.
  96878. */
  96879. getClassName(): string;
  96880. }
  96881. }
  96882. declare module BABYLON {
  96883. /**
  96884. * Manage the keyboard inputs to control the movement of a follow camera.
  96885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96886. */
  96887. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96888. /**
  96889. * Defines the camera the input is attached to.
  96890. */
  96891. camera: FollowCamera;
  96892. /**
  96893. * Defines the list of key codes associated with the up action (increase heightOffset)
  96894. */
  96895. keysHeightOffsetIncr: number[];
  96896. /**
  96897. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96898. */
  96899. keysHeightOffsetDecr: number[];
  96900. /**
  96901. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96902. */
  96903. keysHeightOffsetModifierAlt: boolean;
  96904. /**
  96905. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96906. */
  96907. keysHeightOffsetModifierCtrl: boolean;
  96908. /**
  96909. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96910. */
  96911. keysHeightOffsetModifierShift: boolean;
  96912. /**
  96913. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96914. */
  96915. keysRotationOffsetIncr: number[];
  96916. /**
  96917. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96918. */
  96919. keysRotationOffsetDecr: number[];
  96920. /**
  96921. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96922. */
  96923. keysRotationOffsetModifierAlt: boolean;
  96924. /**
  96925. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96926. */
  96927. keysRotationOffsetModifierCtrl: boolean;
  96928. /**
  96929. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96930. */
  96931. keysRotationOffsetModifierShift: boolean;
  96932. /**
  96933. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96934. */
  96935. keysRadiusIncr: number[];
  96936. /**
  96937. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96938. */
  96939. keysRadiusDecr: number[];
  96940. /**
  96941. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96942. */
  96943. keysRadiusModifierAlt: boolean;
  96944. /**
  96945. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96946. */
  96947. keysRadiusModifierCtrl: boolean;
  96948. /**
  96949. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96950. */
  96951. keysRadiusModifierShift: boolean;
  96952. /**
  96953. * Defines the rate of change of heightOffset.
  96954. */
  96955. heightSensibility: number;
  96956. /**
  96957. * Defines the rate of change of rotationOffset.
  96958. */
  96959. rotationSensibility: number;
  96960. /**
  96961. * Defines the rate of change of radius.
  96962. */
  96963. radiusSensibility: number;
  96964. private _keys;
  96965. private _ctrlPressed;
  96966. private _altPressed;
  96967. private _shiftPressed;
  96968. private _onCanvasBlurObserver;
  96969. private _onKeyboardObserver;
  96970. private _engine;
  96971. private _scene;
  96972. /**
  96973. * Attach the input controls to a specific dom element to get the input from.
  96974. * @param element Defines the element the controls should be listened from
  96975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96976. */
  96977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96978. /**
  96979. * Detach the current controls from the specified dom element.
  96980. * @param element Defines the element to stop listening the inputs from
  96981. */
  96982. detachControl(element: Nullable<HTMLElement>): void;
  96983. /**
  96984. * Update the current camera state depending on the inputs that have been used this frame.
  96985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96986. */
  96987. checkInputs(): void;
  96988. /**
  96989. * Gets the class name of the current input.
  96990. * @returns the class name
  96991. */
  96992. getClassName(): string;
  96993. /**
  96994. * Get the friendly name associated with the input class.
  96995. * @returns the input friendly name
  96996. */
  96997. getSimpleName(): string;
  96998. /**
  96999. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97000. * allow modification of the heightOffset value.
  97001. */
  97002. private _modifierHeightOffset;
  97003. /**
  97004. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97005. * allow modification of the rotationOffset value.
  97006. */
  97007. private _modifierRotationOffset;
  97008. /**
  97009. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  97010. * allow modification of the radius value.
  97011. */
  97012. private _modifierRadius;
  97013. }
  97014. }
  97015. declare module BABYLON {
  97016. interface FreeCameraInputsManager {
  97017. /**
  97018. * @hidden
  97019. */
  97020. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  97021. /**
  97022. * Add orientation input support to the input manager.
  97023. * @returns the current input manager
  97024. */
  97025. addDeviceOrientation(): FreeCameraInputsManager;
  97026. }
  97027. /**
  97028. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  97029. * Screen rotation is taken into account.
  97030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97031. */
  97032. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  97033. private _camera;
  97034. private _screenOrientationAngle;
  97035. private _constantTranform;
  97036. private _screenQuaternion;
  97037. private _alpha;
  97038. private _beta;
  97039. private _gamma;
  97040. /**
  97041. * @hidden
  97042. */
  97043. _onDeviceOrientationChangedObservable: Observable<void>;
  97044. /**
  97045. * Instantiates a new input
  97046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97047. */
  97048. constructor();
  97049. /**
  97050. * Define the camera controlled by the input.
  97051. */
  97052. camera: FreeCamera;
  97053. /**
  97054. * Attach the input controls to a specific dom element to get the input from.
  97055. * @param element Defines the element the controls should be listened from
  97056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97057. */
  97058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97059. private _orientationChanged;
  97060. private _deviceOrientation;
  97061. /**
  97062. * Detach the current controls from the specified dom element.
  97063. * @param element Defines the element to stop listening the inputs from
  97064. */
  97065. detachControl(element: Nullable<HTMLElement>): void;
  97066. /**
  97067. * Update the current camera state depending on the inputs that have been used this frame.
  97068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97069. */
  97070. checkInputs(): void;
  97071. /**
  97072. * Gets the class name of the current intput.
  97073. * @returns the class name
  97074. */
  97075. getClassName(): string;
  97076. /**
  97077. * Get the friendly name associated with the input class.
  97078. * @returns the input friendly name
  97079. */
  97080. getSimpleName(): string;
  97081. }
  97082. }
  97083. declare module BABYLON {
  97084. /**
  97085. * Manage the gamepad inputs to control a free camera.
  97086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97087. */
  97088. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  97089. /**
  97090. * Define the camera the input is attached to.
  97091. */
  97092. camera: FreeCamera;
  97093. /**
  97094. * Define the Gamepad controlling the input
  97095. */
  97096. gamepad: Nullable<Gamepad>;
  97097. /**
  97098. * Defines the gamepad rotation sensiblity.
  97099. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97100. */
  97101. gamepadAngularSensibility: number;
  97102. /**
  97103. * Defines the gamepad move sensiblity.
  97104. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97105. */
  97106. gamepadMoveSensibility: number;
  97107. private _onGamepadConnectedObserver;
  97108. private _onGamepadDisconnectedObserver;
  97109. private _cameraTransform;
  97110. private _deltaTransform;
  97111. private _vector3;
  97112. private _vector2;
  97113. /**
  97114. * Attach the input controls to a specific dom element to get the input from.
  97115. * @param element Defines the element the controls should be listened from
  97116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97117. */
  97118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97119. /**
  97120. * Detach the current controls from the specified dom element.
  97121. * @param element Defines the element to stop listening the inputs from
  97122. */
  97123. detachControl(element: Nullable<HTMLElement>): void;
  97124. /**
  97125. * Update the current camera state depending on the inputs that have been used this frame.
  97126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97127. */
  97128. checkInputs(): void;
  97129. /**
  97130. * Gets the class name of the current intput.
  97131. * @returns the class name
  97132. */
  97133. getClassName(): string;
  97134. /**
  97135. * Get the friendly name associated with the input class.
  97136. * @returns the input friendly name
  97137. */
  97138. getSimpleName(): string;
  97139. }
  97140. }
  97141. declare module BABYLON {
  97142. /**
  97143. * Defines the potential axis of a Joystick
  97144. */
  97145. export enum JoystickAxis {
  97146. /** X axis */
  97147. X = 0,
  97148. /** Y axis */
  97149. Y = 1,
  97150. /** Z axis */
  97151. Z = 2
  97152. }
  97153. /**
  97154. * Class used to define virtual joystick (used in touch mode)
  97155. */
  97156. export class VirtualJoystick {
  97157. /**
  97158. * Gets or sets a boolean indicating that left and right values must be inverted
  97159. */
  97160. reverseLeftRight: boolean;
  97161. /**
  97162. * Gets or sets a boolean indicating that up and down values must be inverted
  97163. */
  97164. reverseUpDown: boolean;
  97165. /**
  97166. * Gets the offset value for the position (ie. the change of the position value)
  97167. */
  97168. deltaPosition: Vector3;
  97169. /**
  97170. * Gets a boolean indicating if the virtual joystick was pressed
  97171. */
  97172. pressed: boolean;
  97173. /**
  97174. * Canvas the virtual joystick will render onto, default z-index of this is 5
  97175. */
  97176. static Canvas: Nullable<HTMLCanvasElement>;
  97177. private static _globalJoystickIndex;
  97178. private static vjCanvasContext;
  97179. private static vjCanvasWidth;
  97180. private static vjCanvasHeight;
  97181. private static halfWidth;
  97182. private _action;
  97183. private _axisTargetedByLeftAndRight;
  97184. private _axisTargetedByUpAndDown;
  97185. private _joystickSensibility;
  97186. private _inversedSensibility;
  97187. private _joystickPointerID;
  97188. private _joystickColor;
  97189. private _joystickPointerPos;
  97190. private _joystickPreviousPointerPos;
  97191. private _joystickPointerStartPos;
  97192. private _deltaJoystickVector;
  97193. private _leftJoystick;
  97194. private _touches;
  97195. private _onPointerDownHandlerRef;
  97196. private _onPointerMoveHandlerRef;
  97197. private _onPointerUpHandlerRef;
  97198. private _onResize;
  97199. /**
  97200. * Creates a new virtual joystick
  97201. * @param leftJoystick defines that the joystick is for left hand (false by default)
  97202. */
  97203. constructor(leftJoystick?: boolean);
  97204. /**
  97205. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  97206. * @param newJoystickSensibility defines the new sensibility
  97207. */
  97208. setJoystickSensibility(newJoystickSensibility: number): void;
  97209. private _onPointerDown;
  97210. private _onPointerMove;
  97211. private _onPointerUp;
  97212. /**
  97213. * Change the color of the virtual joystick
  97214. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  97215. */
  97216. setJoystickColor(newColor: string): void;
  97217. /**
  97218. * Defines a callback to call when the joystick is touched
  97219. * @param action defines the callback
  97220. */
  97221. setActionOnTouch(action: () => any): void;
  97222. /**
  97223. * Defines which axis you'd like to control for left & right
  97224. * @param axis defines the axis to use
  97225. */
  97226. setAxisForLeftRight(axis: JoystickAxis): void;
  97227. /**
  97228. * Defines which axis you'd like to control for up & down
  97229. * @param axis defines the axis to use
  97230. */
  97231. setAxisForUpDown(axis: JoystickAxis): void;
  97232. private _drawVirtualJoystick;
  97233. /**
  97234. * Release internal HTML canvas
  97235. */
  97236. releaseCanvas(): void;
  97237. }
  97238. }
  97239. declare module BABYLON {
  97240. interface FreeCameraInputsManager {
  97241. /**
  97242. * Add virtual joystick input support to the input manager.
  97243. * @returns the current input manager
  97244. */
  97245. addVirtualJoystick(): FreeCameraInputsManager;
  97246. }
  97247. /**
  97248. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  97249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97250. */
  97251. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  97252. /**
  97253. * Defines the camera the input is attached to.
  97254. */
  97255. camera: FreeCamera;
  97256. private _leftjoystick;
  97257. private _rightjoystick;
  97258. /**
  97259. * Gets the left stick of the virtual joystick.
  97260. * @returns The virtual Joystick
  97261. */
  97262. getLeftJoystick(): VirtualJoystick;
  97263. /**
  97264. * Gets the right stick of the virtual joystick.
  97265. * @returns The virtual Joystick
  97266. */
  97267. getRightJoystick(): VirtualJoystick;
  97268. /**
  97269. * Update the current camera state depending on the inputs that have been used this frame.
  97270. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97271. */
  97272. checkInputs(): void;
  97273. /**
  97274. * Attach the input controls to a specific dom element to get the input from.
  97275. * @param element Defines the element the controls should be listened from
  97276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97277. */
  97278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97279. /**
  97280. * Detach the current controls from the specified dom element.
  97281. * @param element Defines the element to stop listening the inputs from
  97282. */
  97283. detachControl(element: Nullable<HTMLElement>): void;
  97284. /**
  97285. * Gets the class name of the current intput.
  97286. * @returns the class name
  97287. */
  97288. getClassName(): string;
  97289. /**
  97290. * Get the friendly name associated with the input class.
  97291. * @returns the input friendly name
  97292. */
  97293. getSimpleName(): string;
  97294. }
  97295. }
  97296. declare module BABYLON {
  97297. /**
  97298. * This represents a FPS type of camera controlled by touch.
  97299. * This is like a universal camera minus the Gamepad controls.
  97300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97301. */
  97302. export class TouchCamera extends FreeCamera {
  97303. /**
  97304. * Defines the touch sensibility for rotation.
  97305. * The higher the faster.
  97306. */
  97307. touchAngularSensibility: number;
  97308. /**
  97309. * Defines the touch sensibility for move.
  97310. * The higher the faster.
  97311. */
  97312. touchMoveSensibility: number;
  97313. /**
  97314. * Instantiates a new touch camera.
  97315. * This represents a FPS type of camera controlled by touch.
  97316. * This is like a universal camera minus the Gamepad controls.
  97317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97318. * @param name Define the name of the camera in the scene
  97319. * @param position Define the start position of the camera in the scene
  97320. * @param scene Define the scene the camera belongs to
  97321. */
  97322. constructor(name: string, position: Vector3, scene: Scene);
  97323. /**
  97324. * Gets the current object class name.
  97325. * @return the class name
  97326. */
  97327. getClassName(): string;
  97328. /** @hidden */
  97329. _setupInputs(): void;
  97330. }
  97331. }
  97332. declare module BABYLON {
  97333. /**
  97334. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  97335. * being tilted forward or back and left or right.
  97336. */
  97337. export class DeviceOrientationCamera extends FreeCamera {
  97338. private _initialQuaternion;
  97339. private _quaternionCache;
  97340. private _tmpDragQuaternion;
  97341. /**
  97342. * Creates a new device orientation camera
  97343. * @param name The name of the camera
  97344. * @param position The start position camera
  97345. * @param scene The scene the camera belongs to
  97346. */
  97347. constructor(name: string, position: Vector3, scene: Scene);
  97348. /**
  97349. * @hidden
  97350. * Disabled pointer input on first orientation sensor update (Default: true)
  97351. */
  97352. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  97353. private _dragFactor;
  97354. /**
  97355. * Enabled turning on the y axis when the orientation sensor is active
  97356. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  97357. */
  97358. enableHorizontalDragging(dragFactor?: number): void;
  97359. /**
  97360. * Gets the current instance class name ("DeviceOrientationCamera").
  97361. * This helps avoiding instanceof at run time.
  97362. * @returns the class name
  97363. */
  97364. getClassName(): string;
  97365. /**
  97366. * @hidden
  97367. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  97368. */
  97369. _checkInputs(): void;
  97370. /**
  97371. * Reset the camera to its default orientation on the specified axis only.
  97372. * @param axis The axis to reset
  97373. */
  97374. resetToCurrentRotation(axis?: Axis): void;
  97375. }
  97376. }
  97377. declare module BABYLON {
  97378. /**
  97379. * 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,
  97380. * which still works and will still be found in many Playgrounds.
  97381. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97382. */
  97383. export class UniversalCamera extends TouchCamera {
  97384. /**
  97385. * Defines the gamepad rotation sensiblity.
  97386. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  97387. */
  97388. gamepadAngularSensibility: number;
  97389. /**
  97390. * Defines the gamepad move sensiblity.
  97391. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  97392. */
  97393. gamepadMoveSensibility: number;
  97394. /**
  97395. * 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,
  97396. * which still works and will still be found in many Playgrounds.
  97397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97398. * @param name Define the name of the camera in the scene
  97399. * @param position Define the start position of the camera in the scene
  97400. * @param scene Define the scene the camera belongs to
  97401. */
  97402. constructor(name: string, position: Vector3, scene: Scene);
  97403. /**
  97404. * Gets the current object class name.
  97405. * @return the class name
  97406. */
  97407. getClassName(): string;
  97408. }
  97409. }
  97410. declare module BABYLON {
  97411. /**
  97412. * This represents a FPS type of camera. This is only here for back compat purpose.
  97413. * Please use the UniversalCamera instead as both are identical.
  97414. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97415. */
  97416. export class GamepadCamera extends UniversalCamera {
  97417. /**
  97418. * Instantiates a new Gamepad Camera
  97419. * This represents a FPS type of camera. This is only here for back compat purpose.
  97420. * Please use the UniversalCamera instead as both are identical.
  97421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  97422. * @param name Define the name of the camera in the scene
  97423. * @param position Define the start position of the camera in the scene
  97424. * @param scene Define the scene the camera belongs to
  97425. */
  97426. constructor(name: string, position: Vector3, scene: Scene);
  97427. /**
  97428. * Gets the current object class name.
  97429. * @return the class name
  97430. */
  97431. getClassName(): string;
  97432. }
  97433. }
  97434. declare module BABYLON {
  97435. /** @hidden */
  97436. export var passPixelShader: {
  97437. name: string;
  97438. shader: string;
  97439. };
  97440. }
  97441. declare module BABYLON {
  97442. /** @hidden */
  97443. export var passCubePixelShader: {
  97444. name: string;
  97445. shader: string;
  97446. };
  97447. }
  97448. declare module BABYLON {
  97449. /**
  97450. * PassPostProcess which produces an output the same as it's input
  97451. */
  97452. export class PassPostProcess extends PostProcess {
  97453. /**
  97454. * Creates the PassPostProcess
  97455. * @param name The name of the effect.
  97456. * @param options The required width/height ratio to downsize to before computing the render pass.
  97457. * @param camera The camera to apply the render pass to.
  97458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97459. * @param engine The engine which the post process will be applied. (default: current engine)
  97460. * @param reusable If the post process can be reused on the same frame. (default: false)
  97461. * @param textureType The type of texture to be used when performing the post processing.
  97462. * @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)
  97463. */
  97464. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97465. }
  97466. /**
  97467. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  97468. */
  97469. export class PassCubePostProcess extends PostProcess {
  97470. private _face;
  97471. /**
  97472. * Gets or sets the cube face to display.
  97473. * * 0 is +X
  97474. * * 1 is -X
  97475. * * 2 is +Y
  97476. * * 3 is -Y
  97477. * * 4 is +Z
  97478. * * 5 is -Z
  97479. */
  97480. face: number;
  97481. /**
  97482. * Creates the PassCubePostProcess
  97483. * @param name The name of the effect.
  97484. * @param options The required width/height ratio to downsize to before computing the render pass.
  97485. * @param camera The camera to apply the render pass to.
  97486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97487. * @param engine The engine which the post process will be applied. (default: current engine)
  97488. * @param reusable If the post process can be reused on the same frame. (default: false)
  97489. * @param textureType The type of texture to be used when performing the post processing.
  97490. * @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)
  97491. */
  97492. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  97493. }
  97494. }
  97495. declare module BABYLON {
  97496. /** @hidden */
  97497. export var anaglyphPixelShader: {
  97498. name: string;
  97499. shader: string;
  97500. };
  97501. }
  97502. declare module BABYLON {
  97503. /**
  97504. * Postprocess used to generate anaglyphic rendering
  97505. */
  97506. export class AnaglyphPostProcess extends PostProcess {
  97507. private _passedProcess;
  97508. /**
  97509. * Creates a new AnaglyphPostProcess
  97510. * @param name defines postprocess name
  97511. * @param options defines creation options or target ratio scale
  97512. * @param rigCameras defines cameras using this postprocess
  97513. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  97514. * @param engine defines hosting engine
  97515. * @param reusable defines if the postprocess will be reused multiple times per frame
  97516. */
  97517. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97518. }
  97519. }
  97520. declare module BABYLON {
  97521. /**
  97522. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97523. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97524. */
  97525. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97526. /**
  97527. * Creates a new AnaglyphArcRotateCamera
  97528. * @param name defines camera name
  97529. * @param alpha defines alpha angle (in radians)
  97530. * @param beta defines beta angle (in radians)
  97531. * @param radius defines radius
  97532. * @param target defines camera target
  97533. * @param interaxialDistance defines distance between each color axis
  97534. * @param scene defines the hosting scene
  97535. */
  97536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97537. /**
  97538. * Gets camera class name
  97539. * @returns AnaglyphArcRotateCamera
  97540. */
  97541. getClassName(): string;
  97542. }
  97543. }
  97544. declare module BABYLON {
  97545. /**
  97546. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97547. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97548. */
  97549. export class AnaglyphFreeCamera extends FreeCamera {
  97550. /**
  97551. * Creates a new AnaglyphFreeCamera
  97552. * @param name defines camera name
  97553. * @param position defines initial position
  97554. * @param interaxialDistance defines distance between each color axis
  97555. * @param scene defines the hosting scene
  97556. */
  97557. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97558. /**
  97559. * Gets camera class name
  97560. * @returns AnaglyphFreeCamera
  97561. */
  97562. getClassName(): string;
  97563. }
  97564. }
  97565. declare module BABYLON {
  97566. /**
  97567. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97568. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97569. */
  97570. export class AnaglyphGamepadCamera extends GamepadCamera {
  97571. /**
  97572. * Creates a new AnaglyphGamepadCamera
  97573. * @param name defines camera name
  97574. * @param position defines initial position
  97575. * @param interaxialDistance defines distance between each color axis
  97576. * @param scene defines the hosting scene
  97577. */
  97578. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97579. /**
  97580. * Gets camera class name
  97581. * @returns AnaglyphGamepadCamera
  97582. */
  97583. getClassName(): string;
  97584. }
  97585. }
  97586. declare module BABYLON {
  97587. /**
  97588. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97589. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97590. */
  97591. export class AnaglyphUniversalCamera extends UniversalCamera {
  97592. /**
  97593. * Creates a new AnaglyphUniversalCamera
  97594. * @param name defines camera name
  97595. * @param position defines initial position
  97596. * @param interaxialDistance defines distance between each color axis
  97597. * @param scene defines the hosting scene
  97598. */
  97599. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97600. /**
  97601. * Gets camera class name
  97602. * @returns AnaglyphUniversalCamera
  97603. */
  97604. getClassName(): string;
  97605. }
  97606. }
  97607. declare module BABYLON {
  97608. /** @hidden */
  97609. export var stereoscopicInterlacePixelShader: {
  97610. name: string;
  97611. shader: string;
  97612. };
  97613. }
  97614. declare module BABYLON {
  97615. /**
  97616. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97617. */
  97618. export class StereoscopicInterlacePostProcess extends PostProcess {
  97619. private _stepSize;
  97620. private _passedProcess;
  97621. /**
  97622. * Initializes a StereoscopicInterlacePostProcess
  97623. * @param name The name of the effect.
  97624. * @param rigCameras The rig cameras to be appled to the post process
  97625. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97627. * @param engine The engine which the post process will be applied. (default: current engine)
  97628. * @param reusable If the post process can be reused on the same frame. (default: false)
  97629. */
  97630. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97631. }
  97632. }
  97633. declare module BABYLON {
  97634. /**
  97635. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97636. * @see http://doc.babylonjs.com/features/cameras
  97637. */
  97638. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97639. /**
  97640. * Creates a new StereoscopicArcRotateCamera
  97641. * @param name defines camera name
  97642. * @param alpha defines alpha angle (in radians)
  97643. * @param beta defines beta angle (in radians)
  97644. * @param radius defines radius
  97645. * @param target defines camera target
  97646. * @param interaxialDistance defines distance between each color axis
  97647. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97648. * @param scene defines the hosting scene
  97649. */
  97650. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97651. /**
  97652. * Gets camera class name
  97653. * @returns StereoscopicArcRotateCamera
  97654. */
  97655. getClassName(): string;
  97656. }
  97657. }
  97658. declare module BABYLON {
  97659. /**
  97660. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97661. * @see http://doc.babylonjs.com/features/cameras
  97662. */
  97663. export class StereoscopicFreeCamera extends FreeCamera {
  97664. /**
  97665. * Creates a new StereoscopicFreeCamera
  97666. * @param name defines camera name
  97667. * @param position defines initial position
  97668. * @param interaxialDistance defines distance between each color axis
  97669. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97670. * @param scene defines the hosting scene
  97671. */
  97672. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97673. /**
  97674. * Gets camera class name
  97675. * @returns StereoscopicFreeCamera
  97676. */
  97677. getClassName(): string;
  97678. }
  97679. }
  97680. declare module BABYLON {
  97681. /**
  97682. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97683. * @see http://doc.babylonjs.com/features/cameras
  97684. */
  97685. export class StereoscopicGamepadCamera extends GamepadCamera {
  97686. /**
  97687. * Creates a new StereoscopicGamepadCamera
  97688. * @param name defines camera name
  97689. * @param position defines initial position
  97690. * @param interaxialDistance defines distance between each color axis
  97691. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97692. * @param scene defines the hosting scene
  97693. */
  97694. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97695. /**
  97696. * Gets camera class name
  97697. * @returns StereoscopicGamepadCamera
  97698. */
  97699. getClassName(): string;
  97700. }
  97701. }
  97702. declare module BABYLON {
  97703. /**
  97704. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97705. * @see http://doc.babylonjs.com/features/cameras
  97706. */
  97707. export class StereoscopicUniversalCamera extends UniversalCamera {
  97708. /**
  97709. * Creates a new StereoscopicUniversalCamera
  97710. * @param name defines camera name
  97711. * @param position defines initial position
  97712. * @param interaxialDistance defines distance between each color axis
  97713. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97714. * @param scene defines the hosting scene
  97715. */
  97716. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97717. /**
  97718. * Gets camera class name
  97719. * @returns StereoscopicUniversalCamera
  97720. */
  97721. getClassName(): string;
  97722. }
  97723. }
  97724. declare module BABYLON {
  97725. /**
  97726. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97727. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97728. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97729. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97730. */
  97731. export class VirtualJoysticksCamera extends FreeCamera {
  97732. /**
  97733. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97734. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97735. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97736. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97737. * @param name Define the name of the camera in the scene
  97738. * @param position Define the start position of the camera in the scene
  97739. * @param scene Define the scene the camera belongs to
  97740. */
  97741. constructor(name: string, position: Vector3, scene: Scene);
  97742. /**
  97743. * Gets the current object class name.
  97744. * @return the class name
  97745. */
  97746. getClassName(): string;
  97747. }
  97748. }
  97749. declare module BABYLON {
  97750. /**
  97751. * This represents all the required metrics to create a VR camera.
  97752. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97753. */
  97754. export class VRCameraMetrics {
  97755. /**
  97756. * Define the horizontal resolution off the screen.
  97757. */
  97758. hResolution: number;
  97759. /**
  97760. * Define the vertical resolution off the screen.
  97761. */
  97762. vResolution: number;
  97763. /**
  97764. * Define the horizontal screen size.
  97765. */
  97766. hScreenSize: number;
  97767. /**
  97768. * Define the vertical screen size.
  97769. */
  97770. vScreenSize: number;
  97771. /**
  97772. * Define the vertical screen center position.
  97773. */
  97774. vScreenCenter: number;
  97775. /**
  97776. * Define the distance of the eyes to the screen.
  97777. */
  97778. eyeToScreenDistance: number;
  97779. /**
  97780. * Define the distance between both lenses
  97781. */
  97782. lensSeparationDistance: number;
  97783. /**
  97784. * Define the distance between both viewer's eyes.
  97785. */
  97786. interpupillaryDistance: number;
  97787. /**
  97788. * Define the distortion factor of the VR postprocess.
  97789. * Please, touch with care.
  97790. */
  97791. distortionK: number[];
  97792. /**
  97793. * Define the chromatic aberration correction factors for the VR post process.
  97794. */
  97795. chromaAbCorrection: number[];
  97796. /**
  97797. * Define the scale factor of the post process.
  97798. * The smaller the better but the slower.
  97799. */
  97800. postProcessScaleFactor: number;
  97801. /**
  97802. * Define an offset for the lens center.
  97803. */
  97804. lensCenterOffset: number;
  97805. /**
  97806. * Define if the current vr camera should compensate the distortion of the lense or not.
  97807. */
  97808. compensateDistortion: boolean;
  97809. /**
  97810. * Defines if multiview should be enabled when rendering (Default: false)
  97811. */
  97812. multiviewEnabled: boolean;
  97813. /**
  97814. * Gets the rendering aspect ratio based on the provided resolutions.
  97815. */
  97816. readonly aspectRatio: number;
  97817. /**
  97818. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97819. */
  97820. readonly aspectRatioFov: number;
  97821. /**
  97822. * @hidden
  97823. */
  97824. readonly leftHMatrix: Matrix;
  97825. /**
  97826. * @hidden
  97827. */
  97828. readonly rightHMatrix: Matrix;
  97829. /**
  97830. * @hidden
  97831. */
  97832. readonly leftPreViewMatrix: Matrix;
  97833. /**
  97834. * @hidden
  97835. */
  97836. readonly rightPreViewMatrix: Matrix;
  97837. /**
  97838. * Get the default VRMetrics based on the most generic setup.
  97839. * @returns the default vr metrics
  97840. */
  97841. static GetDefault(): VRCameraMetrics;
  97842. }
  97843. }
  97844. declare module BABYLON {
  97845. /** @hidden */
  97846. export var vrDistortionCorrectionPixelShader: {
  97847. name: string;
  97848. shader: string;
  97849. };
  97850. }
  97851. declare module BABYLON {
  97852. /**
  97853. * VRDistortionCorrectionPostProcess used for mobile VR
  97854. */
  97855. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97856. private _isRightEye;
  97857. private _distortionFactors;
  97858. private _postProcessScaleFactor;
  97859. private _lensCenterOffset;
  97860. private _scaleIn;
  97861. private _scaleFactor;
  97862. private _lensCenter;
  97863. /**
  97864. * Initializes the VRDistortionCorrectionPostProcess
  97865. * @param name The name of the effect.
  97866. * @param camera The camera to apply the render pass to.
  97867. * @param isRightEye If this is for the right eye distortion
  97868. * @param vrMetrics All the required metrics for the VR camera
  97869. */
  97870. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97871. }
  97872. }
  97873. declare module BABYLON {
  97874. /**
  97875. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97876. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97877. */
  97878. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97879. /**
  97880. * Creates a new VRDeviceOrientationArcRotateCamera
  97881. * @param name defines camera name
  97882. * @param alpha defines the camera rotation along the logitudinal axis
  97883. * @param beta defines the camera rotation along the latitudinal axis
  97884. * @param radius defines the camera distance from its target
  97885. * @param target defines the camera target
  97886. * @param scene defines the scene the camera belongs to
  97887. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97888. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97889. */
  97890. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97891. /**
  97892. * Gets camera class name
  97893. * @returns VRDeviceOrientationArcRotateCamera
  97894. */
  97895. getClassName(): string;
  97896. }
  97897. }
  97898. declare module BABYLON {
  97899. /**
  97900. * Camera used to simulate VR rendering (based on FreeCamera)
  97901. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97902. */
  97903. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97904. /**
  97905. * Creates a new VRDeviceOrientationFreeCamera
  97906. * @param name defines camera name
  97907. * @param position defines the start position of the camera
  97908. * @param scene defines the scene the camera belongs to
  97909. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97910. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97911. */
  97912. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97913. /**
  97914. * Gets camera class name
  97915. * @returns VRDeviceOrientationFreeCamera
  97916. */
  97917. getClassName(): string;
  97918. }
  97919. }
  97920. declare module BABYLON {
  97921. /**
  97922. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97923. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97924. */
  97925. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97926. /**
  97927. * Creates a new VRDeviceOrientationGamepadCamera
  97928. * @param name defines camera name
  97929. * @param position defines the start position of the camera
  97930. * @param scene defines the scene the camera belongs to
  97931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97933. */
  97934. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97935. /**
  97936. * Gets camera class name
  97937. * @returns VRDeviceOrientationGamepadCamera
  97938. */
  97939. getClassName(): string;
  97940. }
  97941. }
  97942. declare module BABYLON {
  97943. /**
  97944. * Defines supported buttons for XBox360 compatible gamepads
  97945. */
  97946. export enum Xbox360Button {
  97947. /** A */
  97948. A = 0,
  97949. /** B */
  97950. B = 1,
  97951. /** X */
  97952. X = 2,
  97953. /** Y */
  97954. Y = 3,
  97955. /** Start */
  97956. Start = 4,
  97957. /** Back */
  97958. Back = 5,
  97959. /** Left button */
  97960. LB = 6,
  97961. /** Right button */
  97962. RB = 7,
  97963. /** Left stick */
  97964. LeftStick = 8,
  97965. /** Right stick */
  97966. RightStick = 9
  97967. }
  97968. /** Defines values for XBox360 DPad */
  97969. export enum Xbox360Dpad {
  97970. /** Up */
  97971. Up = 0,
  97972. /** Down */
  97973. Down = 1,
  97974. /** Left */
  97975. Left = 2,
  97976. /** Right */
  97977. Right = 3
  97978. }
  97979. /**
  97980. * Defines a XBox360 gamepad
  97981. */
  97982. export class Xbox360Pad extends Gamepad {
  97983. private _leftTrigger;
  97984. private _rightTrigger;
  97985. private _onlefttriggerchanged;
  97986. private _onrighttriggerchanged;
  97987. private _onbuttondown;
  97988. private _onbuttonup;
  97989. private _ondpaddown;
  97990. private _ondpadup;
  97991. /** Observable raised when a button is pressed */
  97992. onButtonDownObservable: Observable<Xbox360Button>;
  97993. /** Observable raised when a button is released */
  97994. onButtonUpObservable: Observable<Xbox360Button>;
  97995. /** Observable raised when a pad is pressed */
  97996. onPadDownObservable: Observable<Xbox360Dpad>;
  97997. /** Observable raised when a pad is released */
  97998. onPadUpObservable: Observable<Xbox360Dpad>;
  97999. private _buttonA;
  98000. private _buttonB;
  98001. private _buttonX;
  98002. private _buttonY;
  98003. private _buttonBack;
  98004. private _buttonStart;
  98005. private _buttonLB;
  98006. private _buttonRB;
  98007. private _buttonLeftStick;
  98008. private _buttonRightStick;
  98009. private _dPadUp;
  98010. private _dPadDown;
  98011. private _dPadLeft;
  98012. private _dPadRight;
  98013. private _isXboxOnePad;
  98014. /**
  98015. * Creates a new XBox360 gamepad object
  98016. * @param id defines the id of this gamepad
  98017. * @param index defines its index
  98018. * @param gamepad defines the internal HTML gamepad object
  98019. * @param xboxOne defines if it is a XBox One gamepad
  98020. */
  98021. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  98022. /**
  98023. * Defines the callback to call when left trigger is pressed
  98024. * @param callback defines the callback to use
  98025. */
  98026. onlefttriggerchanged(callback: (value: number) => void): void;
  98027. /**
  98028. * Defines the callback to call when right trigger is pressed
  98029. * @param callback defines the callback to use
  98030. */
  98031. onrighttriggerchanged(callback: (value: number) => void): void;
  98032. /**
  98033. * Gets the left trigger value
  98034. */
  98035. /**
  98036. * Sets the left trigger value
  98037. */
  98038. leftTrigger: number;
  98039. /**
  98040. * Gets the right trigger value
  98041. */
  98042. /**
  98043. * Sets the right trigger value
  98044. */
  98045. rightTrigger: number;
  98046. /**
  98047. * Defines the callback to call when a button is pressed
  98048. * @param callback defines the callback to use
  98049. */
  98050. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  98051. /**
  98052. * Defines the callback to call when a button is released
  98053. * @param callback defines the callback to use
  98054. */
  98055. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  98056. /**
  98057. * Defines the callback to call when a pad is pressed
  98058. * @param callback defines the callback to use
  98059. */
  98060. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  98061. /**
  98062. * Defines the callback to call when a pad is released
  98063. * @param callback defines the callback to use
  98064. */
  98065. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  98066. private _setButtonValue;
  98067. private _setDPadValue;
  98068. /**
  98069. * Gets the value of the `A` button
  98070. */
  98071. /**
  98072. * Sets the value of the `A` button
  98073. */
  98074. buttonA: number;
  98075. /**
  98076. * Gets the value of the `B` button
  98077. */
  98078. /**
  98079. * Sets the value of the `B` button
  98080. */
  98081. buttonB: number;
  98082. /**
  98083. * Gets the value of the `X` button
  98084. */
  98085. /**
  98086. * Sets the value of the `X` button
  98087. */
  98088. buttonX: number;
  98089. /**
  98090. * Gets the value of the `Y` button
  98091. */
  98092. /**
  98093. * Sets the value of the `Y` button
  98094. */
  98095. buttonY: number;
  98096. /**
  98097. * Gets the value of the `Start` button
  98098. */
  98099. /**
  98100. * Sets the value of the `Start` button
  98101. */
  98102. buttonStart: number;
  98103. /**
  98104. * Gets the value of the `Back` button
  98105. */
  98106. /**
  98107. * Sets the value of the `Back` button
  98108. */
  98109. buttonBack: number;
  98110. /**
  98111. * Gets the value of the `Left` button
  98112. */
  98113. /**
  98114. * Sets the value of the `Left` button
  98115. */
  98116. buttonLB: number;
  98117. /**
  98118. * Gets the value of the `Right` button
  98119. */
  98120. /**
  98121. * Sets the value of the `Right` button
  98122. */
  98123. buttonRB: number;
  98124. /**
  98125. * Gets the value of the Left joystick
  98126. */
  98127. /**
  98128. * Sets the value of the Left joystick
  98129. */
  98130. buttonLeftStick: number;
  98131. /**
  98132. * Gets the value of the Right joystick
  98133. */
  98134. /**
  98135. * Sets the value of the Right joystick
  98136. */
  98137. buttonRightStick: number;
  98138. /**
  98139. * Gets the value of D-pad up
  98140. */
  98141. /**
  98142. * Sets the value of D-pad up
  98143. */
  98144. dPadUp: number;
  98145. /**
  98146. * Gets the value of D-pad down
  98147. */
  98148. /**
  98149. * Sets the value of D-pad down
  98150. */
  98151. dPadDown: number;
  98152. /**
  98153. * Gets the value of D-pad left
  98154. */
  98155. /**
  98156. * Sets the value of D-pad left
  98157. */
  98158. dPadLeft: number;
  98159. /**
  98160. * Gets the value of D-pad right
  98161. */
  98162. /**
  98163. * Sets the value of D-pad right
  98164. */
  98165. dPadRight: number;
  98166. /**
  98167. * Force the gamepad to synchronize with device values
  98168. */
  98169. update(): void;
  98170. /**
  98171. * Disposes the gamepad
  98172. */
  98173. dispose(): void;
  98174. }
  98175. }
  98176. declare module BABYLON {
  98177. /**
  98178. * Base class of materials working in push mode in babylon JS
  98179. * @hidden
  98180. */
  98181. export class PushMaterial extends Material {
  98182. protected _activeEffect: Effect;
  98183. protected _normalMatrix: Matrix;
  98184. /**
  98185. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98186. * This means that the material can keep using a previous shader while a new one is being compiled.
  98187. * This is mostly used when shader parallel compilation is supported (true by default)
  98188. */
  98189. allowShaderHotSwapping: boolean;
  98190. constructor(name: string, scene: Scene);
  98191. getEffect(): Effect;
  98192. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98193. /**
  98194. * Binds the given world matrix to the active effect
  98195. *
  98196. * @param world the matrix to bind
  98197. */
  98198. bindOnlyWorldMatrix(world: Matrix): void;
  98199. /**
  98200. * Binds the given normal matrix to the active effect
  98201. *
  98202. * @param normalMatrix the matrix to bind
  98203. */
  98204. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98205. bind(world: Matrix, mesh?: Mesh): void;
  98206. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98207. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98208. }
  98209. }
  98210. declare module BABYLON {
  98211. /**
  98212. * This groups all the flags used to control the materials channel.
  98213. */
  98214. export class MaterialFlags {
  98215. private static _DiffuseTextureEnabled;
  98216. /**
  98217. * Are diffuse textures enabled in the application.
  98218. */
  98219. static DiffuseTextureEnabled: boolean;
  98220. private static _AmbientTextureEnabled;
  98221. /**
  98222. * Are ambient textures enabled in the application.
  98223. */
  98224. static AmbientTextureEnabled: boolean;
  98225. private static _OpacityTextureEnabled;
  98226. /**
  98227. * Are opacity textures enabled in the application.
  98228. */
  98229. static OpacityTextureEnabled: boolean;
  98230. private static _ReflectionTextureEnabled;
  98231. /**
  98232. * Are reflection textures enabled in the application.
  98233. */
  98234. static ReflectionTextureEnabled: boolean;
  98235. private static _EmissiveTextureEnabled;
  98236. /**
  98237. * Are emissive textures enabled in the application.
  98238. */
  98239. static EmissiveTextureEnabled: boolean;
  98240. private static _SpecularTextureEnabled;
  98241. /**
  98242. * Are specular textures enabled in the application.
  98243. */
  98244. static SpecularTextureEnabled: boolean;
  98245. private static _BumpTextureEnabled;
  98246. /**
  98247. * Are bump textures enabled in the application.
  98248. */
  98249. static BumpTextureEnabled: boolean;
  98250. private static _LightmapTextureEnabled;
  98251. /**
  98252. * Are lightmap textures enabled in the application.
  98253. */
  98254. static LightmapTextureEnabled: boolean;
  98255. private static _RefractionTextureEnabled;
  98256. /**
  98257. * Are refraction textures enabled in the application.
  98258. */
  98259. static RefractionTextureEnabled: boolean;
  98260. private static _ColorGradingTextureEnabled;
  98261. /**
  98262. * Are color grading textures enabled in the application.
  98263. */
  98264. static ColorGradingTextureEnabled: boolean;
  98265. private static _FresnelEnabled;
  98266. /**
  98267. * Are fresnels enabled in the application.
  98268. */
  98269. static FresnelEnabled: boolean;
  98270. private static _ClearCoatTextureEnabled;
  98271. /**
  98272. * Are clear coat textures enabled in the application.
  98273. */
  98274. static ClearCoatTextureEnabled: boolean;
  98275. private static _ClearCoatBumpTextureEnabled;
  98276. /**
  98277. * Are clear coat bump textures enabled in the application.
  98278. */
  98279. static ClearCoatBumpTextureEnabled: boolean;
  98280. private static _ClearCoatTintTextureEnabled;
  98281. /**
  98282. * Are clear coat tint textures enabled in the application.
  98283. */
  98284. static ClearCoatTintTextureEnabled: boolean;
  98285. private static _SheenTextureEnabled;
  98286. /**
  98287. * Are sheen textures enabled in the application.
  98288. */
  98289. static SheenTextureEnabled: boolean;
  98290. private static _AnisotropicTextureEnabled;
  98291. /**
  98292. * Are anisotropic textures enabled in the application.
  98293. */
  98294. static AnisotropicTextureEnabled: boolean;
  98295. private static _ThicknessTextureEnabled;
  98296. /**
  98297. * Are thickness textures enabled in the application.
  98298. */
  98299. static ThicknessTextureEnabled: boolean;
  98300. }
  98301. }
  98302. declare module BABYLON {
  98303. /** @hidden */
  98304. export var defaultFragmentDeclaration: {
  98305. name: string;
  98306. shader: string;
  98307. };
  98308. }
  98309. declare module BABYLON {
  98310. /** @hidden */
  98311. export var defaultUboDeclaration: {
  98312. name: string;
  98313. shader: string;
  98314. };
  98315. }
  98316. declare module BABYLON {
  98317. /** @hidden */
  98318. export var lightFragmentDeclaration: {
  98319. name: string;
  98320. shader: string;
  98321. };
  98322. }
  98323. declare module BABYLON {
  98324. /** @hidden */
  98325. export var lightUboDeclaration: {
  98326. name: string;
  98327. shader: string;
  98328. };
  98329. }
  98330. declare module BABYLON {
  98331. /** @hidden */
  98332. export var lightsFragmentFunctions: {
  98333. name: string;
  98334. shader: string;
  98335. };
  98336. }
  98337. declare module BABYLON {
  98338. /** @hidden */
  98339. export var shadowsFragmentFunctions: {
  98340. name: string;
  98341. shader: string;
  98342. };
  98343. }
  98344. declare module BABYLON {
  98345. /** @hidden */
  98346. export var fresnelFunction: {
  98347. name: string;
  98348. shader: string;
  98349. };
  98350. }
  98351. declare module BABYLON {
  98352. /** @hidden */
  98353. export var reflectionFunction: {
  98354. name: string;
  98355. shader: string;
  98356. };
  98357. }
  98358. declare module BABYLON {
  98359. /** @hidden */
  98360. export var bumpFragmentFunctions: {
  98361. name: string;
  98362. shader: string;
  98363. };
  98364. }
  98365. declare module BABYLON {
  98366. /** @hidden */
  98367. export var logDepthDeclaration: {
  98368. name: string;
  98369. shader: string;
  98370. };
  98371. }
  98372. declare module BABYLON {
  98373. /** @hidden */
  98374. export var bumpFragment: {
  98375. name: string;
  98376. shader: string;
  98377. };
  98378. }
  98379. declare module BABYLON {
  98380. /** @hidden */
  98381. export var depthPrePass: {
  98382. name: string;
  98383. shader: string;
  98384. };
  98385. }
  98386. declare module BABYLON {
  98387. /** @hidden */
  98388. export var lightFragment: {
  98389. name: string;
  98390. shader: string;
  98391. };
  98392. }
  98393. declare module BABYLON {
  98394. /** @hidden */
  98395. export var logDepthFragment: {
  98396. name: string;
  98397. shader: string;
  98398. };
  98399. }
  98400. declare module BABYLON {
  98401. /** @hidden */
  98402. export var defaultPixelShader: {
  98403. name: string;
  98404. shader: string;
  98405. };
  98406. }
  98407. declare module BABYLON {
  98408. /** @hidden */
  98409. export var defaultVertexDeclaration: {
  98410. name: string;
  98411. shader: string;
  98412. };
  98413. }
  98414. declare module BABYLON {
  98415. /** @hidden */
  98416. export var bumpVertexDeclaration: {
  98417. name: string;
  98418. shader: string;
  98419. };
  98420. }
  98421. declare module BABYLON {
  98422. /** @hidden */
  98423. export var bumpVertex: {
  98424. name: string;
  98425. shader: string;
  98426. };
  98427. }
  98428. declare module BABYLON {
  98429. /** @hidden */
  98430. export var fogVertex: {
  98431. name: string;
  98432. shader: string;
  98433. };
  98434. }
  98435. declare module BABYLON {
  98436. /** @hidden */
  98437. export var shadowsVertex: {
  98438. name: string;
  98439. shader: string;
  98440. };
  98441. }
  98442. declare module BABYLON {
  98443. /** @hidden */
  98444. export var pointCloudVertex: {
  98445. name: string;
  98446. shader: string;
  98447. };
  98448. }
  98449. declare module BABYLON {
  98450. /** @hidden */
  98451. export var logDepthVertex: {
  98452. name: string;
  98453. shader: string;
  98454. };
  98455. }
  98456. declare module BABYLON {
  98457. /** @hidden */
  98458. export var defaultVertexShader: {
  98459. name: string;
  98460. shader: string;
  98461. };
  98462. }
  98463. declare module BABYLON {
  98464. /** @hidden */
  98465. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98466. MAINUV1: boolean;
  98467. MAINUV2: boolean;
  98468. DIFFUSE: boolean;
  98469. DIFFUSEDIRECTUV: number;
  98470. AMBIENT: boolean;
  98471. AMBIENTDIRECTUV: number;
  98472. OPACITY: boolean;
  98473. OPACITYDIRECTUV: number;
  98474. OPACITYRGB: boolean;
  98475. REFLECTION: boolean;
  98476. EMISSIVE: boolean;
  98477. EMISSIVEDIRECTUV: number;
  98478. SPECULAR: boolean;
  98479. SPECULARDIRECTUV: number;
  98480. BUMP: boolean;
  98481. BUMPDIRECTUV: number;
  98482. PARALLAX: boolean;
  98483. PARALLAXOCCLUSION: boolean;
  98484. SPECULAROVERALPHA: boolean;
  98485. CLIPPLANE: boolean;
  98486. CLIPPLANE2: boolean;
  98487. CLIPPLANE3: boolean;
  98488. CLIPPLANE4: boolean;
  98489. ALPHATEST: boolean;
  98490. DEPTHPREPASS: boolean;
  98491. ALPHAFROMDIFFUSE: boolean;
  98492. POINTSIZE: boolean;
  98493. FOG: boolean;
  98494. SPECULARTERM: boolean;
  98495. DIFFUSEFRESNEL: boolean;
  98496. OPACITYFRESNEL: boolean;
  98497. REFLECTIONFRESNEL: boolean;
  98498. REFRACTIONFRESNEL: boolean;
  98499. EMISSIVEFRESNEL: boolean;
  98500. FRESNEL: boolean;
  98501. NORMAL: boolean;
  98502. UV1: boolean;
  98503. UV2: boolean;
  98504. VERTEXCOLOR: boolean;
  98505. VERTEXALPHA: boolean;
  98506. NUM_BONE_INFLUENCERS: number;
  98507. BonesPerMesh: number;
  98508. BONETEXTURE: boolean;
  98509. INSTANCES: boolean;
  98510. GLOSSINESS: boolean;
  98511. ROUGHNESS: boolean;
  98512. EMISSIVEASILLUMINATION: boolean;
  98513. LINKEMISSIVEWITHDIFFUSE: boolean;
  98514. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98515. LIGHTMAP: boolean;
  98516. LIGHTMAPDIRECTUV: number;
  98517. OBJECTSPACE_NORMALMAP: boolean;
  98518. USELIGHTMAPASSHADOWMAP: boolean;
  98519. REFLECTIONMAP_3D: boolean;
  98520. REFLECTIONMAP_SPHERICAL: boolean;
  98521. REFLECTIONMAP_PLANAR: boolean;
  98522. REFLECTIONMAP_CUBIC: boolean;
  98523. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98524. REFLECTIONMAP_PROJECTION: boolean;
  98525. REFLECTIONMAP_SKYBOX: boolean;
  98526. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98527. REFLECTIONMAP_EXPLICIT: boolean;
  98528. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98529. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98530. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98531. INVERTCUBICMAP: boolean;
  98532. LOGARITHMICDEPTH: boolean;
  98533. REFRACTION: boolean;
  98534. REFRACTIONMAP_3D: boolean;
  98535. REFLECTIONOVERALPHA: boolean;
  98536. TWOSIDEDLIGHTING: boolean;
  98537. SHADOWFLOAT: boolean;
  98538. MORPHTARGETS: boolean;
  98539. MORPHTARGETS_NORMAL: boolean;
  98540. MORPHTARGETS_TANGENT: boolean;
  98541. NUM_MORPH_INFLUENCERS: number;
  98542. NONUNIFORMSCALING: boolean;
  98543. PREMULTIPLYALPHA: boolean;
  98544. IMAGEPROCESSING: boolean;
  98545. VIGNETTE: boolean;
  98546. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98547. VIGNETTEBLENDMODEOPAQUE: boolean;
  98548. TONEMAPPING: boolean;
  98549. TONEMAPPING_ACES: boolean;
  98550. CONTRAST: boolean;
  98551. COLORCURVES: boolean;
  98552. COLORGRADING: boolean;
  98553. COLORGRADING3D: boolean;
  98554. SAMPLER3DGREENDEPTH: boolean;
  98555. SAMPLER3DBGRMAP: boolean;
  98556. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98557. MULTIVIEW: boolean;
  98558. /**
  98559. * If the reflection texture on this material is in linear color space
  98560. * @hidden
  98561. */
  98562. IS_REFLECTION_LINEAR: boolean;
  98563. /**
  98564. * If the refraction texture on this material is in linear color space
  98565. * @hidden
  98566. */
  98567. IS_REFRACTION_LINEAR: boolean;
  98568. EXPOSURE: boolean;
  98569. constructor();
  98570. setReflectionMode(modeToEnable: string): void;
  98571. }
  98572. /**
  98573. * This is the default material used in Babylon. It is the best trade off between quality
  98574. * and performances.
  98575. * @see http://doc.babylonjs.com/babylon101/materials
  98576. */
  98577. export class StandardMaterial extends PushMaterial {
  98578. private _diffuseTexture;
  98579. /**
  98580. * The basic texture of the material as viewed under a light.
  98581. */
  98582. diffuseTexture: Nullable<BaseTexture>;
  98583. private _ambientTexture;
  98584. /**
  98585. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98586. */
  98587. ambientTexture: Nullable<BaseTexture>;
  98588. private _opacityTexture;
  98589. /**
  98590. * Define the transparency of the material from a texture.
  98591. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98592. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98593. */
  98594. opacityTexture: Nullable<BaseTexture>;
  98595. private _reflectionTexture;
  98596. /**
  98597. * Define the texture used to display the reflection.
  98598. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98599. */
  98600. reflectionTexture: Nullable<BaseTexture>;
  98601. private _emissiveTexture;
  98602. /**
  98603. * Define texture of the material as if self lit.
  98604. * This will be mixed in the final result even in the absence of light.
  98605. */
  98606. emissiveTexture: Nullable<BaseTexture>;
  98607. private _specularTexture;
  98608. /**
  98609. * Define how the color and intensity of the highlight given by the light in the material.
  98610. */
  98611. specularTexture: Nullable<BaseTexture>;
  98612. private _bumpTexture;
  98613. /**
  98614. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98615. * 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.
  98616. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98617. */
  98618. bumpTexture: Nullable<BaseTexture>;
  98619. private _lightmapTexture;
  98620. /**
  98621. * Complex lighting can be computationally expensive to compute at runtime.
  98622. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98623. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98624. */
  98625. lightmapTexture: Nullable<BaseTexture>;
  98626. private _refractionTexture;
  98627. /**
  98628. * Define the texture used to display the refraction.
  98629. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98630. */
  98631. refractionTexture: Nullable<BaseTexture>;
  98632. /**
  98633. * The color of the material lit by the environmental background lighting.
  98634. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98635. */
  98636. ambientColor: Color3;
  98637. /**
  98638. * The basic color of the material as viewed under a light.
  98639. */
  98640. diffuseColor: Color3;
  98641. /**
  98642. * Define how the color and intensity of the highlight given by the light in the material.
  98643. */
  98644. specularColor: Color3;
  98645. /**
  98646. * Define the color of the material as if self lit.
  98647. * This will be mixed in the final result even in the absence of light.
  98648. */
  98649. emissiveColor: Color3;
  98650. /**
  98651. * Defines how sharp are the highlights in the material.
  98652. * The bigger the value the sharper giving a more glossy feeling to the result.
  98653. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98654. */
  98655. specularPower: number;
  98656. private _useAlphaFromDiffuseTexture;
  98657. /**
  98658. * Does the transparency come from the diffuse texture alpha channel.
  98659. */
  98660. useAlphaFromDiffuseTexture: boolean;
  98661. private _useEmissiveAsIllumination;
  98662. /**
  98663. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98664. */
  98665. useEmissiveAsIllumination: boolean;
  98666. private _linkEmissiveWithDiffuse;
  98667. /**
  98668. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98669. * the emissive level when the final color is close to one.
  98670. */
  98671. linkEmissiveWithDiffuse: boolean;
  98672. private _useSpecularOverAlpha;
  98673. /**
  98674. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98675. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98676. */
  98677. useSpecularOverAlpha: boolean;
  98678. private _useReflectionOverAlpha;
  98679. /**
  98680. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98681. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98682. */
  98683. useReflectionOverAlpha: boolean;
  98684. private _disableLighting;
  98685. /**
  98686. * Does lights from the scene impacts this material.
  98687. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98688. */
  98689. disableLighting: boolean;
  98690. private _useObjectSpaceNormalMap;
  98691. /**
  98692. * Allows using an object space normal map (instead of tangent space).
  98693. */
  98694. useObjectSpaceNormalMap: boolean;
  98695. private _useParallax;
  98696. /**
  98697. * Is parallax enabled or not.
  98698. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98699. */
  98700. useParallax: boolean;
  98701. private _useParallaxOcclusion;
  98702. /**
  98703. * Is parallax occlusion enabled or not.
  98704. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98706. */
  98707. useParallaxOcclusion: boolean;
  98708. /**
  98709. * 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.
  98710. */
  98711. parallaxScaleBias: number;
  98712. private _roughness;
  98713. /**
  98714. * Helps to define how blurry the reflections should appears in the material.
  98715. */
  98716. roughness: number;
  98717. /**
  98718. * In case of refraction, define the value of the indice of refraction.
  98719. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98720. */
  98721. indexOfRefraction: number;
  98722. /**
  98723. * Invert the refraction texture alongside the y axis.
  98724. * It can be useful with procedural textures or probe for instance.
  98725. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98726. */
  98727. invertRefractionY: boolean;
  98728. /**
  98729. * Defines the alpha limits in alpha test mode.
  98730. */
  98731. alphaCutOff: number;
  98732. private _useLightmapAsShadowmap;
  98733. /**
  98734. * In case of light mapping, define whether the map contains light or shadow informations.
  98735. */
  98736. useLightmapAsShadowmap: boolean;
  98737. private _diffuseFresnelParameters;
  98738. /**
  98739. * Define the diffuse fresnel parameters of the material.
  98740. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98741. */
  98742. diffuseFresnelParameters: FresnelParameters;
  98743. private _opacityFresnelParameters;
  98744. /**
  98745. * Define the opacity fresnel parameters of the material.
  98746. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98747. */
  98748. opacityFresnelParameters: FresnelParameters;
  98749. private _reflectionFresnelParameters;
  98750. /**
  98751. * Define the reflection fresnel parameters of the material.
  98752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98753. */
  98754. reflectionFresnelParameters: FresnelParameters;
  98755. private _refractionFresnelParameters;
  98756. /**
  98757. * Define the refraction fresnel parameters of the material.
  98758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98759. */
  98760. refractionFresnelParameters: FresnelParameters;
  98761. private _emissiveFresnelParameters;
  98762. /**
  98763. * Define the emissive fresnel parameters of the material.
  98764. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98765. */
  98766. emissiveFresnelParameters: FresnelParameters;
  98767. private _useReflectionFresnelFromSpecular;
  98768. /**
  98769. * If true automatically deducts the fresnels values from the material specularity.
  98770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98771. */
  98772. useReflectionFresnelFromSpecular: boolean;
  98773. private _useGlossinessFromSpecularMapAlpha;
  98774. /**
  98775. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98776. */
  98777. useGlossinessFromSpecularMapAlpha: boolean;
  98778. private _maxSimultaneousLights;
  98779. /**
  98780. * Defines the maximum number of lights that can be used in the material
  98781. */
  98782. maxSimultaneousLights: number;
  98783. private _invertNormalMapX;
  98784. /**
  98785. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98786. */
  98787. invertNormalMapX: boolean;
  98788. private _invertNormalMapY;
  98789. /**
  98790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98791. */
  98792. invertNormalMapY: boolean;
  98793. private _twoSidedLighting;
  98794. /**
  98795. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98796. */
  98797. twoSidedLighting: boolean;
  98798. /**
  98799. * Default configuration related to image processing available in the standard Material.
  98800. */
  98801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98802. /**
  98803. * Gets the image processing configuration used either in this material.
  98804. */
  98805. /**
  98806. * Sets the Default image processing configuration used either in the this material.
  98807. *
  98808. * If sets to null, the scene one is in use.
  98809. */
  98810. imageProcessingConfiguration: ImageProcessingConfiguration;
  98811. /**
  98812. * Keep track of the image processing observer to allow dispose and replace.
  98813. */
  98814. private _imageProcessingObserver;
  98815. /**
  98816. * Attaches a new image processing configuration to the Standard Material.
  98817. * @param configuration
  98818. */
  98819. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98820. /**
  98821. * Gets wether the color curves effect is enabled.
  98822. */
  98823. /**
  98824. * Sets wether the color curves effect is enabled.
  98825. */
  98826. cameraColorCurvesEnabled: boolean;
  98827. /**
  98828. * Gets wether the color grading effect is enabled.
  98829. */
  98830. /**
  98831. * Gets wether the color grading effect is enabled.
  98832. */
  98833. cameraColorGradingEnabled: boolean;
  98834. /**
  98835. * Gets wether tonemapping is enabled or not.
  98836. */
  98837. /**
  98838. * Sets wether tonemapping is enabled or not
  98839. */
  98840. cameraToneMappingEnabled: boolean;
  98841. /**
  98842. * The camera exposure used on this material.
  98843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98844. * This corresponds to a photographic exposure.
  98845. */
  98846. /**
  98847. * The camera exposure used on this material.
  98848. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98849. * This corresponds to a photographic exposure.
  98850. */
  98851. cameraExposure: number;
  98852. /**
  98853. * Gets The camera contrast used on this material.
  98854. */
  98855. /**
  98856. * Sets The camera contrast used on this material.
  98857. */
  98858. cameraContrast: number;
  98859. /**
  98860. * Gets the Color Grading 2D Lookup Texture.
  98861. */
  98862. /**
  98863. * Sets the Color Grading 2D Lookup Texture.
  98864. */
  98865. cameraColorGradingTexture: Nullable<BaseTexture>;
  98866. /**
  98867. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98868. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98869. * 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;
  98870. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98871. */
  98872. /**
  98873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98875. * 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;
  98876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98877. */
  98878. cameraColorCurves: Nullable<ColorCurves>;
  98879. /**
  98880. * Custom callback helping to override the default shader used in the material.
  98881. */
  98882. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98883. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98884. protected _worldViewProjectionMatrix: Matrix;
  98885. protected _globalAmbientColor: Color3;
  98886. protected _useLogarithmicDepth: boolean;
  98887. /**
  98888. * Instantiates a new standard material.
  98889. * This is the default material used in Babylon. It is the best trade off between quality
  98890. * and performances.
  98891. * @see http://doc.babylonjs.com/babylon101/materials
  98892. * @param name Define the name of the material in the scene
  98893. * @param scene Define the scene the material belong to
  98894. */
  98895. constructor(name: string, scene: Scene);
  98896. /**
  98897. * Gets a boolean indicating that current material needs to register RTT
  98898. */
  98899. readonly hasRenderTargetTextures: boolean;
  98900. /**
  98901. * Gets the current class name of the material e.g. "StandardMaterial"
  98902. * Mainly use in serialization.
  98903. * @returns the class name
  98904. */
  98905. getClassName(): string;
  98906. /**
  98907. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98908. * You can try switching to logarithmic depth.
  98909. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98910. */
  98911. useLogarithmicDepth: boolean;
  98912. /**
  98913. * Specifies if the material will require alpha blending
  98914. * @returns a boolean specifying if alpha blending is needed
  98915. */
  98916. needAlphaBlending(): boolean;
  98917. /**
  98918. * Specifies if this material should be rendered in alpha test mode
  98919. * @returns a boolean specifying if an alpha test is needed.
  98920. */
  98921. needAlphaTesting(): boolean;
  98922. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98923. /**
  98924. * Get the texture used for alpha test purpose.
  98925. * @returns the diffuse texture in case of the standard material.
  98926. */
  98927. getAlphaTestTexture(): Nullable<BaseTexture>;
  98928. /**
  98929. * Get if the submesh is ready to be used and all its information available.
  98930. * Child classes can use it to update shaders
  98931. * @param mesh defines the mesh to check
  98932. * @param subMesh defines which submesh to check
  98933. * @param useInstances specifies that instances should be used
  98934. * @returns a boolean indicating that the submesh is ready or not
  98935. */
  98936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98937. /**
  98938. * Builds the material UBO layouts.
  98939. * Used internally during the effect preparation.
  98940. */
  98941. buildUniformLayout(): void;
  98942. /**
  98943. * Unbinds the material from the mesh
  98944. */
  98945. unbind(): void;
  98946. /**
  98947. * Binds the submesh to this material by preparing the effect and shader to draw
  98948. * @param world defines the world transformation matrix
  98949. * @param mesh defines the mesh containing the submesh
  98950. * @param subMesh defines the submesh to bind the material to
  98951. */
  98952. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98953. /**
  98954. * Get the list of animatables in the material.
  98955. * @returns the list of animatables object used in the material
  98956. */
  98957. getAnimatables(): IAnimatable[];
  98958. /**
  98959. * Gets the active textures from the material
  98960. * @returns an array of textures
  98961. */
  98962. getActiveTextures(): BaseTexture[];
  98963. /**
  98964. * Specifies if the material uses a texture
  98965. * @param texture defines the texture to check against the material
  98966. * @returns a boolean specifying if the material uses the texture
  98967. */
  98968. hasTexture(texture: BaseTexture): boolean;
  98969. /**
  98970. * Disposes the material
  98971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98973. */
  98974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98975. /**
  98976. * Makes a duplicate of the material, and gives it a new name
  98977. * @param name defines the new name for the duplicated material
  98978. * @returns the cloned material
  98979. */
  98980. clone(name: string): StandardMaterial;
  98981. /**
  98982. * Serializes this material in a JSON representation
  98983. * @returns the serialized material object
  98984. */
  98985. serialize(): any;
  98986. /**
  98987. * Creates a standard material from parsed material data
  98988. * @param source defines the JSON representation of the material
  98989. * @param scene defines the hosting scene
  98990. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98991. * @returns a new standard material
  98992. */
  98993. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98994. /**
  98995. * Are diffuse textures enabled in the application.
  98996. */
  98997. static DiffuseTextureEnabled: boolean;
  98998. /**
  98999. * Are ambient textures enabled in the application.
  99000. */
  99001. static AmbientTextureEnabled: boolean;
  99002. /**
  99003. * Are opacity textures enabled in the application.
  99004. */
  99005. static OpacityTextureEnabled: boolean;
  99006. /**
  99007. * Are reflection textures enabled in the application.
  99008. */
  99009. static ReflectionTextureEnabled: boolean;
  99010. /**
  99011. * Are emissive textures enabled in the application.
  99012. */
  99013. static EmissiveTextureEnabled: boolean;
  99014. /**
  99015. * Are specular textures enabled in the application.
  99016. */
  99017. static SpecularTextureEnabled: boolean;
  99018. /**
  99019. * Are bump textures enabled in the application.
  99020. */
  99021. static BumpTextureEnabled: boolean;
  99022. /**
  99023. * Are lightmap textures enabled in the application.
  99024. */
  99025. static LightmapTextureEnabled: boolean;
  99026. /**
  99027. * Are refraction textures enabled in the application.
  99028. */
  99029. static RefractionTextureEnabled: boolean;
  99030. /**
  99031. * Are color grading textures enabled in the application.
  99032. */
  99033. static ColorGradingTextureEnabled: boolean;
  99034. /**
  99035. * Are fresnels enabled in the application.
  99036. */
  99037. static FresnelEnabled: boolean;
  99038. }
  99039. }
  99040. declare module BABYLON {
  99041. /**
  99042. * A class extending Texture allowing drawing on a texture
  99043. * @see http://doc.babylonjs.com/how_to/dynamictexture
  99044. */
  99045. export class DynamicTexture extends Texture {
  99046. private _generateMipMaps;
  99047. private _canvas;
  99048. private _context;
  99049. private _engine;
  99050. /**
  99051. * Creates a DynamicTexture
  99052. * @param name defines the name of the texture
  99053. * @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
  99054. * @param scene defines the scene where you want the texture
  99055. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  99056. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  99057. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  99058. */
  99059. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  99060. /**
  99061. * Get the current class name of the texture useful for serialization or dynamic coding.
  99062. * @returns "DynamicTexture"
  99063. */
  99064. getClassName(): string;
  99065. /**
  99066. * Gets the current state of canRescale
  99067. */
  99068. readonly canRescale: boolean;
  99069. private _recreate;
  99070. /**
  99071. * Scales the texture
  99072. * @param ratio the scale factor to apply to both width and height
  99073. */
  99074. scale(ratio: number): void;
  99075. /**
  99076. * Resizes the texture
  99077. * @param width the new width
  99078. * @param height the new height
  99079. */
  99080. scaleTo(width: number, height: number): void;
  99081. /**
  99082. * Gets the context of the canvas used by the texture
  99083. * @returns the canvas context of the dynamic texture
  99084. */
  99085. getContext(): CanvasRenderingContext2D;
  99086. /**
  99087. * Clears the texture
  99088. */
  99089. clear(): void;
  99090. /**
  99091. * Updates the texture
  99092. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99093. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  99094. */
  99095. update(invertY?: boolean, premulAlpha?: boolean): void;
  99096. /**
  99097. * Draws text onto the texture
  99098. * @param text defines the text to be drawn
  99099. * @param x defines the placement of the text from the left
  99100. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  99101. * @param font defines the font to be used with font-style, font-size, font-name
  99102. * @param color defines the color used for the text
  99103. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  99104. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  99105. * @param update defines whether texture is immediately update (default is true)
  99106. */
  99107. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  99108. /**
  99109. * Clones the texture
  99110. * @returns the clone of the texture.
  99111. */
  99112. clone(): DynamicTexture;
  99113. /**
  99114. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  99115. * @returns a serialized dynamic texture object
  99116. */
  99117. serialize(): any;
  99118. /** @hidden */
  99119. _rebuild(): void;
  99120. }
  99121. }
  99122. declare module BABYLON {
  99123. /** @hidden */
  99124. export var imageProcessingPixelShader: {
  99125. name: string;
  99126. shader: string;
  99127. };
  99128. }
  99129. declare module BABYLON {
  99130. /**
  99131. * ImageProcessingPostProcess
  99132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99133. */
  99134. export class ImageProcessingPostProcess extends PostProcess {
  99135. /**
  99136. * Default configuration related to image processing available in the PBR Material.
  99137. */
  99138. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99139. /**
  99140. * Gets the image processing configuration used either in this material.
  99141. */
  99142. /**
  99143. * Sets the Default image processing configuration used either in the this material.
  99144. *
  99145. * If sets to null, the scene one is in use.
  99146. */
  99147. imageProcessingConfiguration: ImageProcessingConfiguration;
  99148. /**
  99149. * Keep track of the image processing observer to allow dispose and replace.
  99150. */
  99151. private _imageProcessingObserver;
  99152. /**
  99153. * Attaches a new image processing configuration to the PBR Material.
  99154. * @param configuration
  99155. */
  99156. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99157. /**
  99158. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99159. */
  99160. /**
  99161. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99162. */
  99163. colorCurves: Nullable<ColorCurves>;
  99164. /**
  99165. * Gets wether the color curves effect is enabled.
  99166. */
  99167. /**
  99168. * Sets wether the color curves effect is enabled.
  99169. */
  99170. colorCurvesEnabled: boolean;
  99171. /**
  99172. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99173. */
  99174. /**
  99175. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99176. */
  99177. colorGradingTexture: Nullable<BaseTexture>;
  99178. /**
  99179. * Gets wether the color grading effect is enabled.
  99180. */
  99181. /**
  99182. * Gets wether the color grading effect is enabled.
  99183. */
  99184. colorGradingEnabled: boolean;
  99185. /**
  99186. * Gets exposure used in the effect.
  99187. */
  99188. /**
  99189. * Sets exposure used in the effect.
  99190. */
  99191. exposure: number;
  99192. /**
  99193. * Gets wether tonemapping is enabled or not.
  99194. */
  99195. /**
  99196. * Sets wether tonemapping is enabled or not
  99197. */
  99198. toneMappingEnabled: boolean;
  99199. /**
  99200. * Gets the type of tone mapping effect.
  99201. */
  99202. /**
  99203. * Sets the type of tone mapping effect.
  99204. */
  99205. toneMappingType: number;
  99206. /**
  99207. * Gets contrast used in the effect.
  99208. */
  99209. /**
  99210. * Sets contrast used in the effect.
  99211. */
  99212. contrast: number;
  99213. /**
  99214. * Gets Vignette stretch size.
  99215. */
  99216. /**
  99217. * Sets Vignette stretch size.
  99218. */
  99219. vignetteStretch: number;
  99220. /**
  99221. * Gets Vignette centre X Offset.
  99222. */
  99223. /**
  99224. * Sets Vignette centre X Offset.
  99225. */
  99226. vignetteCentreX: number;
  99227. /**
  99228. * Gets Vignette centre Y Offset.
  99229. */
  99230. /**
  99231. * Sets Vignette centre Y Offset.
  99232. */
  99233. vignetteCentreY: number;
  99234. /**
  99235. * Gets Vignette weight or intensity of the vignette effect.
  99236. */
  99237. /**
  99238. * Sets Vignette weight or intensity of the vignette effect.
  99239. */
  99240. vignetteWeight: number;
  99241. /**
  99242. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99243. * if vignetteEnabled is set to true.
  99244. */
  99245. /**
  99246. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99247. * if vignetteEnabled is set to true.
  99248. */
  99249. vignetteColor: Color4;
  99250. /**
  99251. * Gets Camera field of view used by the Vignette effect.
  99252. */
  99253. /**
  99254. * Sets Camera field of view used by the Vignette effect.
  99255. */
  99256. vignetteCameraFov: number;
  99257. /**
  99258. * Gets the vignette blend mode allowing different kind of effect.
  99259. */
  99260. /**
  99261. * Sets the vignette blend mode allowing different kind of effect.
  99262. */
  99263. vignetteBlendMode: number;
  99264. /**
  99265. * Gets wether the vignette effect is enabled.
  99266. */
  99267. /**
  99268. * Sets wether the vignette effect is enabled.
  99269. */
  99270. vignetteEnabled: boolean;
  99271. private _fromLinearSpace;
  99272. /**
  99273. * Gets wether the input of the processing is in Gamma or Linear Space.
  99274. */
  99275. /**
  99276. * Sets wether the input of the processing is in Gamma or Linear Space.
  99277. */
  99278. fromLinearSpace: boolean;
  99279. /**
  99280. * Defines cache preventing GC.
  99281. */
  99282. private _defines;
  99283. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99284. /**
  99285. * "ImageProcessingPostProcess"
  99286. * @returns "ImageProcessingPostProcess"
  99287. */
  99288. getClassName(): string;
  99289. protected _updateParameters(): void;
  99290. dispose(camera?: Camera): void;
  99291. }
  99292. }
  99293. declare module BABYLON {
  99294. /**
  99295. * Class containing static functions to help procedurally build meshes
  99296. */
  99297. export class GroundBuilder {
  99298. /**
  99299. * Creates a ground mesh
  99300. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  99301. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  99302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99303. * @param name defines the name of the mesh
  99304. * @param options defines the options used to create the mesh
  99305. * @param scene defines the hosting scene
  99306. * @returns the ground mesh
  99307. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  99308. */
  99309. static CreateGround(name: string, options: {
  99310. width?: number;
  99311. height?: number;
  99312. subdivisions?: number;
  99313. subdivisionsX?: number;
  99314. subdivisionsY?: number;
  99315. updatable?: boolean;
  99316. }, scene: any): Mesh;
  99317. /**
  99318. * Creates a tiled ground mesh
  99319. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  99320. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  99321. * * 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
  99322. * * 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
  99323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99324. * @param name defines the name of the mesh
  99325. * @param options defines the options used to create the mesh
  99326. * @param scene defines the hosting scene
  99327. * @returns the tiled ground mesh
  99328. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  99329. */
  99330. static CreateTiledGround(name: string, options: {
  99331. xmin: number;
  99332. zmin: number;
  99333. xmax: number;
  99334. zmax: number;
  99335. subdivisions?: {
  99336. w: number;
  99337. h: number;
  99338. };
  99339. precision?: {
  99340. w: number;
  99341. h: number;
  99342. };
  99343. updatable?: boolean;
  99344. }, scene?: Nullable<Scene>): Mesh;
  99345. /**
  99346. * Creates a ground mesh from a height map
  99347. * * The parameter `url` sets the URL of the height map image resource.
  99348. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  99349. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  99350. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  99351. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  99352. * * 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.
  99353. * * 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).
  99354. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99356. * @param name defines the name of the mesh
  99357. * @param url defines the url to the height map
  99358. * @param options defines the options used to create the mesh
  99359. * @param scene defines the hosting scene
  99360. * @returns the ground mesh
  99361. * @see https://doc.babylonjs.com/babylon101/height_map
  99362. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  99363. */
  99364. static CreateGroundFromHeightMap(name: string, url: string, options: {
  99365. width?: number;
  99366. height?: number;
  99367. subdivisions?: number;
  99368. minHeight?: number;
  99369. maxHeight?: number;
  99370. colorFilter?: Color3;
  99371. alphaFilter?: number;
  99372. updatable?: boolean;
  99373. onReady?: (mesh: GroundMesh) => void;
  99374. }, scene?: Nullable<Scene>): GroundMesh;
  99375. }
  99376. }
  99377. declare module BABYLON {
  99378. /**
  99379. * Class containing static functions to help procedurally build meshes
  99380. */
  99381. export class TorusBuilder {
  99382. /**
  99383. * Creates a torus mesh
  99384. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  99385. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  99386. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  99387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99390. * @param name defines the name of the mesh
  99391. * @param options defines the options used to create the mesh
  99392. * @param scene defines the hosting scene
  99393. * @returns the torus mesh
  99394. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  99395. */
  99396. static CreateTorus(name: string, options: {
  99397. diameter?: number;
  99398. thickness?: number;
  99399. tessellation?: number;
  99400. updatable?: boolean;
  99401. sideOrientation?: number;
  99402. frontUVs?: Vector4;
  99403. backUVs?: Vector4;
  99404. }, scene: any): Mesh;
  99405. }
  99406. }
  99407. declare module BABYLON {
  99408. /**
  99409. * Class containing static functions to help procedurally build meshes
  99410. */
  99411. export class CylinderBuilder {
  99412. /**
  99413. * Creates a cylinder or a cone mesh
  99414. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  99415. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  99416. * * 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.
  99417. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  99418. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  99419. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  99420. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  99421. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  99422. * * 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).
  99423. * * 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
  99424. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  99425. * * 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
  99426. * * 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.
  99427. * * If `enclose` is false, a ring surface is one element.
  99428. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  99429. * * 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
  99430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99433. * @param name defines the name of the mesh
  99434. * @param options defines the options used to create the mesh
  99435. * @param scene defines the hosting scene
  99436. * @returns the cylinder mesh
  99437. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  99438. */
  99439. static CreateCylinder(name: string, options: {
  99440. height?: number;
  99441. diameterTop?: number;
  99442. diameterBottom?: number;
  99443. diameter?: number;
  99444. tessellation?: number;
  99445. subdivisions?: number;
  99446. arc?: number;
  99447. faceColors?: Color4[];
  99448. faceUV?: Vector4[];
  99449. updatable?: boolean;
  99450. hasRings?: boolean;
  99451. enclose?: boolean;
  99452. sideOrientation?: number;
  99453. frontUVs?: Vector4;
  99454. backUVs?: Vector4;
  99455. }, scene: any): Mesh;
  99456. }
  99457. }
  99458. declare module BABYLON {
  99459. /**
  99460. * Manager for handling gamepads
  99461. */
  99462. export class GamepadManager {
  99463. private _scene?;
  99464. private _babylonGamepads;
  99465. private _oneGamepadConnected;
  99466. /** @hidden */
  99467. _isMonitoring: boolean;
  99468. private _gamepadEventSupported;
  99469. private _gamepadSupport;
  99470. /**
  99471. * observable to be triggered when the gamepad controller has been connected
  99472. */
  99473. onGamepadConnectedObservable: Observable<Gamepad>;
  99474. /**
  99475. * observable to be triggered when the gamepad controller has been disconnected
  99476. */
  99477. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99478. private _onGamepadConnectedEvent;
  99479. private _onGamepadDisconnectedEvent;
  99480. /**
  99481. * Initializes the gamepad manager
  99482. * @param _scene BabylonJS scene
  99483. */
  99484. constructor(_scene?: Scene | undefined);
  99485. /**
  99486. * The gamepads in the game pad manager
  99487. */
  99488. readonly gamepads: Gamepad[];
  99489. /**
  99490. * Get the gamepad controllers based on type
  99491. * @param type The type of gamepad controller
  99492. * @returns Nullable gamepad
  99493. */
  99494. getGamepadByType(type?: number): Nullable<Gamepad>;
  99495. /**
  99496. * Disposes the gamepad manager
  99497. */
  99498. dispose(): void;
  99499. private _addNewGamepad;
  99500. private _startMonitoringGamepads;
  99501. private _stopMonitoringGamepads;
  99502. /** @hidden */
  99503. _checkGamepadsStatus(): void;
  99504. private _updateGamepadObjects;
  99505. }
  99506. }
  99507. declare module BABYLON {
  99508. interface Scene {
  99509. /** @hidden */
  99510. _gamepadManager: Nullable<GamepadManager>;
  99511. /**
  99512. * Gets the gamepad manager associated with the scene
  99513. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99514. */
  99515. gamepadManager: GamepadManager;
  99516. }
  99517. /**
  99518. * Interface representing a free camera inputs manager
  99519. */
  99520. interface FreeCameraInputsManager {
  99521. /**
  99522. * Adds gamepad input support to the FreeCameraInputsManager.
  99523. * @returns the FreeCameraInputsManager
  99524. */
  99525. addGamepad(): FreeCameraInputsManager;
  99526. }
  99527. /**
  99528. * Interface representing an arc rotate camera inputs manager
  99529. */
  99530. interface ArcRotateCameraInputsManager {
  99531. /**
  99532. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99533. * @returns the camera inputs manager
  99534. */
  99535. addGamepad(): ArcRotateCameraInputsManager;
  99536. }
  99537. /**
  99538. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99539. */
  99540. export class GamepadSystemSceneComponent implements ISceneComponent {
  99541. /**
  99542. * The component name helpfull to identify the component in the list of scene components.
  99543. */
  99544. readonly name: string;
  99545. /**
  99546. * The scene the component belongs to.
  99547. */
  99548. scene: Scene;
  99549. /**
  99550. * Creates a new instance of the component for the given scene
  99551. * @param scene Defines the scene to register the component in
  99552. */
  99553. constructor(scene: Scene);
  99554. /**
  99555. * Registers the component in a given scene
  99556. */
  99557. register(): void;
  99558. /**
  99559. * Rebuilds the elements related to this component in case of
  99560. * context lost for instance.
  99561. */
  99562. rebuild(): void;
  99563. /**
  99564. * Disposes the component and the associated ressources
  99565. */
  99566. dispose(): void;
  99567. private _beforeCameraUpdate;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * Options to modify the vr teleportation behavior.
  99573. */
  99574. export interface VRTeleportationOptions {
  99575. /**
  99576. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99577. */
  99578. floorMeshName?: string;
  99579. /**
  99580. * A list of meshes to be used as the teleportation floor. (default: empty)
  99581. */
  99582. floorMeshes?: Mesh[];
  99583. }
  99584. /**
  99585. * Options to modify the vr experience helper's behavior.
  99586. */
  99587. export interface VRExperienceHelperOptions extends WebVROptions {
  99588. /**
  99589. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99590. */
  99591. createDeviceOrientationCamera?: boolean;
  99592. /**
  99593. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99594. */
  99595. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99596. /**
  99597. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99598. */
  99599. laserToggle?: boolean;
  99600. /**
  99601. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99602. */
  99603. floorMeshes?: Mesh[];
  99604. /**
  99605. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99606. */
  99607. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99608. }
  99609. /**
  99610. * Event containing information after VR has been entered
  99611. */
  99612. export class OnAfterEnteringVRObservableEvent {
  99613. /**
  99614. * If entering vr was successful
  99615. */
  99616. success: boolean;
  99617. }
  99618. /**
  99619. * Helps to quickly add VR support to an existing scene.
  99620. * See http://doc.babylonjs.com/how_to/webvr_helper
  99621. */
  99622. export class VRExperienceHelper {
  99623. /** Options to modify the vr experience helper's behavior. */
  99624. webVROptions: VRExperienceHelperOptions;
  99625. private _scene;
  99626. private _position;
  99627. private _btnVR;
  99628. private _btnVRDisplayed;
  99629. private _webVRsupported;
  99630. private _webVRready;
  99631. private _webVRrequesting;
  99632. private _webVRpresenting;
  99633. private _hasEnteredVR;
  99634. private _fullscreenVRpresenting;
  99635. private _canvas;
  99636. private _webVRCamera;
  99637. private _vrDeviceOrientationCamera;
  99638. private _deviceOrientationCamera;
  99639. private _existingCamera;
  99640. private _onKeyDown;
  99641. private _onVrDisplayPresentChange;
  99642. private _onVRDisplayChanged;
  99643. private _onVRRequestPresentStart;
  99644. private _onVRRequestPresentComplete;
  99645. /**
  99646. * Observable raised right before entering VR.
  99647. */
  99648. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99649. /**
  99650. * Observable raised when entering VR has completed.
  99651. */
  99652. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99653. /**
  99654. * Observable raised when exiting VR.
  99655. */
  99656. onExitingVRObservable: Observable<VRExperienceHelper>;
  99657. /**
  99658. * Observable raised when controller mesh is loaded.
  99659. */
  99660. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99661. /** Return this.onEnteringVRObservable
  99662. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99663. */
  99664. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99665. /** Return this.onExitingVRObservable
  99666. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99667. */
  99668. readonly onExitingVR: Observable<VRExperienceHelper>;
  99669. /** Return this.onControllerMeshLoadedObservable
  99670. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99671. */
  99672. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99673. private _rayLength;
  99674. private _useCustomVRButton;
  99675. private _teleportationRequested;
  99676. private _teleportActive;
  99677. private _floorMeshName;
  99678. private _floorMeshesCollection;
  99679. private _rotationAllowed;
  99680. private _teleportBackwardsVector;
  99681. private _teleportationTarget;
  99682. private _isDefaultTeleportationTarget;
  99683. private _postProcessMove;
  99684. private _teleportationFillColor;
  99685. private _teleportationBorderColor;
  99686. private _rotationAngle;
  99687. private _haloCenter;
  99688. private _cameraGazer;
  99689. private _padSensibilityUp;
  99690. private _padSensibilityDown;
  99691. private _leftController;
  99692. private _rightController;
  99693. /**
  99694. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99695. */
  99696. onNewMeshSelected: Observable<AbstractMesh>;
  99697. /**
  99698. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99699. */
  99700. onNewMeshPicked: Observable<PickingInfo>;
  99701. private _circleEase;
  99702. /**
  99703. * Observable raised before camera teleportation
  99704. */
  99705. onBeforeCameraTeleport: Observable<Vector3>;
  99706. /**
  99707. * Observable raised after camera teleportation
  99708. */
  99709. onAfterCameraTeleport: Observable<Vector3>;
  99710. /**
  99711. * Observable raised when current selected mesh gets unselected
  99712. */
  99713. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99714. private _raySelectionPredicate;
  99715. /**
  99716. * To be optionaly changed by user to define custom ray selection
  99717. */
  99718. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99719. /**
  99720. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99721. */
  99722. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99723. /**
  99724. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99725. */
  99726. teleportationEnabled: boolean;
  99727. private _defaultHeight;
  99728. private _teleportationInitialized;
  99729. private _interactionsEnabled;
  99730. private _interactionsRequested;
  99731. private _displayGaze;
  99732. private _displayLaserPointer;
  99733. /**
  99734. * The mesh used to display where the user is going to teleport.
  99735. */
  99736. /**
  99737. * Sets the mesh to be used to display where the user is going to teleport.
  99738. */
  99739. teleportationTarget: Mesh;
  99740. /**
  99741. * 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
  99742. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99743. * See http://doc.babylonjs.com/resources/baking_transformations
  99744. */
  99745. gazeTrackerMesh: Mesh;
  99746. /**
  99747. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99748. */
  99749. updateGazeTrackerScale: boolean;
  99750. /**
  99751. * If the gaze trackers color should be updated when selecting meshes
  99752. */
  99753. updateGazeTrackerColor: boolean;
  99754. /**
  99755. * The gaze tracking mesh corresponding to the left controller
  99756. */
  99757. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99758. /**
  99759. * The gaze tracking mesh corresponding to the right controller
  99760. */
  99761. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99762. /**
  99763. * If the ray of the gaze should be displayed.
  99764. */
  99765. /**
  99766. * Sets if the ray of the gaze should be displayed.
  99767. */
  99768. displayGaze: boolean;
  99769. /**
  99770. * If the ray of the LaserPointer should be displayed.
  99771. */
  99772. /**
  99773. * Sets if the ray of the LaserPointer should be displayed.
  99774. */
  99775. displayLaserPointer: boolean;
  99776. /**
  99777. * The deviceOrientationCamera used as the camera when not in VR.
  99778. */
  99779. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99780. /**
  99781. * Based on the current WebVR support, returns the current VR camera used.
  99782. */
  99783. readonly currentVRCamera: Nullable<Camera>;
  99784. /**
  99785. * The webVRCamera which is used when in VR.
  99786. */
  99787. readonly webVRCamera: WebVRFreeCamera;
  99788. /**
  99789. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99790. */
  99791. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99792. private readonly _teleportationRequestInitiated;
  99793. /**
  99794. * Defines wether or not Pointer lock should be requested when switching to
  99795. * full screen.
  99796. */
  99797. requestPointerLockOnFullScreen: boolean;
  99798. /**
  99799. * Instantiates a VRExperienceHelper.
  99800. * Helps to quickly add VR support to an existing scene.
  99801. * @param scene The scene the VRExperienceHelper belongs to.
  99802. * @param webVROptions Options to modify the vr experience helper's behavior.
  99803. */
  99804. constructor(scene: Scene,
  99805. /** Options to modify the vr experience helper's behavior. */
  99806. webVROptions?: VRExperienceHelperOptions);
  99807. private _onDefaultMeshLoaded;
  99808. private _onResize;
  99809. private _onFullscreenChange;
  99810. /**
  99811. * Gets a value indicating if we are currently in VR mode.
  99812. */
  99813. readonly isInVRMode: boolean;
  99814. private onVrDisplayPresentChange;
  99815. private onVRDisplayChanged;
  99816. private moveButtonToBottomRight;
  99817. private displayVRButton;
  99818. private updateButtonVisibility;
  99819. private _cachedAngularSensibility;
  99820. /**
  99821. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99822. * Otherwise, will use the fullscreen API.
  99823. */
  99824. enterVR(): void;
  99825. /**
  99826. * Attempt to exit VR, or fullscreen.
  99827. */
  99828. exitVR(): void;
  99829. /**
  99830. * The position of the vr experience helper.
  99831. */
  99832. /**
  99833. * Sets the position of the vr experience helper.
  99834. */
  99835. position: Vector3;
  99836. /**
  99837. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99838. */
  99839. enableInteractions(): void;
  99840. private readonly _noControllerIsActive;
  99841. private beforeRender;
  99842. private _isTeleportationFloor;
  99843. /**
  99844. * Adds a floor mesh to be used for teleportation.
  99845. * @param floorMesh the mesh to be used for teleportation.
  99846. */
  99847. addFloorMesh(floorMesh: Mesh): void;
  99848. /**
  99849. * Removes a floor mesh from being used for teleportation.
  99850. * @param floorMesh the mesh to be removed.
  99851. */
  99852. removeFloorMesh(floorMesh: Mesh): void;
  99853. /**
  99854. * Enables interactions and teleportation using the VR controllers and gaze.
  99855. * @param vrTeleportationOptions options to modify teleportation behavior.
  99856. */
  99857. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99858. private _onNewGamepadConnected;
  99859. private _tryEnableInteractionOnController;
  99860. private _onNewGamepadDisconnected;
  99861. private _enableInteractionOnController;
  99862. private _checkTeleportWithRay;
  99863. private _checkRotate;
  99864. private _checkTeleportBackwards;
  99865. private _enableTeleportationOnController;
  99866. private _createTeleportationCircles;
  99867. private _displayTeleportationTarget;
  99868. private _hideTeleportationTarget;
  99869. private _rotateCamera;
  99870. private _moveTeleportationSelectorTo;
  99871. private _workingVector;
  99872. private _workingQuaternion;
  99873. private _workingMatrix;
  99874. /**
  99875. * Teleports the users feet to the desired location
  99876. * @param location The location where the user's feet should be placed
  99877. */
  99878. teleportCamera(location: Vector3): void;
  99879. private _convertNormalToDirectionOfRay;
  99880. private _castRayAndSelectObject;
  99881. private _notifySelectedMeshUnselected;
  99882. /**
  99883. * Sets the color of the laser ray from the vr controllers.
  99884. * @param color new color for the ray.
  99885. */
  99886. changeLaserColor(color: Color3): void;
  99887. /**
  99888. * Sets the color of the ray from the vr headsets gaze.
  99889. * @param color new color for the ray.
  99890. */
  99891. changeGazeColor(color: Color3): void;
  99892. /**
  99893. * Exits VR and disposes of the vr experience helper
  99894. */
  99895. dispose(): void;
  99896. /**
  99897. * Gets the name of the VRExperienceHelper class
  99898. * @returns "VRExperienceHelper"
  99899. */
  99900. getClassName(): string;
  99901. }
  99902. }
  99903. declare module BABYLON {
  99904. /**
  99905. * Manages an XRSession
  99906. * @see https://doc.babylonjs.com/how_to/webxr
  99907. */
  99908. export class WebXRSessionManager implements IDisposable {
  99909. private scene;
  99910. /**
  99911. * Fires every time a new xrFrame arrives which can be used to update the camera
  99912. */
  99913. onXRFrameObservable: Observable<any>;
  99914. /**
  99915. * Fires when the xr session is ended either by the device or manually done
  99916. */
  99917. onXRSessionEnded: Observable<any>;
  99918. /** @hidden */
  99919. _xrSession: XRSession;
  99920. /** @hidden */
  99921. _frameOfReference: XRFrameOfReference;
  99922. /** @hidden */
  99923. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99924. /** @hidden */
  99925. _currentXRFrame: Nullable<XRFrame>;
  99926. private _xrNavigator;
  99927. private _xrDevice;
  99928. private _tmpMatrix;
  99929. /**
  99930. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99931. * @param scene The scene which the session should be created for
  99932. */
  99933. constructor(scene: Scene);
  99934. /**
  99935. * Initializes the manager
  99936. * After initialization enterXR can be called to start an XR session
  99937. * @returns Promise which resolves after it is initialized
  99938. */
  99939. initializeAsync(): Promise<void>;
  99940. /**
  99941. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99942. * @param sessionCreationOptions xr options to create the session with
  99943. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99944. * @returns Promise which resolves after it enters XR
  99945. */
  99946. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99947. /**
  99948. * Stops the xrSession and restores the renderloop
  99949. * @returns Promise which resolves after it exits XR
  99950. */
  99951. exitXRAsync(): Promise<void>;
  99952. /**
  99953. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99954. * @param ray ray to cast into the environment
  99955. * @returns Promise which resolves with a collision point in the environment if it exists
  99956. */
  99957. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99958. /**
  99959. * Checks if a session would be supported for the creation options specified
  99960. * @param options creation options to check if they are supported
  99961. * @returns true if supported
  99962. */
  99963. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99964. /**
  99965. * @hidden
  99966. * Converts the render layer of xrSession to a render target
  99967. * @param session session to create render target for
  99968. * @param scene scene the new render target should be created for
  99969. */
  99970. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99971. /**
  99972. * Disposes of the session manager
  99973. */
  99974. dispose(): void;
  99975. }
  99976. }
  99977. declare module BABYLON {
  99978. /**
  99979. * WebXR Camera which holds the views for the xrSession
  99980. * @see https://doc.babylonjs.com/how_to/webxr
  99981. */
  99982. export class WebXRCamera extends FreeCamera {
  99983. private static _TmpMatrix;
  99984. /**
  99985. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99986. * @param name the name of the camera
  99987. * @param scene the scene to add the camera to
  99988. */
  99989. constructor(name: string, scene: Scene);
  99990. private _updateNumberOfRigCameras;
  99991. /** @hidden */
  99992. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99993. /**
  99994. * Updates the cameras position from the current pose information of the XR session
  99995. * @param xrSessionManager the session containing pose information
  99996. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99997. */
  99998. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99999. }
  100000. }
  100001. declare module BABYLON {
  100002. /**
  100003. * States of the webXR experience
  100004. */
  100005. export enum WebXRState {
  100006. /**
  100007. * Transitioning to being in XR mode
  100008. */
  100009. ENTERING_XR = 0,
  100010. /**
  100011. * Transitioning to non XR mode
  100012. */
  100013. EXITING_XR = 1,
  100014. /**
  100015. * In XR mode and presenting
  100016. */
  100017. IN_XR = 2,
  100018. /**
  100019. * Not entered XR mode
  100020. */
  100021. NOT_IN_XR = 3
  100022. }
  100023. /**
  100024. * Helper class used to enable XR
  100025. * @see https://doc.babylonjs.com/how_to/webxr
  100026. */
  100027. export class WebXRExperienceHelper implements IDisposable {
  100028. private scene;
  100029. /**
  100030. * 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
  100031. */
  100032. container: AbstractMesh;
  100033. /**
  100034. * Camera used to render xr content
  100035. */
  100036. camera: WebXRCamera;
  100037. /**
  100038. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  100039. */
  100040. state: WebXRState;
  100041. private _setState;
  100042. private static _TmpVector;
  100043. /**
  100044. * Fires when the state of the experience helper has changed
  100045. */
  100046. onStateChangedObservable: Observable<WebXRState>;
  100047. /** @hidden */
  100048. _sessionManager: WebXRSessionManager;
  100049. private _nonVRCamera;
  100050. private _originalSceneAutoClear;
  100051. private _supported;
  100052. /**
  100053. * Creates the experience helper
  100054. * @param scene the scene to attach the experience helper to
  100055. * @returns a promise for the experience helper
  100056. */
  100057. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  100058. /**
  100059. * Creates a WebXRExperienceHelper
  100060. * @param scene The scene the helper should be created in
  100061. */
  100062. private constructor();
  100063. /**
  100064. * Exits XR mode and returns the scene to its original state
  100065. * @returns promise that resolves after xr mode has exited
  100066. */
  100067. exitXRAsync(): Promise<void>;
  100068. /**
  100069. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  100070. * @param sessionCreationOptions options for the XR session
  100071. * @param frameOfReference frame of reference of the XR session
  100072. * @returns promise that resolves after xr mode has entered
  100073. */
  100074. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  100075. /**
  100076. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  100077. * @param ray ray to cast into the environment
  100078. * @returns Promise which resolves with a collision point in the environment if it exists
  100079. */
  100080. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  100081. /**
  100082. * Updates the global position of the camera by moving the camera's container
  100083. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  100084. * @param position The desired global position of the camera
  100085. */
  100086. setPositionOfCameraUsingContainer(position: Vector3): void;
  100087. /**
  100088. * Rotates the xr camera by rotating the camera's container around the camera's position
  100089. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  100090. * @param rotation the desired quaternion rotation to apply to the camera
  100091. */
  100092. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  100093. /**
  100094. * Checks if the creation options are supported by the xr session
  100095. * @param options creation options
  100096. * @returns true if supported
  100097. */
  100098. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  100099. /**
  100100. * Disposes of the experience helper
  100101. */
  100102. dispose(): void;
  100103. }
  100104. }
  100105. declare module BABYLON {
  100106. /**
  100107. * Button which can be used to enter a different mode of XR
  100108. */
  100109. export class WebXREnterExitUIButton {
  100110. /** button element */
  100111. element: HTMLElement;
  100112. /** XR initialization options for the button */
  100113. initializationOptions: XRSessionCreationOptions;
  100114. /**
  100115. * Creates a WebXREnterExitUIButton
  100116. * @param element button element
  100117. * @param initializationOptions XR initialization options for the button
  100118. */
  100119. constructor(
  100120. /** button element */
  100121. element: HTMLElement,
  100122. /** XR initialization options for the button */
  100123. initializationOptions: XRSessionCreationOptions);
  100124. /**
  100125. * Overwritable function which can be used to update the button's visuals when the state changes
  100126. * @param activeButton the current active button in the UI
  100127. */
  100128. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  100129. }
  100130. /**
  100131. * Options to create the webXR UI
  100132. */
  100133. export class WebXREnterExitUIOptions {
  100134. /**
  100135. * Context to enter xr with
  100136. */
  100137. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  100138. /**
  100139. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  100140. */
  100141. customButtons?: Array<WebXREnterExitUIButton>;
  100142. }
  100143. /**
  100144. * UI to allow the user to enter/exit XR mode
  100145. */
  100146. export class WebXREnterExitUI implements IDisposable {
  100147. private scene;
  100148. private _overlay;
  100149. private _buttons;
  100150. private _activeButton;
  100151. /**
  100152. * Fired every time the active button is changed.
  100153. *
  100154. * When xr is entered via a button that launches xr that button will be the callback parameter
  100155. *
  100156. * When exiting xr the callback parameter will be null)
  100157. */
  100158. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  100159. /**
  100160. * Creates UI to allow the user to enter/exit XR mode
  100161. * @param scene the scene to add the ui to
  100162. * @param helper the xr experience helper to enter/exit xr with
  100163. * @param options options to configure the UI
  100164. * @returns the created ui
  100165. */
  100166. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  100167. private constructor();
  100168. private _updateButtons;
  100169. /**
  100170. * Disposes of the object
  100171. */
  100172. dispose(): void;
  100173. }
  100174. }
  100175. declare module BABYLON {
  100176. /**
  100177. * Represents an XR input
  100178. */
  100179. export class WebXRController {
  100180. /**
  100181. * 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
  100182. */
  100183. grip?: AbstractMesh;
  100184. /**
  100185. * Pointer which can be used to select objects or attach a visible laser to
  100186. */
  100187. pointer: AbstractMesh;
  100188. /**
  100189. * Creates the controller
  100190. * @see https://doc.babylonjs.com/how_to/webxr
  100191. * @param scene the scene which the controller should be associated to
  100192. */
  100193. constructor(scene: Scene);
  100194. /**
  100195. * Disposes of the object
  100196. */
  100197. dispose(): void;
  100198. }
  100199. /**
  100200. * XR input used to track XR inputs such as controllers/rays
  100201. */
  100202. export class WebXRInput implements IDisposable {
  100203. private helper;
  100204. /**
  100205. * XR controllers being tracked
  100206. */
  100207. controllers: Array<WebXRController>;
  100208. private _tmpMatrix;
  100209. private _frameObserver;
  100210. /**
  100211. * Initializes the WebXRInput
  100212. * @param helper experience helper which the input should be created for
  100213. */
  100214. constructor(helper: WebXRExperienceHelper);
  100215. /**
  100216. * Disposes of the object
  100217. */
  100218. dispose(): void;
  100219. }
  100220. }
  100221. declare module BABYLON {
  100222. /**
  100223. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  100224. */
  100225. export class WebXRManagedOutputCanvas implements IDisposable {
  100226. private _canvas;
  100227. /**
  100228. * xrpresent context of the canvas which can be used to display/mirror xr content
  100229. */
  100230. canvasContext: Nullable<WebGLRenderingContext>;
  100231. /**
  100232. * Initializes the canvas to be added/removed upon entering/exiting xr
  100233. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  100234. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  100235. */
  100236. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  100237. /**
  100238. * Disposes of the object
  100239. */
  100240. dispose(): void;
  100241. private _setManagedOutputCanvas;
  100242. private _addCanvas;
  100243. private _removeCanvas;
  100244. }
  100245. }
  100246. declare module BABYLON {
  100247. /**
  100248. * Contains an array of blocks representing the octree
  100249. */
  100250. export interface IOctreeContainer<T> {
  100251. /**
  100252. * Blocks within the octree
  100253. */
  100254. blocks: Array<OctreeBlock<T>>;
  100255. }
  100256. /**
  100257. * Class used to store a cell in an octree
  100258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100259. */
  100260. export class OctreeBlock<T> {
  100261. /**
  100262. * Gets the content of the current block
  100263. */
  100264. entries: T[];
  100265. /**
  100266. * Gets the list of block children
  100267. */
  100268. blocks: Array<OctreeBlock<T>>;
  100269. private _depth;
  100270. private _maxDepth;
  100271. private _capacity;
  100272. private _minPoint;
  100273. private _maxPoint;
  100274. private _boundingVectors;
  100275. private _creationFunc;
  100276. /**
  100277. * Creates a new block
  100278. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  100279. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  100280. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100281. * @param depth defines the current depth of this block in the octree
  100282. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  100283. * @param creationFunc defines a callback to call when an element is added to the block
  100284. */
  100285. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  100286. /**
  100287. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  100288. */
  100289. readonly capacity: number;
  100290. /**
  100291. * Gets the minimum vector (in world space) of the block's bounding box
  100292. */
  100293. readonly minPoint: Vector3;
  100294. /**
  100295. * Gets the maximum vector (in world space) of the block's bounding box
  100296. */
  100297. readonly maxPoint: Vector3;
  100298. /**
  100299. * Add a new element to this block
  100300. * @param entry defines the element to add
  100301. */
  100302. addEntry(entry: T): void;
  100303. /**
  100304. * Remove an element from this block
  100305. * @param entry defines the element to remove
  100306. */
  100307. removeEntry(entry: T): void;
  100308. /**
  100309. * Add an array of elements to this block
  100310. * @param entries defines the array of elements to add
  100311. */
  100312. addEntries(entries: T[]): void;
  100313. /**
  100314. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  100315. * @param frustumPlanes defines the frustum planes to test
  100316. * @param selection defines the array to store current content if selection is positive
  100317. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100318. */
  100319. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100320. /**
  100321. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  100322. * @param sphereCenter defines the bounding sphere center
  100323. * @param sphereRadius defines the bounding sphere radius
  100324. * @param selection defines the array to store current content if selection is positive
  100325. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100326. */
  100327. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  100328. /**
  100329. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  100330. * @param ray defines the ray to test with
  100331. * @param selection defines the array to store current content if selection is positive
  100332. */
  100333. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  100334. /**
  100335. * Subdivide the content into child blocks (this block will then be empty)
  100336. */
  100337. createInnerBlocks(): void;
  100338. /**
  100339. * @hidden
  100340. */
  100341. 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;
  100342. }
  100343. }
  100344. declare module BABYLON {
  100345. /**
  100346. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  100347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100348. */
  100349. export class Octree<T> {
  100350. /** 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.) */
  100351. maxDepth: number;
  100352. /**
  100353. * Blocks within the octree containing objects
  100354. */
  100355. blocks: Array<OctreeBlock<T>>;
  100356. /**
  100357. * Content stored in the octree
  100358. */
  100359. dynamicContent: T[];
  100360. private _maxBlockCapacity;
  100361. private _selectionContent;
  100362. private _creationFunc;
  100363. /**
  100364. * Creates a octree
  100365. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100366. * @param creationFunc function to be used to instatiate the octree
  100367. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  100368. * @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.)
  100369. */
  100370. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  100371. /** 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.) */
  100372. maxDepth?: number);
  100373. /**
  100374. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  100375. * @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);
  100376. * @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);
  100377. * @param entries meshes to be added to the octree blocks
  100378. */
  100379. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  100380. /**
  100381. * Adds a mesh to the octree
  100382. * @param entry Mesh to add to the octree
  100383. */
  100384. addMesh(entry: T): void;
  100385. /**
  100386. * Remove an element from the octree
  100387. * @param entry defines the element to remove
  100388. */
  100389. removeMesh(entry: T): void;
  100390. /**
  100391. * Selects an array of meshes within the frustum
  100392. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  100393. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  100394. * @returns array of meshes within the frustum
  100395. */
  100396. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  100397. /**
  100398. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  100399. * @param sphereCenter defines the bounding sphere center
  100400. * @param sphereRadius defines the bounding sphere radius
  100401. * @param allowDuplicate defines if the selection array can contains duplicated entries
  100402. * @returns an array of objects that intersect the sphere
  100403. */
  100404. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  100405. /**
  100406. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  100407. * @param ray defines the ray to test with
  100408. * @returns array of intersected objects
  100409. */
  100410. intersectsRay(ray: Ray): SmartArray<T>;
  100411. /**
  100412. * Adds a mesh into the octree block if it intersects the block
  100413. */
  100414. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  100415. /**
  100416. * Adds a submesh into the octree block if it intersects the block
  100417. */
  100418. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  100419. }
  100420. }
  100421. declare module BABYLON {
  100422. interface Scene {
  100423. /**
  100424. * @hidden
  100425. * Backing Filed
  100426. */
  100427. _selectionOctree: Octree<AbstractMesh>;
  100428. /**
  100429. * Gets the octree used to boost mesh selection (picking)
  100430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100431. */
  100432. selectionOctree: Octree<AbstractMesh>;
  100433. /**
  100434. * Creates or updates the octree used to boost selection (picking)
  100435. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100436. * @param maxCapacity defines the maximum capacity per leaf
  100437. * @param maxDepth defines the maximum depth of the octree
  100438. * @returns an octree of AbstractMesh
  100439. */
  100440. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  100441. }
  100442. interface AbstractMesh {
  100443. /**
  100444. * @hidden
  100445. * Backing Field
  100446. */
  100447. _submeshesOctree: Octree<SubMesh>;
  100448. /**
  100449. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  100450. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  100451. * @param maxCapacity defines the maximum size of each block (64 by default)
  100452. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  100453. * @returns the new octree
  100454. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  100455. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  100456. */
  100457. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  100458. }
  100459. /**
  100460. * Defines the octree scene component responsible to manage any octrees
  100461. * in a given scene.
  100462. */
  100463. export class OctreeSceneComponent {
  100464. /**
  100465. * The component name help to identify the component in the list of scene components.
  100466. */
  100467. readonly name: string;
  100468. /**
  100469. * The scene the component belongs to.
  100470. */
  100471. scene: Scene;
  100472. /**
  100473. * Indicates if the meshes have been checked to make sure they are isEnabled()
  100474. */
  100475. readonly checksIsEnabled: boolean;
  100476. /**
  100477. * Creates a new instance of the component for the given scene
  100478. * @param scene Defines the scene to register the component in
  100479. */
  100480. constructor(scene: Scene);
  100481. /**
  100482. * Registers the component in a given scene
  100483. */
  100484. register(): void;
  100485. /**
  100486. * Return the list of active meshes
  100487. * @returns the list of active meshes
  100488. */
  100489. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100490. /**
  100491. * Return the list of active sub meshes
  100492. * @param mesh The mesh to get the candidates sub meshes from
  100493. * @returns the list of active sub meshes
  100494. */
  100495. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100496. private _tempRay;
  100497. /**
  100498. * Return the list of sub meshes intersecting with a given local ray
  100499. * @param mesh defines the mesh to find the submesh for
  100500. * @param localRay defines the ray in local space
  100501. * @returns the list of intersecting sub meshes
  100502. */
  100503. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  100504. /**
  100505. * Return the list of sub meshes colliding with a collider
  100506. * @param mesh defines the mesh to find the submesh for
  100507. * @param collider defines the collider to evaluate the collision against
  100508. * @returns the list of colliding sub meshes
  100509. */
  100510. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  100511. /**
  100512. * Rebuilds the elements related to this component in case of
  100513. * context lost for instance.
  100514. */
  100515. rebuild(): void;
  100516. /**
  100517. * Disposes the component and the associated ressources.
  100518. */
  100519. dispose(): void;
  100520. }
  100521. }
  100522. declare module BABYLON {
  100523. /**
  100524. * Renders a layer on top of an existing scene
  100525. */
  100526. export class UtilityLayerRenderer implements IDisposable {
  100527. /** the original scene that will be rendered on top of */
  100528. originalScene: Scene;
  100529. private _pointerCaptures;
  100530. private _lastPointerEvents;
  100531. private static _DefaultUtilityLayer;
  100532. private static _DefaultKeepDepthUtilityLayer;
  100533. private _sharedGizmoLight;
  100534. /**
  100535. * @hidden
  100536. * Light which used by gizmos to get light shading
  100537. */
  100538. _getSharedGizmoLight(): HemisphericLight;
  100539. /**
  100540. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100541. */
  100542. pickUtilitySceneFirst: boolean;
  100543. /**
  100544. * 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)
  100545. */
  100546. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100547. /**
  100548. * 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)
  100549. */
  100550. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100551. /**
  100552. * The scene that is rendered on top of the original scene
  100553. */
  100554. utilityLayerScene: Scene;
  100555. /**
  100556. * If the utility layer should automatically be rendered on top of existing scene
  100557. */
  100558. shouldRender: boolean;
  100559. /**
  100560. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100561. */
  100562. onlyCheckPointerDownEvents: boolean;
  100563. /**
  100564. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100565. */
  100566. processAllEvents: boolean;
  100567. /**
  100568. * Observable raised when the pointer move from the utility layer scene to the main scene
  100569. */
  100570. onPointerOutObservable: Observable<number>;
  100571. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100572. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100573. private _afterRenderObserver;
  100574. private _sceneDisposeObserver;
  100575. private _originalPointerObserver;
  100576. /**
  100577. * Instantiates a UtilityLayerRenderer
  100578. * @param originalScene the original scene that will be rendered on top of
  100579. * @param handleEvents boolean indicating if the utility layer should handle events
  100580. */
  100581. constructor(
  100582. /** the original scene that will be rendered on top of */
  100583. originalScene: Scene, handleEvents?: boolean);
  100584. private _notifyObservers;
  100585. /**
  100586. * Renders the utility layers scene on top of the original scene
  100587. */
  100588. render(): void;
  100589. /**
  100590. * Disposes of the renderer
  100591. */
  100592. dispose(): void;
  100593. private _updateCamera;
  100594. }
  100595. }
  100596. declare module BABYLON {
  100597. /**
  100598. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100599. */
  100600. export class Gizmo implements IDisposable {
  100601. /** The utility layer the gizmo will be added to */
  100602. gizmoLayer: UtilityLayerRenderer;
  100603. /**
  100604. * The root mesh of the gizmo
  100605. */
  100606. _rootMesh: Mesh;
  100607. private _attachedMesh;
  100608. /**
  100609. * Ratio for the scale of the gizmo (Default: 1)
  100610. */
  100611. scaleRatio: number;
  100612. /**
  100613. * If a custom mesh has been set (Default: false)
  100614. */
  100615. protected _customMeshSet: boolean;
  100616. /**
  100617. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100618. * * When set, interactions will be enabled
  100619. */
  100620. attachedMesh: Nullable<AbstractMesh>;
  100621. /**
  100622. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100623. * @param mesh The mesh to replace the default mesh of the gizmo
  100624. */
  100625. setCustomMesh(mesh: Mesh): void;
  100626. /**
  100627. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100628. */
  100629. updateGizmoRotationToMatchAttachedMesh: boolean;
  100630. /**
  100631. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100632. */
  100633. updateGizmoPositionToMatchAttachedMesh: boolean;
  100634. /**
  100635. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100636. */
  100637. protected _updateScale: boolean;
  100638. protected _interactionsEnabled: boolean;
  100639. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100640. private _beforeRenderObserver;
  100641. private _tempVector;
  100642. /**
  100643. * Creates a gizmo
  100644. * @param gizmoLayer The utility layer the gizmo will be added to
  100645. */
  100646. constructor(
  100647. /** The utility layer the gizmo will be added to */
  100648. gizmoLayer?: UtilityLayerRenderer);
  100649. /**
  100650. * Updates the gizmo to match the attached mesh's position/rotation
  100651. */
  100652. protected _update(): void;
  100653. /**
  100654. * Disposes of the gizmo
  100655. */
  100656. dispose(): void;
  100657. }
  100658. }
  100659. declare module BABYLON {
  100660. /**
  100661. * Single axis drag gizmo
  100662. */
  100663. export class AxisDragGizmo extends Gizmo {
  100664. /**
  100665. * Drag behavior responsible for the gizmos dragging interactions
  100666. */
  100667. dragBehavior: PointerDragBehavior;
  100668. private _pointerObserver;
  100669. /**
  100670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100671. */
  100672. snapDistance: number;
  100673. /**
  100674. * Event that fires each time the gizmo snaps to a new location.
  100675. * * snapDistance is the the change in distance
  100676. */
  100677. onSnapObservable: Observable<{
  100678. snapDistance: number;
  100679. }>;
  100680. /** @hidden */
  100681. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100682. /** @hidden */
  100683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100684. /**
  100685. * Creates an AxisDragGizmo
  100686. * @param gizmoLayer The utility layer the gizmo will be added to
  100687. * @param dragAxis The axis which the gizmo will be able to drag on
  100688. * @param color The color of the gizmo
  100689. */
  100690. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100692. /**
  100693. * Disposes of the gizmo
  100694. */
  100695. dispose(): void;
  100696. }
  100697. }
  100698. declare module BABYLON.Debug {
  100699. /**
  100700. * The Axes viewer will show 3 axes in a specific point in space
  100701. */
  100702. export class AxesViewer {
  100703. private _xAxis;
  100704. private _yAxis;
  100705. private _zAxis;
  100706. private _scaleLinesFactor;
  100707. private _instanced;
  100708. /**
  100709. * Gets the hosting scene
  100710. */
  100711. scene: Scene;
  100712. /**
  100713. * Gets or sets a number used to scale line length
  100714. */
  100715. scaleLines: number;
  100716. /** Gets the node hierarchy used to render x-axis */
  100717. readonly xAxis: TransformNode;
  100718. /** Gets the node hierarchy used to render y-axis */
  100719. readonly yAxis: TransformNode;
  100720. /** Gets the node hierarchy used to render z-axis */
  100721. readonly zAxis: TransformNode;
  100722. /**
  100723. * Creates a new AxesViewer
  100724. * @param scene defines the hosting scene
  100725. * @param scaleLines defines a number used to scale line length (1 by default)
  100726. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100727. * @param xAxis defines the node hierarchy used to render the x-axis
  100728. * @param yAxis defines the node hierarchy used to render the y-axis
  100729. * @param zAxis defines the node hierarchy used to render the z-axis
  100730. */
  100731. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100732. /**
  100733. * Force the viewer to update
  100734. * @param position defines the position of the viewer
  100735. * @param xaxis defines the x axis of the viewer
  100736. * @param yaxis defines the y axis of the viewer
  100737. * @param zaxis defines the z axis of the viewer
  100738. */
  100739. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100740. /**
  100741. * Creates an instance of this axes viewer.
  100742. * @returns a new axes viewer with instanced meshes
  100743. */
  100744. createInstance(): AxesViewer;
  100745. /** Releases resources */
  100746. dispose(): void;
  100747. private static _SetRenderingGroupId;
  100748. }
  100749. }
  100750. declare module BABYLON.Debug {
  100751. /**
  100752. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100753. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100754. */
  100755. export class BoneAxesViewer extends AxesViewer {
  100756. /**
  100757. * Gets or sets the target mesh where to display the axes viewer
  100758. */
  100759. mesh: Nullable<Mesh>;
  100760. /**
  100761. * Gets or sets the target bone where to display the axes viewer
  100762. */
  100763. bone: Nullable<Bone>;
  100764. /** Gets current position */
  100765. pos: Vector3;
  100766. /** Gets direction of X axis */
  100767. xaxis: Vector3;
  100768. /** Gets direction of Y axis */
  100769. yaxis: Vector3;
  100770. /** Gets direction of Z axis */
  100771. zaxis: Vector3;
  100772. /**
  100773. * Creates a new BoneAxesViewer
  100774. * @param scene defines the hosting scene
  100775. * @param bone defines the target bone
  100776. * @param mesh defines the target mesh
  100777. * @param scaleLines defines a scaling factor for line length (1 by default)
  100778. */
  100779. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100780. /**
  100781. * Force the viewer to update
  100782. */
  100783. update(): void;
  100784. /** Releases resources */
  100785. dispose(): void;
  100786. }
  100787. }
  100788. declare module BABYLON {
  100789. /**
  100790. * Interface used to define scene explorer extensibility option
  100791. */
  100792. export interface IExplorerExtensibilityOption {
  100793. /**
  100794. * Define the option label
  100795. */
  100796. label: string;
  100797. /**
  100798. * Defines the action to execute on click
  100799. */
  100800. action: (entity: any) => void;
  100801. }
  100802. /**
  100803. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100804. */
  100805. export interface IExplorerExtensibilityGroup {
  100806. /**
  100807. * Defines a predicate to test if a given type mut be extended
  100808. */
  100809. predicate: (entity: any) => boolean;
  100810. /**
  100811. * Gets the list of options added to a type
  100812. */
  100813. entries: IExplorerExtensibilityOption[];
  100814. }
  100815. /**
  100816. * Interface used to define the options to use to create the Inspector
  100817. */
  100818. export interface IInspectorOptions {
  100819. /**
  100820. * Display in overlay mode (default: false)
  100821. */
  100822. overlay?: boolean;
  100823. /**
  100824. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100825. */
  100826. globalRoot?: HTMLElement;
  100827. /**
  100828. * Display the Scene explorer
  100829. */
  100830. showExplorer?: boolean;
  100831. /**
  100832. * Display the property inspector
  100833. */
  100834. showInspector?: boolean;
  100835. /**
  100836. * Display in embed mode (both panes on the right)
  100837. */
  100838. embedMode?: boolean;
  100839. /**
  100840. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100841. */
  100842. handleResize?: boolean;
  100843. /**
  100844. * Allow the panes to popup (default: true)
  100845. */
  100846. enablePopup?: boolean;
  100847. /**
  100848. * Allow the panes to be closed by users (default: true)
  100849. */
  100850. enableClose?: boolean;
  100851. /**
  100852. * Optional list of extensibility entries
  100853. */
  100854. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100855. /**
  100856. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100857. */
  100858. inspectorURL?: string;
  100859. }
  100860. interface Scene {
  100861. /**
  100862. * @hidden
  100863. * Backing field
  100864. */
  100865. _debugLayer: DebugLayer;
  100866. /**
  100867. * Gets the debug layer (aka Inspector) associated with the scene
  100868. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100869. */
  100870. debugLayer: DebugLayer;
  100871. }
  100872. /**
  100873. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100874. * what is happening in your scene
  100875. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100876. */
  100877. export class DebugLayer {
  100878. /**
  100879. * Define the url to get the inspector script from.
  100880. * By default it uses the babylonjs CDN.
  100881. * @ignoreNaming
  100882. */
  100883. static InspectorURL: string;
  100884. private _scene;
  100885. private BJSINSPECTOR;
  100886. /**
  100887. * Observable triggered when a property is changed through the inspector.
  100888. */
  100889. onPropertyChangedObservable: Observable<{
  100890. object: any;
  100891. property: string;
  100892. value: any;
  100893. initialValue: any;
  100894. }>;
  100895. /**
  100896. * Instantiates a new debug layer.
  100897. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100898. * what is happening in your scene
  100899. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100900. * @param scene Defines the scene to inspect
  100901. */
  100902. constructor(scene: Scene);
  100903. /** Creates the inspector window. */
  100904. private _createInspector;
  100905. /**
  100906. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100907. * @param entity defines the entity to select
  100908. * @param lineContainerTitle defines the specific block to highlight
  100909. */
  100910. select(entity: any, lineContainerTitle?: string): void;
  100911. /** Get the inspector from bundle or global */
  100912. private _getGlobalInspector;
  100913. /**
  100914. * Get if the inspector is visible or not.
  100915. * @returns true if visible otherwise, false
  100916. */
  100917. isVisible(): boolean;
  100918. /**
  100919. * Hide the inspector and close its window.
  100920. */
  100921. hide(): void;
  100922. /**
  100923. * Launch the debugLayer.
  100924. * @param config Define the configuration of the inspector
  100925. * @return a promise fulfilled when the debug layer is visible
  100926. */
  100927. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100928. }
  100929. }
  100930. declare module BABYLON {
  100931. /**
  100932. * Class containing static functions to help procedurally build meshes
  100933. */
  100934. export class BoxBuilder {
  100935. /**
  100936. * Creates a box mesh
  100937. * * The parameter `size` sets the size (float) of each box side (default 1)
  100938. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100939. * * 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)
  100940. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100944. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100945. * @param name defines the name of the mesh
  100946. * @param options defines the options used to create the mesh
  100947. * @param scene defines the hosting scene
  100948. * @returns the box mesh
  100949. */
  100950. static CreateBox(name: string, options: {
  100951. size?: number;
  100952. width?: number;
  100953. height?: number;
  100954. depth?: number;
  100955. faceUV?: Vector4[];
  100956. faceColors?: Color4[];
  100957. sideOrientation?: number;
  100958. frontUVs?: Vector4;
  100959. backUVs?: Vector4;
  100960. wrap?: boolean;
  100961. topBaseAt?: number;
  100962. bottomBaseAt?: number;
  100963. updatable?: boolean;
  100964. }, scene?: Nullable<Scene>): Mesh;
  100965. }
  100966. }
  100967. declare module BABYLON {
  100968. /**
  100969. * Class containing static functions to help procedurally build meshes
  100970. */
  100971. export class SphereBuilder {
  100972. /**
  100973. * Creates a sphere mesh
  100974. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100975. * * 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`)
  100976. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100977. * * 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
  100978. * * 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)
  100979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100982. * @param name defines the name of the mesh
  100983. * @param options defines the options used to create the mesh
  100984. * @param scene defines the hosting scene
  100985. * @returns the sphere mesh
  100986. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100987. */
  100988. static CreateSphere(name: string, options: {
  100989. segments?: number;
  100990. diameter?: number;
  100991. diameterX?: number;
  100992. diameterY?: number;
  100993. diameterZ?: number;
  100994. arc?: number;
  100995. slice?: number;
  100996. sideOrientation?: number;
  100997. frontUVs?: Vector4;
  100998. backUVs?: Vector4;
  100999. updatable?: boolean;
  101000. }, scene: any): Mesh;
  101001. }
  101002. }
  101003. declare module BABYLON.Debug {
  101004. /**
  101005. * Used to show the physics impostor around the specific mesh
  101006. */
  101007. export class PhysicsViewer {
  101008. /** @hidden */
  101009. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  101010. /** @hidden */
  101011. protected _meshes: Array<Nullable<AbstractMesh>>;
  101012. /** @hidden */
  101013. protected _scene: Nullable<Scene>;
  101014. /** @hidden */
  101015. protected _numMeshes: number;
  101016. /** @hidden */
  101017. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  101018. private _renderFunction;
  101019. private _utilityLayer;
  101020. private _debugBoxMesh;
  101021. private _debugSphereMesh;
  101022. private _debugCylinderMesh;
  101023. private _debugMaterial;
  101024. private _debugMeshMeshes;
  101025. /**
  101026. * Creates a new PhysicsViewer
  101027. * @param scene defines the hosting scene
  101028. */
  101029. constructor(scene: Scene);
  101030. /** @hidden */
  101031. protected _updateDebugMeshes(): void;
  101032. /**
  101033. * Renders a specified physic impostor
  101034. * @param impostor defines the impostor to render
  101035. * @param targetMesh defines the mesh represented by the impostor
  101036. * @returns the new debug mesh used to render the impostor
  101037. */
  101038. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  101039. /**
  101040. * Hides a specified physic impostor
  101041. * @param impostor defines the impostor to hide
  101042. */
  101043. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  101044. private _getDebugMaterial;
  101045. private _getDebugBoxMesh;
  101046. private _getDebugSphereMesh;
  101047. private _getDebugCylinderMesh;
  101048. private _getDebugMeshMesh;
  101049. private _getDebugMesh;
  101050. /** Releases all resources */
  101051. dispose(): void;
  101052. }
  101053. }
  101054. declare module BABYLON {
  101055. /**
  101056. * Class containing static functions to help procedurally build meshes
  101057. */
  101058. export class LinesBuilder {
  101059. /**
  101060. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  101061. * * 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
  101062. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  101063. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  101064. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  101065. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  101066. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  101067. * * 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
  101068. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  101069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  101071. * @param name defines the name of the new line system
  101072. * @param options defines the options used to create the line system
  101073. * @param scene defines the hosting scene
  101074. * @returns a new line system mesh
  101075. */
  101076. static CreateLineSystem(name: string, options: {
  101077. lines: Vector3[][];
  101078. updatable?: boolean;
  101079. instance?: Nullable<LinesMesh>;
  101080. colors?: Nullable<Color4[][]>;
  101081. useVertexAlpha?: boolean;
  101082. }, scene: Nullable<Scene>): LinesMesh;
  101083. /**
  101084. * Creates a line mesh
  101085. * 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
  101086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101087. * * The parameter `points` is an array successive Vector3
  101088. * * 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
  101089. * * The optional parameter `colors` is an array of successive Color4, one per line point
  101090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  101091. * * When updating an instance, remember that only point positions can change, not the number of points
  101092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  101094. * @param name defines the name of the new line system
  101095. * @param options defines the options used to create the line system
  101096. * @param scene defines the hosting scene
  101097. * @returns a new line mesh
  101098. */
  101099. static CreateLines(name: string, options: {
  101100. points: Vector3[];
  101101. updatable?: boolean;
  101102. instance?: Nullable<LinesMesh>;
  101103. colors?: Color4[];
  101104. useVertexAlpha?: boolean;
  101105. }, scene?: Nullable<Scene>): LinesMesh;
  101106. /**
  101107. * Creates a dashed line mesh
  101108. * * 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
  101109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  101110. * * The parameter `points` is an array successive Vector3
  101111. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  101112. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  101113. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  101114. * * 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
  101115. * * When updating an instance, remember that only point positions can change, not the number of points
  101116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101117. * @param name defines the name of the mesh
  101118. * @param options defines the options used to create the mesh
  101119. * @param scene defines the hosting scene
  101120. * @returns the dashed line mesh
  101121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  101122. */
  101123. static CreateDashedLines(name: string, options: {
  101124. points: Vector3[];
  101125. dashSize?: number;
  101126. gapSize?: number;
  101127. dashNb?: number;
  101128. updatable?: boolean;
  101129. instance?: LinesMesh;
  101130. }, scene?: Nullable<Scene>): LinesMesh;
  101131. }
  101132. }
  101133. declare module BABYLON {
  101134. /**
  101135. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101136. * in order to better appreciate the issue one might have.
  101137. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101138. */
  101139. export class RayHelper {
  101140. /**
  101141. * Defines the ray we are currently tryin to visualize.
  101142. */
  101143. ray: Nullable<Ray>;
  101144. private _renderPoints;
  101145. private _renderLine;
  101146. private _renderFunction;
  101147. private _scene;
  101148. private _updateToMeshFunction;
  101149. private _attachedToMesh;
  101150. private _meshSpaceDirection;
  101151. private _meshSpaceOrigin;
  101152. /**
  101153. * Helper function to create a colored helper in a scene in one line.
  101154. * @param ray Defines the ray we are currently tryin to visualize
  101155. * @param scene Defines the scene the ray is used in
  101156. * @param color Defines the color we want to see the ray in
  101157. * @returns The newly created ray helper.
  101158. */
  101159. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  101160. /**
  101161. * Instantiate a new ray helper.
  101162. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  101163. * in order to better appreciate the issue one might have.
  101164. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  101165. * @param ray Defines the ray we are currently tryin to visualize
  101166. */
  101167. constructor(ray: Ray);
  101168. /**
  101169. * Shows the ray we are willing to debug.
  101170. * @param scene Defines the scene the ray needs to be rendered in
  101171. * @param color Defines the color the ray needs to be rendered in
  101172. */
  101173. show(scene: Scene, color?: Color3): void;
  101174. /**
  101175. * Hides the ray we are debugging.
  101176. */
  101177. hide(): void;
  101178. private _render;
  101179. /**
  101180. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  101181. * @param mesh Defines the mesh we want the helper attached to
  101182. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  101183. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  101184. * @param length Defines the length of the ray
  101185. */
  101186. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  101187. /**
  101188. * Detach the ray helper from the mesh it has previously been attached to.
  101189. */
  101190. detachFromMesh(): void;
  101191. private _updateToMesh;
  101192. /**
  101193. * Dispose the helper and release its associated resources.
  101194. */
  101195. dispose(): void;
  101196. }
  101197. }
  101198. declare module BABYLON.Debug {
  101199. /**
  101200. * Class used to render a debug view of a given skeleton
  101201. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  101202. */
  101203. export class SkeletonViewer {
  101204. /** defines the skeleton to render */
  101205. skeleton: Skeleton;
  101206. /** defines the mesh attached to the skeleton */
  101207. mesh: AbstractMesh;
  101208. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101209. autoUpdateBonesMatrices: boolean;
  101210. /** defines the rendering group id to use with the viewer */
  101211. renderingGroupId: number;
  101212. /** Gets or sets the color used to render the skeleton */
  101213. color: Color3;
  101214. private _scene;
  101215. private _debugLines;
  101216. private _debugMesh;
  101217. private _isEnabled;
  101218. private _renderFunction;
  101219. private _utilityLayer;
  101220. /**
  101221. * Returns the mesh used to render the bones
  101222. */
  101223. readonly debugMesh: Nullable<LinesMesh>;
  101224. /**
  101225. * Creates a new SkeletonViewer
  101226. * @param skeleton defines the skeleton to render
  101227. * @param mesh defines the mesh attached to the skeleton
  101228. * @param scene defines the hosting scene
  101229. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  101230. * @param renderingGroupId defines the rendering group id to use with the viewer
  101231. */
  101232. constructor(
  101233. /** defines the skeleton to render */
  101234. skeleton: Skeleton,
  101235. /** defines the mesh attached to the skeleton */
  101236. mesh: AbstractMesh, scene: Scene,
  101237. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  101238. autoUpdateBonesMatrices?: boolean,
  101239. /** defines the rendering group id to use with the viewer */
  101240. renderingGroupId?: number);
  101241. /** Gets or sets a boolean indicating if the viewer is enabled */
  101242. isEnabled: boolean;
  101243. private _getBonePosition;
  101244. private _getLinesForBonesWithLength;
  101245. private _getLinesForBonesNoLength;
  101246. /** Update the viewer to sync with current skeleton state */
  101247. update(): void;
  101248. /** Release associated resources */
  101249. dispose(): void;
  101250. }
  101251. }
  101252. declare module BABYLON {
  101253. /**
  101254. * Options to create the null engine
  101255. */
  101256. export class NullEngineOptions {
  101257. /**
  101258. * Render width (Default: 512)
  101259. */
  101260. renderWidth: number;
  101261. /**
  101262. * Render height (Default: 256)
  101263. */
  101264. renderHeight: number;
  101265. /**
  101266. * Texture size (Default: 512)
  101267. */
  101268. textureSize: number;
  101269. /**
  101270. * If delta time between frames should be constant
  101271. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101272. */
  101273. deterministicLockstep: boolean;
  101274. /**
  101275. * Maximum about of steps between frames (Default: 4)
  101276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101277. */
  101278. lockstepMaxSteps: number;
  101279. }
  101280. /**
  101281. * The null engine class provides support for headless version of babylon.js.
  101282. * This can be used in server side scenario or for testing purposes
  101283. */
  101284. export class NullEngine extends Engine {
  101285. private _options;
  101286. /**
  101287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101288. */
  101289. isDeterministicLockStep(): boolean;
  101290. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  101291. getLockstepMaxSteps(): number;
  101292. /**
  101293. * Sets hardware scaling, used to save performance if needed
  101294. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101295. */
  101296. getHardwareScalingLevel(): number;
  101297. constructor(options?: NullEngineOptions);
  101298. createVertexBuffer(vertices: FloatArray): DataBuffer;
  101299. createIndexBuffer(indices: IndicesArray): DataBuffer;
  101300. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101301. getRenderWidth(useScreen?: boolean): number;
  101302. getRenderHeight(useScreen?: boolean): number;
  101303. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  101304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  101305. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101306. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101307. bindSamplers(effect: Effect): void;
  101308. enableEffect(effect: Effect): void;
  101309. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101310. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  101311. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  101312. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  101313. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  101314. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  101315. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  101316. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  101317. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  101318. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  101319. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  101320. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  101321. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  101322. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  101323. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  101324. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101325. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  101326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  101327. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  101328. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  101329. setBool(uniform: WebGLUniformLocation, bool: number): void;
  101330. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  101331. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  101332. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  101333. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101334. bindBuffers(vertexBuffers: {
  101335. [key: string]: VertexBuffer;
  101336. }, indexBuffer: DataBuffer, effect: Effect): void;
  101337. wipeCaches(bruteForce?: boolean): void;
  101338. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101339. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101340. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101341. /** @hidden */
  101342. _createTexture(): WebGLTexture;
  101343. /** @hidden */
  101344. _releaseTexture(texture: InternalTexture): void;
  101345. 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;
  101346. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  101347. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  101348. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  101349. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101350. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  101351. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  101352. areAllEffectsReady(): boolean;
  101353. /**
  101354. * @hidden
  101355. * Get the current error code of the webGL context
  101356. * @returns the error code
  101357. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  101358. */
  101359. getError(): number;
  101360. /** @hidden */
  101361. _getUnpackAlignement(): number;
  101362. /** @hidden */
  101363. _unpackFlipY(value: boolean): void;
  101364. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  101365. /**
  101366. * Updates a dynamic vertex buffer.
  101367. * @param vertexBuffer the vertex buffer to update
  101368. * @param data the data used to update the vertex buffer
  101369. * @param byteOffset the byte offset of the data (optional)
  101370. * @param byteLength the byte length of the data (optional)
  101371. */
  101372. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  101373. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  101374. /** @hidden */
  101375. _bindTexture(channel: number, texture: InternalTexture): void;
  101376. /** @hidden */
  101377. _releaseBuffer(buffer: DataBuffer): boolean;
  101378. releaseEffects(): void;
  101379. displayLoadingUI(): void;
  101380. hideLoadingUI(): void;
  101381. /** @hidden */
  101382. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101383. /** @hidden */
  101384. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101385. /** @hidden */
  101386. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  101387. /** @hidden */
  101388. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  101389. }
  101390. }
  101391. declare module BABYLON {
  101392. /** @hidden */
  101393. export class _OcclusionDataStorage {
  101394. /** @hidden */
  101395. occlusionInternalRetryCounter: number;
  101396. /** @hidden */
  101397. isOcclusionQueryInProgress: boolean;
  101398. /** @hidden */
  101399. isOccluded: boolean;
  101400. /** @hidden */
  101401. occlusionRetryCount: number;
  101402. /** @hidden */
  101403. occlusionType: number;
  101404. /** @hidden */
  101405. occlusionQueryAlgorithmType: number;
  101406. }
  101407. interface Engine {
  101408. /**
  101409. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  101410. * @return the new query
  101411. */
  101412. createQuery(): WebGLQuery;
  101413. /**
  101414. * Delete and release a webGL query
  101415. * @param query defines the query to delete
  101416. * @return the current engine
  101417. */
  101418. deleteQuery(query: WebGLQuery): Engine;
  101419. /**
  101420. * Check if a given query has resolved and got its value
  101421. * @param query defines the query to check
  101422. * @returns true if the query got its value
  101423. */
  101424. isQueryResultAvailable(query: WebGLQuery): boolean;
  101425. /**
  101426. * Gets the value of a given query
  101427. * @param query defines the query to check
  101428. * @returns the value of the query
  101429. */
  101430. getQueryResult(query: WebGLQuery): number;
  101431. /**
  101432. * Initiates an occlusion query
  101433. * @param algorithmType defines the algorithm to use
  101434. * @param query defines the query to use
  101435. * @returns the current engine
  101436. * @see http://doc.babylonjs.com/features/occlusionquery
  101437. */
  101438. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  101439. /**
  101440. * Ends an occlusion query
  101441. * @see http://doc.babylonjs.com/features/occlusionquery
  101442. * @param algorithmType defines the algorithm to use
  101443. * @returns the current engine
  101444. */
  101445. endOcclusionQuery(algorithmType: number): Engine;
  101446. /**
  101447. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  101448. * Please note that only one query can be issued at a time
  101449. * @returns a time token used to track the time span
  101450. */
  101451. startTimeQuery(): Nullable<_TimeToken>;
  101452. /**
  101453. * Ends a time query
  101454. * @param token defines the token used to measure the time span
  101455. * @returns the time spent (in ns)
  101456. */
  101457. endTimeQuery(token: _TimeToken): int;
  101458. /** @hidden */
  101459. _currentNonTimestampToken: Nullable<_TimeToken>;
  101460. /** @hidden */
  101461. _createTimeQuery(): WebGLQuery;
  101462. /** @hidden */
  101463. _deleteTimeQuery(query: WebGLQuery): void;
  101464. /** @hidden */
  101465. _getGlAlgorithmType(algorithmType: number): number;
  101466. /** @hidden */
  101467. _getTimeQueryResult(query: WebGLQuery): any;
  101468. /** @hidden */
  101469. _getTimeQueryAvailability(query: WebGLQuery): any;
  101470. }
  101471. interface AbstractMesh {
  101472. /**
  101473. * Backing filed
  101474. * @hidden
  101475. */
  101476. __occlusionDataStorage: _OcclusionDataStorage;
  101477. /**
  101478. * Access property
  101479. * @hidden
  101480. */
  101481. _occlusionDataStorage: _OcclusionDataStorage;
  101482. /**
  101483. * 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.
  101484. * The default value is -1 which means don't break the query and wait till the result
  101485. * @see http://doc.babylonjs.com/features/occlusionquery
  101486. */
  101487. occlusionRetryCount: number;
  101488. /**
  101489. * 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:
  101490. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  101491. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  101492. * * 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.
  101493. * @see http://doc.babylonjs.com/features/occlusionquery
  101494. */
  101495. occlusionType: number;
  101496. /**
  101497. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101498. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  101499. * * 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.
  101500. * @see http://doc.babylonjs.com/features/occlusionquery
  101501. */
  101502. occlusionQueryAlgorithmType: number;
  101503. /**
  101504. * 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
  101505. * @see http://doc.babylonjs.com/features/occlusionquery
  101506. */
  101507. isOccluded: boolean;
  101508. /**
  101509. * Flag to check the progress status of the query
  101510. * @see http://doc.babylonjs.com/features/occlusionquery
  101511. */
  101512. isOcclusionQueryInProgress: boolean;
  101513. }
  101514. }
  101515. declare module BABYLON {
  101516. /** @hidden */
  101517. export var _forceTransformFeedbackToBundle: boolean;
  101518. interface Engine {
  101519. /**
  101520. * Creates a webGL transform feedback object
  101521. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101522. * @returns the webGL transform feedback object
  101523. */
  101524. createTransformFeedback(): WebGLTransformFeedback;
  101525. /**
  101526. * Delete a webGL transform feedback object
  101527. * @param value defines the webGL transform feedback object to delete
  101528. */
  101529. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101530. /**
  101531. * Bind a webGL transform feedback object to the webgl context
  101532. * @param value defines the webGL transform feedback object to bind
  101533. */
  101534. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101535. /**
  101536. * Begins a transform feedback operation
  101537. * @param usePoints defines if points or triangles must be used
  101538. */
  101539. beginTransformFeedback(usePoints: boolean): void;
  101540. /**
  101541. * Ends a transform feedback operation
  101542. */
  101543. endTransformFeedback(): void;
  101544. /**
  101545. * Specify the varyings to use with transform feedback
  101546. * @param program defines the associated webGL program
  101547. * @param value defines the list of strings representing the varying names
  101548. */
  101549. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101550. /**
  101551. * Bind a webGL buffer for a transform feedback operation
  101552. * @param value defines the webGL buffer to bind
  101553. */
  101554. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101555. }
  101556. }
  101557. declare module BABYLON {
  101558. /**
  101559. * Creation options of the multi render target texture.
  101560. */
  101561. export interface IMultiRenderTargetOptions {
  101562. /**
  101563. * Define if the texture needs to create mip maps after render.
  101564. */
  101565. generateMipMaps?: boolean;
  101566. /**
  101567. * Define the types of all the draw buffers we want to create
  101568. */
  101569. types?: number[];
  101570. /**
  101571. * Define the sampling modes of all the draw buffers we want to create
  101572. */
  101573. samplingModes?: number[];
  101574. /**
  101575. * Define if a depth buffer is required
  101576. */
  101577. generateDepthBuffer?: boolean;
  101578. /**
  101579. * Define if a stencil buffer is required
  101580. */
  101581. generateStencilBuffer?: boolean;
  101582. /**
  101583. * Define if a depth texture is required instead of a depth buffer
  101584. */
  101585. generateDepthTexture?: boolean;
  101586. /**
  101587. * Define the number of desired draw buffers
  101588. */
  101589. textureCount?: number;
  101590. /**
  101591. * Define if aspect ratio should be adapted to the texture or stay the scene one
  101592. */
  101593. doNotChangeAspectRatio?: boolean;
  101594. /**
  101595. * Define the default type of the buffers we are creating
  101596. */
  101597. defaultType?: number;
  101598. }
  101599. /**
  101600. * A multi render target, like a render target provides the ability to render to a texture.
  101601. * Unlike the render target, it can render to several draw buffers in one draw.
  101602. * This is specially interesting in deferred rendering or for any effects requiring more than
  101603. * just one color from a single pass.
  101604. */
  101605. export class MultiRenderTarget extends RenderTargetTexture {
  101606. private _internalTextures;
  101607. private _textures;
  101608. private _multiRenderTargetOptions;
  101609. /**
  101610. * Get if draw buffers are currently supported by the used hardware and browser.
  101611. */
  101612. readonly isSupported: boolean;
  101613. /**
  101614. * Get the list of textures generated by the multi render target.
  101615. */
  101616. readonly textures: Texture[];
  101617. /**
  101618. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  101619. */
  101620. readonly depthTexture: Texture;
  101621. /**
  101622. * Set the wrapping mode on U of all the textures we are rendering to.
  101623. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101624. */
  101625. wrapU: number;
  101626. /**
  101627. * Set the wrapping mode on V of all the textures we are rendering to.
  101628. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  101629. */
  101630. wrapV: number;
  101631. /**
  101632. * Instantiate a new multi render target texture.
  101633. * A multi render target, like a render target provides the ability to render to a texture.
  101634. * Unlike the render target, it can render to several draw buffers in one draw.
  101635. * This is specially interesting in deferred rendering or for any effects requiring more than
  101636. * just one color from a single pass.
  101637. * @param name Define the name of the texture
  101638. * @param size Define the size of the buffers to render to
  101639. * @param count Define the number of target we are rendering into
  101640. * @param scene Define the scene the texture belongs to
  101641. * @param options Define the options used to create the multi render target
  101642. */
  101643. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  101644. /** @hidden */
  101645. _rebuild(): void;
  101646. private _createInternalTextures;
  101647. private _createTextures;
  101648. /**
  101649. * Define the number of samples used if MSAA is enabled.
  101650. */
  101651. samples: number;
  101652. /**
  101653. * Resize all the textures in the multi render target.
  101654. * Be carrefull as it will recreate all the data in the new texture.
  101655. * @param size Define the new size
  101656. */
  101657. resize(size: any): void;
  101658. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101659. /**
  101660. * Dispose the render targets and their associated resources
  101661. */
  101662. dispose(): void;
  101663. /**
  101664. * Release all the underlying texture used as draw buffers.
  101665. */
  101666. releaseInternalTextures(): void;
  101667. }
  101668. }
  101669. declare module BABYLON {
  101670. interface Engine {
  101671. /**
  101672. * Unbind a list of render target textures from the webGL context
  101673. * This is used only when drawBuffer extension or webGL2 are active
  101674. * @param textures defines the render target textures to unbind
  101675. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101676. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101677. */
  101678. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  101679. /**
  101680. * Create a multi render target texture
  101681. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  101682. * @param size defines the size of the texture
  101683. * @param options defines the creation options
  101684. * @returns the cube texture as an InternalTexture
  101685. */
  101686. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  101687. /**
  101688. * Update the sample count for a given multiple render target texture
  101689. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  101690. * @param textures defines the textures to update
  101691. * @param samples defines the sample count to set
  101692. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  101693. */
  101694. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  101695. }
  101696. }
  101697. declare module BABYLON {
  101698. /**
  101699. * Gather the list of clipboard event types as constants.
  101700. */
  101701. export class ClipboardEventTypes {
  101702. /**
  101703. * The clipboard event is fired when a copy command is active (pressed).
  101704. */
  101705. static readonly COPY: number;
  101706. /**
  101707. * The clipboard event is fired when a cut command is active (pressed).
  101708. */
  101709. static readonly CUT: number;
  101710. /**
  101711. * The clipboard event is fired when a paste command is active (pressed).
  101712. */
  101713. static readonly PASTE: number;
  101714. }
  101715. /**
  101716. * This class is used to store clipboard related info for the onClipboardObservable event.
  101717. */
  101718. export class ClipboardInfo {
  101719. /**
  101720. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101721. */
  101722. type: number;
  101723. /**
  101724. * Defines the related dom event
  101725. */
  101726. event: ClipboardEvent;
  101727. /**
  101728. *Creates an instance of ClipboardInfo.
  101729. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101730. * @param event Defines the related dom event
  101731. */
  101732. constructor(
  101733. /**
  101734. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101735. */
  101736. type: number,
  101737. /**
  101738. * Defines the related dom event
  101739. */
  101740. event: ClipboardEvent);
  101741. /**
  101742. * Get the clipboard event's type from the keycode.
  101743. * @param keyCode Defines the keyCode for the current keyboard event.
  101744. * @return {number}
  101745. */
  101746. static GetTypeFromCharacter(keyCode: number): number;
  101747. }
  101748. }
  101749. declare module BABYLON {
  101750. /**
  101751. * Class used to represent data loading progression
  101752. */
  101753. export class SceneLoaderProgressEvent {
  101754. /** defines if data length to load can be evaluated */
  101755. readonly lengthComputable: boolean;
  101756. /** defines the loaded data length */
  101757. readonly loaded: number;
  101758. /** defines the data length to load */
  101759. readonly total: number;
  101760. /**
  101761. * Create a new progress event
  101762. * @param lengthComputable defines if data length to load can be evaluated
  101763. * @param loaded defines the loaded data length
  101764. * @param total defines the data length to load
  101765. */
  101766. constructor(
  101767. /** defines if data length to load can be evaluated */
  101768. lengthComputable: boolean,
  101769. /** defines the loaded data length */
  101770. loaded: number,
  101771. /** defines the data length to load */
  101772. total: number);
  101773. /**
  101774. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101775. * @param event defines the source event
  101776. * @returns a new SceneLoaderProgressEvent
  101777. */
  101778. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101779. }
  101780. /**
  101781. * Interface used by SceneLoader plugins to define supported file extensions
  101782. */
  101783. export interface ISceneLoaderPluginExtensions {
  101784. /**
  101785. * Defines the list of supported extensions
  101786. */
  101787. [extension: string]: {
  101788. isBinary: boolean;
  101789. };
  101790. }
  101791. /**
  101792. * Interface used by SceneLoader plugin factory
  101793. */
  101794. export interface ISceneLoaderPluginFactory {
  101795. /**
  101796. * Defines the name of the factory
  101797. */
  101798. name: string;
  101799. /**
  101800. * Function called to create a new plugin
  101801. * @return the new plugin
  101802. */
  101803. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101804. /**
  101805. * Boolean indicating if the plugin can direct load specific data
  101806. */
  101807. canDirectLoad?: (data: string) => boolean;
  101808. }
  101809. /**
  101810. * Interface used to define a SceneLoader plugin
  101811. */
  101812. export interface ISceneLoaderPlugin {
  101813. /**
  101814. * The friendly name of this plugin.
  101815. */
  101816. name: string;
  101817. /**
  101818. * The file extensions supported by this plugin.
  101819. */
  101820. extensions: string | ISceneLoaderPluginExtensions;
  101821. /**
  101822. * Import meshes into a scene.
  101823. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101824. * @param scene The scene to import into
  101825. * @param data The data to import
  101826. * @param rootUrl The root url for scene and resources
  101827. * @param meshes The meshes array to import into
  101828. * @param particleSystems The particle systems array to import into
  101829. * @param skeletons The skeletons array to import into
  101830. * @param onError The callback when import fails
  101831. * @returns True if successful or false otherwise
  101832. */
  101833. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101834. /**
  101835. * Load into a scene.
  101836. * @param scene The scene to load into
  101837. * @param data The data to import
  101838. * @param rootUrl The root url for scene and resources
  101839. * @param onError The callback when import fails
  101840. * @returns true if successful or false otherwise
  101841. */
  101842. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101843. /**
  101844. * The callback that returns true if the data can be directly loaded.
  101845. */
  101846. canDirectLoad?: (data: string) => boolean;
  101847. /**
  101848. * The callback that allows custom handling of the root url based on the response url.
  101849. */
  101850. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101851. /**
  101852. * Load into an asset container.
  101853. * @param scene The scene to load into
  101854. * @param data The data to import
  101855. * @param rootUrl The root url for scene and resources
  101856. * @param onError The callback when import fails
  101857. * @returns The loaded asset container
  101858. */
  101859. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101860. }
  101861. /**
  101862. * Interface used to define an async SceneLoader plugin
  101863. */
  101864. export interface ISceneLoaderPluginAsync {
  101865. /**
  101866. * The friendly name of this plugin.
  101867. */
  101868. name: string;
  101869. /**
  101870. * The file extensions supported by this plugin.
  101871. */
  101872. extensions: string | ISceneLoaderPluginExtensions;
  101873. /**
  101874. * Import meshes into a scene.
  101875. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101876. * @param scene The scene to import into
  101877. * @param data The data to import
  101878. * @param rootUrl The root url for scene and resources
  101879. * @param onProgress The callback when the load progresses
  101880. * @param fileName Defines the name of the file to load
  101881. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101882. */
  101883. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101884. meshes: AbstractMesh[];
  101885. particleSystems: IParticleSystem[];
  101886. skeletons: Skeleton[];
  101887. animationGroups: AnimationGroup[];
  101888. }>;
  101889. /**
  101890. * Load into a scene.
  101891. * @param scene The scene to load into
  101892. * @param data The data to import
  101893. * @param rootUrl The root url for scene and resources
  101894. * @param onProgress The callback when the load progresses
  101895. * @param fileName Defines the name of the file to load
  101896. * @returns Nothing
  101897. */
  101898. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101899. /**
  101900. * The callback that returns true if the data can be directly loaded.
  101901. */
  101902. canDirectLoad?: (data: string) => boolean;
  101903. /**
  101904. * The callback that allows custom handling of the root url based on the response url.
  101905. */
  101906. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101907. /**
  101908. * Load into an asset container.
  101909. * @param scene The scene to load into
  101910. * @param data The data to import
  101911. * @param rootUrl The root url for scene and resources
  101912. * @param onProgress The callback when the load progresses
  101913. * @param fileName Defines the name of the file to load
  101914. * @returns The loaded asset container
  101915. */
  101916. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101917. }
  101918. /**
  101919. * Class used to load scene from various file formats using registered plugins
  101920. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101921. */
  101922. export class SceneLoader {
  101923. /**
  101924. * No logging while loading
  101925. */
  101926. static readonly NO_LOGGING: number;
  101927. /**
  101928. * Minimal logging while loading
  101929. */
  101930. static readonly MINIMAL_LOGGING: number;
  101931. /**
  101932. * Summary logging while loading
  101933. */
  101934. static readonly SUMMARY_LOGGING: number;
  101935. /**
  101936. * Detailled logging while loading
  101937. */
  101938. static readonly DETAILED_LOGGING: number;
  101939. /**
  101940. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101941. */
  101942. static ForceFullSceneLoadingForIncremental: boolean;
  101943. /**
  101944. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101945. */
  101946. static ShowLoadingScreen: boolean;
  101947. /**
  101948. * Defines the current logging level (while loading the scene)
  101949. * @ignorenaming
  101950. */
  101951. static loggingLevel: number;
  101952. /**
  101953. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101954. */
  101955. static CleanBoneMatrixWeights: boolean;
  101956. /**
  101957. * Event raised when a plugin is used to load a scene
  101958. */
  101959. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101960. private static _registeredPlugins;
  101961. private static _getDefaultPlugin;
  101962. private static _getPluginForExtension;
  101963. private static _getPluginForDirectLoad;
  101964. private static _getPluginForFilename;
  101965. private static _getDirectLoad;
  101966. private static _loadData;
  101967. private static _getFileInfo;
  101968. /**
  101969. * Gets a plugin that can load the given extension
  101970. * @param extension defines the extension to load
  101971. * @returns a plugin or null if none works
  101972. */
  101973. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101974. /**
  101975. * Gets a boolean indicating that the given extension can be loaded
  101976. * @param extension defines the extension to load
  101977. * @returns true if the extension is supported
  101978. */
  101979. static IsPluginForExtensionAvailable(extension: string): boolean;
  101980. /**
  101981. * Adds a new plugin to the list of registered plugins
  101982. * @param plugin defines the plugin to add
  101983. */
  101984. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101985. /**
  101986. * Import meshes into a scene
  101987. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101988. * @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)
  101989. * @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)
  101990. * @param scene the instance of BABYLON.Scene to append to
  101991. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101992. * @param onProgress a callback with a progress event for each file being loaded
  101993. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101994. * @param pluginExtension the extension used to determine the plugin
  101995. * @returns The loaded plugin
  101996. */
  101997. 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>;
  101998. /**
  101999. * Import meshes into a scene
  102000. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  102001. * @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)
  102002. * @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)
  102003. * @param scene the instance of BABYLON.Scene to append to
  102004. * @param onProgress a callback with a progress event for each file being loaded
  102005. * @param pluginExtension the extension used to determine the plugin
  102006. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  102007. */
  102008. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  102009. meshes: AbstractMesh[];
  102010. particleSystems: IParticleSystem[];
  102011. skeletons: Skeleton[];
  102012. animationGroups: AnimationGroup[];
  102013. }>;
  102014. /**
  102015. * Load a scene
  102016. * @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)
  102017. * @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)
  102018. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102019. * @param onSuccess a callback with the scene when import succeeds
  102020. * @param onProgress a callback with a progress event for each file being loaded
  102021. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102022. * @param pluginExtension the extension used to determine the plugin
  102023. * @returns The loaded plugin
  102024. */
  102025. 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>;
  102026. /**
  102027. * Load a scene
  102028. * @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)
  102029. * @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)
  102030. * @param engine is the instance of BABYLON.Engine to use to create the scene
  102031. * @param onProgress a callback with a progress event for each file being loaded
  102032. * @param pluginExtension the extension used to determine the plugin
  102033. * @returns The loaded scene
  102034. */
  102035. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102036. /**
  102037. * Append a scene
  102038. * @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)
  102039. * @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)
  102040. * @param scene is the instance of BABYLON.Scene to append to
  102041. * @param onSuccess a callback with the scene when import succeeds
  102042. * @param onProgress a callback with a progress event for each file being loaded
  102043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102044. * @param pluginExtension the extension used to determine the plugin
  102045. * @returns The loaded plugin
  102046. */
  102047. 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>;
  102048. /**
  102049. * Append a scene
  102050. * @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)
  102051. * @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)
  102052. * @param scene is the instance of BABYLON.Scene to append to
  102053. * @param onProgress a callback with a progress event for each file being loaded
  102054. * @param pluginExtension the extension used to determine the plugin
  102055. * @returns The given scene
  102056. */
  102057. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  102058. /**
  102059. * Load a scene into an asset container
  102060. * @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)
  102061. * @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)
  102062. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  102063. * @param onSuccess a callback with the scene when import succeeds
  102064. * @param onProgress a callback with a progress event for each file being loaded
  102065. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  102066. * @param pluginExtension the extension used to determine the plugin
  102067. * @returns The loaded plugin
  102068. */
  102069. 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>;
  102070. /**
  102071. * Load a scene into an asset container
  102072. * @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)
  102073. * @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)
  102074. * @param scene is the instance of Scene to append to
  102075. * @param onProgress a callback with a progress event for each file being loaded
  102076. * @param pluginExtension the extension used to determine the plugin
  102077. * @returns The loaded asset container
  102078. */
  102079. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  102080. }
  102081. }
  102082. declare module BABYLON {
  102083. /**
  102084. * Google Daydream controller
  102085. */
  102086. export class DaydreamController extends WebVRController {
  102087. /**
  102088. * Base Url for the controller model.
  102089. */
  102090. static MODEL_BASE_URL: string;
  102091. /**
  102092. * File name for the controller model.
  102093. */
  102094. static MODEL_FILENAME: string;
  102095. /**
  102096. * Gamepad Id prefix used to identify Daydream Controller.
  102097. */
  102098. static readonly GAMEPAD_ID_PREFIX: string;
  102099. /**
  102100. * Creates a new DaydreamController from a gamepad
  102101. * @param vrGamepad the gamepad that the controller should be created from
  102102. */
  102103. constructor(vrGamepad: any);
  102104. /**
  102105. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102106. * @param scene scene in which to add meshes
  102107. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102108. */
  102109. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102110. /**
  102111. * Called once for each button that changed state since the last frame
  102112. * @param buttonIdx Which button index changed
  102113. * @param state New state of the button
  102114. * @param changes Which properties on the state changed since last frame
  102115. */
  102116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /**
  102121. * Gear VR Controller
  102122. */
  102123. export class GearVRController extends WebVRController {
  102124. /**
  102125. * Base Url for the controller model.
  102126. */
  102127. static MODEL_BASE_URL: string;
  102128. /**
  102129. * File name for the controller model.
  102130. */
  102131. static MODEL_FILENAME: string;
  102132. /**
  102133. * Gamepad Id prefix used to identify this controller.
  102134. */
  102135. static readonly GAMEPAD_ID_PREFIX: string;
  102136. private readonly _buttonIndexToObservableNameMap;
  102137. /**
  102138. * Creates a new GearVRController from a gamepad
  102139. * @param vrGamepad the gamepad that the controller should be created from
  102140. */
  102141. constructor(vrGamepad: any);
  102142. /**
  102143. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102144. * @param scene scene in which to add meshes
  102145. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102146. */
  102147. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102148. /**
  102149. * Called once for each button that changed state since the last frame
  102150. * @param buttonIdx Which button index changed
  102151. * @param state New state of the button
  102152. * @param changes Which properties on the state changed since last frame
  102153. */
  102154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102155. }
  102156. }
  102157. declare module BABYLON {
  102158. /**
  102159. * Generic Controller
  102160. */
  102161. export class GenericController extends WebVRController {
  102162. /**
  102163. * Base Url for the controller model.
  102164. */
  102165. static readonly MODEL_BASE_URL: string;
  102166. /**
  102167. * File name for the controller model.
  102168. */
  102169. static readonly MODEL_FILENAME: string;
  102170. /**
  102171. * Creates a new GenericController from a gamepad
  102172. * @param vrGamepad the gamepad that the controller should be created from
  102173. */
  102174. constructor(vrGamepad: any);
  102175. /**
  102176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102177. * @param scene scene in which to add meshes
  102178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102179. */
  102180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102181. /**
  102182. * Called once for each button that changed state since the last frame
  102183. * @param buttonIdx Which button index changed
  102184. * @param state New state of the button
  102185. * @param changes Which properties on the state changed since last frame
  102186. */
  102187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102188. }
  102189. }
  102190. declare module BABYLON {
  102191. /**
  102192. * Oculus Touch Controller
  102193. */
  102194. export class OculusTouchController extends WebVRController {
  102195. /**
  102196. * Base Url for the controller model.
  102197. */
  102198. static MODEL_BASE_URL: string;
  102199. /**
  102200. * File name for the left controller model.
  102201. */
  102202. static MODEL_LEFT_FILENAME: string;
  102203. /**
  102204. * File name for the right controller model.
  102205. */
  102206. static MODEL_RIGHT_FILENAME: string;
  102207. /**
  102208. * Fired when the secondary trigger on this controller is modified
  102209. */
  102210. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  102211. /**
  102212. * Fired when the thumb rest on this controller is modified
  102213. */
  102214. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  102215. /**
  102216. * Creates a new OculusTouchController from a gamepad
  102217. * @param vrGamepad the gamepad that the controller should be created from
  102218. */
  102219. constructor(vrGamepad: any);
  102220. /**
  102221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102222. * @param scene scene in which to add meshes
  102223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102224. */
  102225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102226. /**
  102227. * Fired when the A button on this controller is modified
  102228. */
  102229. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102230. /**
  102231. * Fired when the B button on this controller is modified
  102232. */
  102233. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102234. /**
  102235. * Fired when the X button on this controller is modified
  102236. */
  102237. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102238. /**
  102239. * Fired when the Y button on this controller is modified
  102240. */
  102241. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102242. /**
  102243. * Called once for each button that changed state since the last frame
  102244. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  102245. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  102246. * 2) secondary trigger (same)
  102247. * 3) A (right) X (left), touch, pressed = value
  102248. * 4) B / Y
  102249. * 5) thumb rest
  102250. * @param buttonIdx Which button index changed
  102251. * @param state New state of the button
  102252. * @param changes Which properties on the state changed since last frame
  102253. */
  102254. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /**
  102259. * Vive Controller
  102260. */
  102261. export class ViveController extends WebVRController {
  102262. /**
  102263. * Base Url for the controller model.
  102264. */
  102265. static MODEL_BASE_URL: string;
  102266. /**
  102267. * File name for the controller model.
  102268. */
  102269. static MODEL_FILENAME: string;
  102270. /**
  102271. * Creates a new ViveController from a gamepad
  102272. * @param vrGamepad the gamepad that the controller should be created from
  102273. */
  102274. constructor(vrGamepad: any);
  102275. /**
  102276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102277. * @param scene scene in which to add meshes
  102278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102279. */
  102280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  102281. /**
  102282. * Fired when the left button on this controller is modified
  102283. */
  102284. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102285. /**
  102286. * Fired when the right button on this controller is modified
  102287. */
  102288. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102289. /**
  102290. * Fired when the menu button on this controller is modified
  102291. */
  102292. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102293. /**
  102294. * Called once for each button that changed state since the last frame
  102295. * Vive mapping:
  102296. * 0: touchpad
  102297. * 1: trigger
  102298. * 2: left AND right buttons
  102299. * 3: menu button
  102300. * @param buttonIdx Which button index changed
  102301. * @param state New state of the button
  102302. * @param changes Which properties on the state changed since last frame
  102303. */
  102304. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102305. }
  102306. }
  102307. declare module BABYLON {
  102308. /**
  102309. * Defines the WindowsMotionController object that the state of the windows motion controller
  102310. */
  102311. export class WindowsMotionController extends WebVRController {
  102312. /**
  102313. * The base url used to load the left and right controller models
  102314. */
  102315. static MODEL_BASE_URL: string;
  102316. /**
  102317. * The name of the left controller model file
  102318. */
  102319. static MODEL_LEFT_FILENAME: string;
  102320. /**
  102321. * The name of the right controller model file
  102322. */
  102323. static MODEL_RIGHT_FILENAME: string;
  102324. /**
  102325. * The controller name prefix for this controller type
  102326. */
  102327. static readonly GAMEPAD_ID_PREFIX: string;
  102328. /**
  102329. * The controller id pattern for this controller type
  102330. */
  102331. private static readonly GAMEPAD_ID_PATTERN;
  102332. private _loadedMeshInfo;
  102333. private readonly _mapping;
  102334. /**
  102335. * Fired when the trackpad on this controller is clicked
  102336. */
  102337. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  102338. /**
  102339. * Fired when the trackpad on this controller is modified
  102340. */
  102341. onTrackpadValuesChangedObservable: Observable<StickValues>;
  102342. /**
  102343. * The current x and y values of this controller's trackpad
  102344. */
  102345. trackpad: StickValues;
  102346. /**
  102347. * Creates a new WindowsMotionController from a gamepad
  102348. * @param vrGamepad the gamepad that the controller should be created from
  102349. */
  102350. constructor(vrGamepad: any);
  102351. /**
  102352. * Fired when the trigger on this controller is modified
  102353. */
  102354. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102355. /**
  102356. * Fired when the menu button on this controller is modified
  102357. */
  102358. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102359. /**
  102360. * Fired when the grip button on this controller is modified
  102361. */
  102362. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102363. /**
  102364. * Fired when the thumbstick button on this controller is modified
  102365. */
  102366. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102367. /**
  102368. * Fired when the touchpad button on this controller is modified
  102369. */
  102370. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  102371. /**
  102372. * Fired when the touchpad values on this controller are modified
  102373. */
  102374. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  102375. private _updateTrackpad;
  102376. /**
  102377. * Called once per frame by the engine.
  102378. */
  102379. update(): void;
  102380. /**
  102381. * Called once for each button that changed state since the last frame
  102382. * @param buttonIdx Which button index changed
  102383. * @param state New state of the button
  102384. * @param changes Which properties on the state changed since last frame
  102385. */
  102386. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  102387. /**
  102388. * Moves the buttons on the controller mesh based on their current state
  102389. * @param buttonName the name of the button to move
  102390. * @param buttonValue the value of the button which determines the buttons new position
  102391. */
  102392. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  102393. /**
  102394. * Moves the axis on the controller mesh based on its current state
  102395. * @param axis the index of the axis
  102396. * @param axisValue the value of the axis which determines the meshes new position
  102397. * @hidden
  102398. */
  102399. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  102400. /**
  102401. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  102402. * @param scene scene in which to add meshes
  102403. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  102404. */
  102405. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  102406. /**
  102407. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  102408. * can be transformed by button presses and axes values, based on this._mapping.
  102409. *
  102410. * @param scene scene in which the meshes exist
  102411. * @param meshes list of meshes that make up the controller model to process
  102412. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  102413. */
  102414. private processModel;
  102415. private createMeshInfo;
  102416. /**
  102417. * Gets the ray of the controller in the direction the controller is pointing
  102418. * @param length the length the resulting ray should be
  102419. * @returns a ray in the direction the controller is pointing
  102420. */
  102421. getForwardRay(length?: number): Ray;
  102422. /**
  102423. * Disposes of the controller
  102424. */
  102425. dispose(): void;
  102426. }
  102427. }
  102428. declare module BABYLON {
  102429. /**
  102430. * Single axis scale gizmo
  102431. */
  102432. export class AxisScaleGizmo extends Gizmo {
  102433. private _coloredMaterial;
  102434. /**
  102435. * Drag behavior responsible for the gizmos dragging interactions
  102436. */
  102437. dragBehavior: PointerDragBehavior;
  102438. private _pointerObserver;
  102439. /**
  102440. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102441. */
  102442. snapDistance: number;
  102443. /**
  102444. * Event that fires each time the gizmo snaps to a new location.
  102445. * * snapDistance is the the change in distance
  102446. */
  102447. onSnapObservable: Observable<{
  102448. snapDistance: number;
  102449. }>;
  102450. /**
  102451. * If the scaling operation should be done on all axis (default: false)
  102452. */
  102453. uniformScaling: boolean;
  102454. /**
  102455. * Creates an AxisScaleGizmo
  102456. * @param gizmoLayer The utility layer the gizmo will be added to
  102457. * @param dragAxis The axis which the gizmo will be able to scale on
  102458. * @param color The color of the gizmo
  102459. */
  102460. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102461. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102462. /**
  102463. * Disposes of the gizmo
  102464. */
  102465. dispose(): void;
  102466. /**
  102467. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102468. * @param mesh The mesh to replace the default mesh of the gizmo
  102469. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  102470. */
  102471. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Bounding box gizmo
  102477. */
  102478. export class BoundingBoxGizmo extends Gizmo {
  102479. private _lineBoundingBox;
  102480. private _rotateSpheresParent;
  102481. private _scaleBoxesParent;
  102482. private _boundingDimensions;
  102483. private _renderObserver;
  102484. private _pointerObserver;
  102485. private _scaleDragSpeed;
  102486. private _tmpQuaternion;
  102487. private _tmpVector;
  102488. private _tmpRotationMatrix;
  102489. /**
  102490. * 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)
  102491. */
  102492. ignoreChildren: boolean;
  102493. /**
  102494. * 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)
  102495. */
  102496. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  102497. /**
  102498. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  102499. */
  102500. rotationSphereSize: number;
  102501. /**
  102502. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  102503. */
  102504. scaleBoxSize: number;
  102505. /**
  102506. * 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)
  102507. */
  102508. fixedDragMeshScreenSize: boolean;
  102509. /**
  102510. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  102511. */
  102512. fixedDragMeshScreenSizeDistanceFactor: number;
  102513. /**
  102514. * Fired when a rotation sphere or scale box is dragged
  102515. */
  102516. onDragStartObservable: Observable<{}>;
  102517. /**
  102518. * Fired when a scale box is dragged
  102519. */
  102520. onScaleBoxDragObservable: Observable<{}>;
  102521. /**
  102522. * Fired when a scale box drag is ended
  102523. */
  102524. onScaleBoxDragEndObservable: Observable<{}>;
  102525. /**
  102526. * Fired when a rotation sphere is dragged
  102527. */
  102528. onRotationSphereDragObservable: Observable<{}>;
  102529. /**
  102530. * Fired when a rotation sphere drag is ended
  102531. */
  102532. onRotationSphereDragEndObservable: Observable<{}>;
  102533. /**
  102534. * 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)
  102535. */
  102536. scalePivot: Nullable<Vector3>;
  102537. /**
  102538. * Mesh used as a pivot to rotate the attached mesh
  102539. */
  102540. private _anchorMesh;
  102541. private _existingMeshScale;
  102542. private _dragMesh;
  102543. private pointerDragBehavior;
  102544. private coloredMaterial;
  102545. private hoverColoredMaterial;
  102546. /**
  102547. * Sets the color of the bounding box gizmo
  102548. * @param color the color to set
  102549. */
  102550. setColor(color: Color3): void;
  102551. /**
  102552. * Creates an BoundingBoxGizmo
  102553. * @param gizmoLayer The utility layer the gizmo will be added to
  102554. * @param color The color of the gizmo
  102555. */
  102556. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  102557. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102558. private _selectNode;
  102559. /**
  102560. * Updates the bounding box information for the Gizmo
  102561. */
  102562. updateBoundingBox(): void;
  102563. private _updateRotationSpheres;
  102564. private _updateScaleBoxes;
  102565. /**
  102566. * Enables rotation on the specified axis and disables rotation on the others
  102567. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  102568. */
  102569. setEnabledRotationAxis(axis: string): void;
  102570. /**
  102571. * Enables/disables scaling
  102572. * @param enable if scaling should be enabled
  102573. */
  102574. setEnabledScaling(enable: boolean): void;
  102575. private _updateDummy;
  102576. /**
  102577. * Enables a pointer drag behavior on the bounding box of the gizmo
  102578. */
  102579. enableDragBehavior(): void;
  102580. /**
  102581. * Disposes of the gizmo
  102582. */
  102583. dispose(): void;
  102584. /**
  102585. * 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)
  102586. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  102587. * @returns the bounding box mesh with the passed in mesh as a child
  102588. */
  102589. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  102590. /**
  102591. * CustomMeshes are not supported by this gizmo
  102592. * @param mesh The mesh to replace the default mesh of the gizmo
  102593. */
  102594. setCustomMesh(mesh: Mesh): void;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /**
  102599. * Single plane rotation gizmo
  102600. */
  102601. export class PlaneRotationGizmo extends Gizmo {
  102602. /**
  102603. * Drag behavior responsible for the gizmos dragging interactions
  102604. */
  102605. dragBehavior: PointerDragBehavior;
  102606. private _pointerObserver;
  102607. /**
  102608. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  102609. */
  102610. snapDistance: number;
  102611. /**
  102612. * Event that fires each time the gizmo snaps to a new location.
  102613. * * snapDistance is the the change in distance
  102614. */
  102615. onSnapObservable: Observable<{
  102616. snapDistance: number;
  102617. }>;
  102618. /**
  102619. * Creates a PlaneRotationGizmo
  102620. * @param gizmoLayer The utility layer the gizmo will be added to
  102621. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  102622. * @param color The color of the gizmo
  102623. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102624. */
  102625. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102626. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102627. /**
  102628. * Disposes of the gizmo
  102629. */
  102630. dispose(): void;
  102631. }
  102632. }
  102633. declare module BABYLON {
  102634. /**
  102635. * Gizmo that enables rotating a mesh along 3 axis
  102636. */
  102637. export class RotationGizmo extends Gizmo {
  102638. /**
  102639. * Internal gizmo used for interactions on the x axis
  102640. */
  102641. xGizmo: PlaneRotationGizmo;
  102642. /**
  102643. * Internal gizmo used for interactions on the y axis
  102644. */
  102645. yGizmo: PlaneRotationGizmo;
  102646. /**
  102647. * Internal gizmo used for interactions on the z axis
  102648. */
  102649. zGizmo: PlaneRotationGizmo;
  102650. /** Fires an event when any of it's sub gizmos are dragged */
  102651. onDragStartObservable: Observable<{}>;
  102652. /** Fires an event when any of it's sub gizmos are released from dragging */
  102653. onDragEndObservable: Observable<{}>;
  102654. attachedMesh: Nullable<AbstractMesh>;
  102655. /**
  102656. * Creates a RotationGizmo
  102657. * @param gizmoLayer The utility layer the gizmo will be added to
  102658. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102659. */
  102660. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102661. updateGizmoRotationToMatchAttachedMesh: boolean;
  102662. /**
  102663. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102664. */
  102665. snapDistance: number;
  102666. /**
  102667. * Ratio for the scale of the gizmo (Default: 1)
  102668. */
  102669. scaleRatio: number;
  102670. /**
  102671. * Disposes of the gizmo
  102672. */
  102673. dispose(): void;
  102674. /**
  102675. * CustomMeshes are not supported by this gizmo
  102676. * @param mesh The mesh to replace the default mesh of the gizmo
  102677. */
  102678. setCustomMesh(mesh: Mesh): void;
  102679. }
  102680. }
  102681. declare module BABYLON {
  102682. /**
  102683. * Gizmo that enables dragging a mesh along 3 axis
  102684. */
  102685. export class PositionGizmo extends Gizmo {
  102686. /**
  102687. * Internal gizmo used for interactions on the x axis
  102688. */
  102689. xGizmo: AxisDragGizmo;
  102690. /**
  102691. * Internal gizmo used for interactions on the y axis
  102692. */
  102693. yGizmo: AxisDragGizmo;
  102694. /**
  102695. * Internal gizmo used for interactions on the z axis
  102696. */
  102697. zGizmo: AxisDragGizmo;
  102698. /** Fires an event when any of it's sub gizmos are dragged */
  102699. onDragStartObservable: Observable<{}>;
  102700. /** Fires an event when any of it's sub gizmos are released from dragging */
  102701. onDragEndObservable: Observable<{}>;
  102702. attachedMesh: Nullable<AbstractMesh>;
  102703. /**
  102704. * Creates a PositionGizmo
  102705. * @param gizmoLayer The utility layer the gizmo will be added to
  102706. */
  102707. constructor(gizmoLayer?: UtilityLayerRenderer);
  102708. updateGizmoRotationToMatchAttachedMesh: boolean;
  102709. /**
  102710. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102711. */
  102712. snapDistance: number;
  102713. /**
  102714. * Ratio for the scale of the gizmo (Default: 1)
  102715. */
  102716. scaleRatio: number;
  102717. /**
  102718. * Disposes of the gizmo
  102719. */
  102720. dispose(): void;
  102721. /**
  102722. * CustomMeshes are not supported by this gizmo
  102723. * @param mesh The mesh to replace the default mesh of the gizmo
  102724. */
  102725. setCustomMesh(mesh: Mesh): void;
  102726. }
  102727. }
  102728. declare module BABYLON {
  102729. /**
  102730. * Class containing static functions to help procedurally build meshes
  102731. */
  102732. export class PolyhedronBuilder {
  102733. /**
  102734. * Creates a polyhedron mesh
  102735. * * 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
  102736. * * The parameter `size` (positive float, default 1) sets the polygon size
  102737. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102738. * * 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`
  102739. * * 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
  102740. * * 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)`)
  102741. * * 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
  102742. * * 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
  102743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102746. * @param name defines the name of the mesh
  102747. * @param options defines the options used to create the mesh
  102748. * @param scene defines the hosting scene
  102749. * @returns the polyhedron mesh
  102750. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102751. */
  102752. static CreatePolyhedron(name: string, options: {
  102753. type?: number;
  102754. size?: number;
  102755. sizeX?: number;
  102756. sizeY?: number;
  102757. sizeZ?: number;
  102758. custom?: any;
  102759. faceUV?: Vector4[];
  102760. faceColors?: Color4[];
  102761. flat?: boolean;
  102762. updatable?: boolean;
  102763. sideOrientation?: number;
  102764. frontUVs?: Vector4;
  102765. backUVs?: Vector4;
  102766. }, scene?: Nullable<Scene>): Mesh;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /**
  102771. * Gizmo that enables scaling a mesh along 3 axis
  102772. */
  102773. export class ScaleGizmo extends Gizmo {
  102774. /**
  102775. * Internal gizmo used for interactions on the x axis
  102776. */
  102777. xGizmo: AxisScaleGizmo;
  102778. /**
  102779. * Internal gizmo used for interactions on the y axis
  102780. */
  102781. yGizmo: AxisScaleGizmo;
  102782. /**
  102783. * Internal gizmo used for interactions on the z axis
  102784. */
  102785. zGizmo: AxisScaleGizmo;
  102786. /**
  102787. * Internal gizmo used to scale all axis equally
  102788. */
  102789. uniformScaleGizmo: AxisScaleGizmo;
  102790. /** Fires an event when any of it's sub gizmos are dragged */
  102791. onDragStartObservable: Observable<{}>;
  102792. /** Fires an event when any of it's sub gizmos are released from dragging */
  102793. onDragEndObservable: Observable<{}>;
  102794. attachedMesh: Nullable<AbstractMesh>;
  102795. /**
  102796. * Creates a ScaleGizmo
  102797. * @param gizmoLayer The utility layer the gizmo will be added to
  102798. */
  102799. constructor(gizmoLayer?: UtilityLayerRenderer);
  102800. updateGizmoRotationToMatchAttachedMesh: boolean;
  102801. /**
  102802. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102803. */
  102804. snapDistance: number;
  102805. /**
  102806. * Ratio for the scale of the gizmo (Default: 1)
  102807. */
  102808. scaleRatio: number;
  102809. /**
  102810. * Disposes of the gizmo
  102811. */
  102812. dispose(): void;
  102813. }
  102814. }
  102815. declare module BABYLON {
  102816. /**
  102817. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102818. */
  102819. export class GizmoManager implements IDisposable {
  102820. private scene;
  102821. /**
  102822. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102823. */
  102824. gizmos: {
  102825. positionGizmo: Nullable<PositionGizmo>;
  102826. rotationGizmo: Nullable<RotationGizmo>;
  102827. scaleGizmo: Nullable<ScaleGizmo>;
  102828. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102829. };
  102830. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102831. clearGizmoOnEmptyPointerEvent: boolean;
  102832. /** Fires an event when the manager is attached to a mesh */
  102833. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102834. private _gizmosEnabled;
  102835. private _pointerObserver;
  102836. private _attachedMesh;
  102837. private _boundingBoxColor;
  102838. private _defaultUtilityLayer;
  102839. private _defaultKeepDepthUtilityLayer;
  102840. /**
  102841. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102842. */
  102843. boundingBoxDragBehavior: SixDofDragBehavior;
  102844. /**
  102845. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102846. */
  102847. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102848. /**
  102849. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102850. */
  102851. usePointerToAttachGizmos: boolean;
  102852. /**
  102853. * Instatiates a gizmo manager
  102854. * @param scene the scene to overlay the gizmos on top of
  102855. */
  102856. constructor(scene: Scene);
  102857. /**
  102858. * Attaches a set of gizmos to the specified mesh
  102859. * @param mesh The mesh the gizmo's should be attached to
  102860. */
  102861. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102862. /**
  102863. * If the position gizmo is enabled
  102864. */
  102865. positionGizmoEnabled: boolean;
  102866. /**
  102867. * If the rotation gizmo is enabled
  102868. */
  102869. rotationGizmoEnabled: boolean;
  102870. /**
  102871. * If the scale gizmo is enabled
  102872. */
  102873. scaleGizmoEnabled: boolean;
  102874. /**
  102875. * If the boundingBox gizmo is enabled
  102876. */
  102877. boundingBoxGizmoEnabled: boolean;
  102878. /**
  102879. * Disposes of the gizmo manager
  102880. */
  102881. dispose(): void;
  102882. }
  102883. }
  102884. declare module BABYLON {
  102885. /**
  102886. * A directional light is defined by a direction (what a surprise!).
  102887. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102888. * 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.
  102889. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102890. */
  102891. export class DirectionalLight extends ShadowLight {
  102892. private _shadowFrustumSize;
  102893. /**
  102894. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102895. */
  102896. /**
  102897. * Specifies a fix frustum size for the shadow generation.
  102898. */
  102899. shadowFrustumSize: number;
  102900. private _shadowOrthoScale;
  102901. /**
  102902. * Gets the shadow projection scale against the optimal computed one.
  102903. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102904. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102905. */
  102906. /**
  102907. * Sets the shadow projection scale against the optimal computed one.
  102908. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102909. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102910. */
  102911. shadowOrthoScale: number;
  102912. /**
  102913. * Automatically compute the projection matrix to best fit (including all the casters)
  102914. * on each frame.
  102915. */
  102916. autoUpdateExtends: boolean;
  102917. private _orthoLeft;
  102918. private _orthoRight;
  102919. private _orthoTop;
  102920. private _orthoBottom;
  102921. /**
  102922. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102923. * The directional light is emitted from everywhere in the given direction.
  102924. * It can cast shadows.
  102925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102926. * @param name The friendly name of the light
  102927. * @param direction The direction of the light
  102928. * @param scene The scene the light belongs to
  102929. */
  102930. constructor(name: string, direction: Vector3, scene: Scene);
  102931. /**
  102932. * Returns the string "DirectionalLight".
  102933. * @return The class name
  102934. */
  102935. getClassName(): string;
  102936. /**
  102937. * Returns the integer 1.
  102938. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102939. */
  102940. getTypeID(): number;
  102941. /**
  102942. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102943. * Returns the DirectionalLight Shadow projection matrix.
  102944. */
  102945. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102946. /**
  102947. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102948. * Returns the DirectionalLight Shadow projection matrix.
  102949. */
  102950. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102951. /**
  102952. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102953. * Returns the DirectionalLight Shadow projection matrix.
  102954. */
  102955. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102956. protected _buildUniformLayout(): void;
  102957. /**
  102958. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102959. * @param effect The effect to update
  102960. * @param lightIndex The index of the light in the effect to update
  102961. * @returns The directional light
  102962. */
  102963. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102964. /**
  102965. * Gets the minZ used for shadow according to both the scene and the light.
  102966. *
  102967. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102968. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102969. * @param activeCamera The camera we are returning the min for
  102970. * @returns the depth min z
  102971. */
  102972. getDepthMinZ(activeCamera: Camera): number;
  102973. /**
  102974. * Gets the maxZ used for shadow according to both the scene and the light.
  102975. *
  102976. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102977. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102978. * @param activeCamera The camera we are returning the max for
  102979. * @returns the depth max z
  102980. */
  102981. getDepthMaxZ(activeCamera: Camera): number;
  102982. /**
  102983. * Prepares the list of defines specific to the light type.
  102984. * @param defines the list of defines
  102985. * @param lightIndex defines the index of the light for the effect
  102986. */
  102987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102988. }
  102989. }
  102990. declare module BABYLON {
  102991. /**
  102992. * Class containing static functions to help procedurally build meshes
  102993. */
  102994. export class HemisphereBuilder {
  102995. /**
  102996. * Creates a hemisphere mesh
  102997. * @param name defines the name of the mesh
  102998. * @param options defines the options used to create the mesh
  102999. * @param scene defines the hosting scene
  103000. * @returns the hemisphere mesh
  103001. */
  103002. static CreateHemisphere(name: string, options: {
  103003. segments?: number;
  103004. diameter?: number;
  103005. sideOrientation?: number;
  103006. }, scene: any): Mesh;
  103007. }
  103008. }
  103009. declare module BABYLON {
  103010. /**
  103011. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103012. * These values define a cone of light starting from the position, emitting toward the direction.
  103013. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103014. * and the exponent defines the speed of the decay of the light with distance (reach).
  103015. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103016. */
  103017. export class SpotLight extends ShadowLight {
  103018. private _angle;
  103019. private _innerAngle;
  103020. private _cosHalfAngle;
  103021. private _lightAngleScale;
  103022. private _lightAngleOffset;
  103023. /**
  103024. * Gets the cone angle of the spot light in Radians.
  103025. */
  103026. /**
  103027. * Sets the cone angle of the spot light in Radians.
  103028. */
  103029. angle: number;
  103030. /**
  103031. * Only used in gltf falloff mode, this defines the angle where
  103032. * the directional falloff will start before cutting at angle which could be seen
  103033. * as outer angle.
  103034. */
  103035. /**
  103036. * Only used in gltf falloff mode, this defines the angle where
  103037. * the directional falloff will start before cutting at angle which could be seen
  103038. * as outer angle.
  103039. */
  103040. innerAngle: number;
  103041. private _shadowAngleScale;
  103042. /**
  103043. * Allows scaling the angle of the light for shadow generation only.
  103044. */
  103045. /**
  103046. * Allows scaling the angle of the light for shadow generation only.
  103047. */
  103048. shadowAngleScale: number;
  103049. /**
  103050. * The light decay speed with the distance from the emission spot.
  103051. */
  103052. exponent: number;
  103053. private _projectionTextureMatrix;
  103054. /**
  103055. * Allows reading the projecton texture
  103056. */
  103057. readonly projectionTextureMatrix: Matrix;
  103058. protected _projectionTextureLightNear: number;
  103059. /**
  103060. * Gets the near clip of the Spotlight for texture projection.
  103061. */
  103062. /**
  103063. * Sets the near clip of the Spotlight for texture projection.
  103064. */
  103065. projectionTextureLightNear: number;
  103066. protected _projectionTextureLightFar: number;
  103067. /**
  103068. * Gets the far clip of the Spotlight for texture projection.
  103069. */
  103070. /**
  103071. * Sets the far clip of the Spotlight for texture projection.
  103072. */
  103073. projectionTextureLightFar: number;
  103074. protected _projectionTextureUpDirection: Vector3;
  103075. /**
  103076. * Gets the Up vector of the Spotlight for texture projection.
  103077. */
  103078. /**
  103079. * Sets the Up vector of the Spotlight for texture projection.
  103080. */
  103081. projectionTextureUpDirection: Vector3;
  103082. private _projectionTexture;
  103083. /**
  103084. * Gets the projection texture of the light.
  103085. */
  103086. /**
  103087. * Sets the projection texture of the light.
  103088. */
  103089. projectionTexture: Nullable<BaseTexture>;
  103090. private _projectionTextureViewLightDirty;
  103091. private _projectionTextureProjectionLightDirty;
  103092. private _projectionTextureDirty;
  103093. private _projectionTextureViewTargetVector;
  103094. private _projectionTextureViewLightMatrix;
  103095. private _projectionTextureProjectionLightMatrix;
  103096. private _projectionTextureScalingMatrix;
  103097. /**
  103098. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  103099. * It can cast shadows.
  103100. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103101. * @param name The light friendly name
  103102. * @param position The position of the spot light in the scene
  103103. * @param direction The direction of the light in the scene
  103104. * @param angle The cone angle of the light in Radians
  103105. * @param exponent The light decay speed with the distance from the emission spot
  103106. * @param scene The scene the lights belongs to
  103107. */
  103108. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  103109. /**
  103110. * Returns the string "SpotLight".
  103111. * @returns the class name
  103112. */
  103113. getClassName(): string;
  103114. /**
  103115. * Returns the integer 2.
  103116. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103117. */
  103118. getTypeID(): number;
  103119. /**
  103120. * Overrides the direction setter to recompute the projection texture view light Matrix.
  103121. */
  103122. protected _setDirection(value: Vector3): void;
  103123. /**
  103124. * Overrides the position setter to recompute the projection texture view light Matrix.
  103125. */
  103126. protected _setPosition(value: Vector3): void;
  103127. /**
  103128. * 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.
  103129. * Returns the SpotLight.
  103130. */
  103131. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103132. protected _computeProjectionTextureViewLightMatrix(): void;
  103133. protected _computeProjectionTextureProjectionLightMatrix(): void;
  103134. /**
  103135. * Main function for light texture projection matrix computing.
  103136. */
  103137. protected _computeProjectionTextureMatrix(): void;
  103138. protected _buildUniformLayout(): void;
  103139. private _computeAngleValues;
  103140. /**
  103141. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  103142. * @param effect The effect to update
  103143. * @param lightIndex The index of the light in the effect to update
  103144. * @returns The spot light
  103145. */
  103146. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  103147. /**
  103148. * Disposes the light and the associated resources.
  103149. */
  103150. dispose(): void;
  103151. /**
  103152. * Prepares the list of defines specific to the light type.
  103153. * @param defines the list of defines
  103154. * @param lightIndex defines the index of the light for the effect
  103155. */
  103156. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103157. }
  103158. }
  103159. declare module BABYLON {
  103160. /**
  103161. * Gizmo that enables viewing a light
  103162. */
  103163. export class LightGizmo extends Gizmo {
  103164. private _lightMesh;
  103165. private _material;
  103166. /**
  103167. * Creates a LightGizmo
  103168. * @param gizmoLayer The utility layer the gizmo will be added to
  103169. */
  103170. constructor(gizmoLayer?: UtilityLayerRenderer);
  103171. private _light;
  103172. /**
  103173. * The light that the gizmo is attached to
  103174. */
  103175. light: Nullable<Light>;
  103176. /**
  103177. * @hidden
  103178. * Updates the gizmo to match the attached mesh's position/rotation
  103179. */
  103180. protected _update(): void;
  103181. private static _Scale;
  103182. /**
  103183. * Creates the lines for a light mesh
  103184. */
  103185. private static _createLightLines;
  103186. private static _CreateHemisphericLightMesh;
  103187. private static _CreatePointLightMesh;
  103188. private static _CreateSpotLightMesh;
  103189. private static _CreateDirectionalLightMesh;
  103190. }
  103191. }
  103192. declare module BABYLON {
  103193. /** @hidden */
  103194. export var backgroundFragmentDeclaration: {
  103195. name: string;
  103196. shader: string;
  103197. };
  103198. }
  103199. declare module BABYLON {
  103200. /** @hidden */
  103201. export var backgroundUboDeclaration: {
  103202. name: string;
  103203. shader: string;
  103204. };
  103205. }
  103206. declare module BABYLON {
  103207. /** @hidden */
  103208. export var backgroundPixelShader: {
  103209. name: string;
  103210. shader: string;
  103211. };
  103212. }
  103213. declare module BABYLON {
  103214. /** @hidden */
  103215. export var backgroundVertexDeclaration: {
  103216. name: string;
  103217. shader: string;
  103218. };
  103219. }
  103220. declare module BABYLON {
  103221. /** @hidden */
  103222. export var backgroundVertexShader: {
  103223. name: string;
  103224. shader: string;
  103225. };
  103226. }
  103227. declare module BABYLON {
  103228. /**
  103229. * Background material used to create an efficient environement around your scene.
  103230. */
  103231. export class BackgroundMaterial extends PushMaterial {
  103232. /**
  103233. * Standard reflectance value at parallel view angle.
  103234. */
  103235. static StandardReflectance0: number;
  103236. /**
  103237. * Standard reflectance value at grazing angle.
  103238. */
  103239. static StandardReflectance90: number;
  103240. protected _primaryColor: Color3;
  103241. /**
  103242. * Key light Color (multiply against the environement texture)
  103243. */
  103244. primaryColor: Color3;
  103245. protected __perceptualColor: Nullable<Color3>;
  103246. /**
  103247. * Experimental Internal Use Only.
  103248. *
  103249. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  103250. * This acts as a helper to set the primary color to a more "human friendly" value.
  103251. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  103252. * output color as close as possible from the chosen value.
  103253. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  103254. * part of lighting setup.)
  103255. */
  103256. _perceptualColor: Nullable<Color3>;
  103257. protected _primaryColorShadowLevel: float;
  103258. /**
  103259. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  103260. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  103261. */
  103262. primaryColorShadowLevel: float;
  103263. protected _primaryColorHighlightLevel: float;
  103264. /**
  103265. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  103266. * The primary color is used at the level chosen to define what the white area would look.
  103267. */
  103268. primaryColorHighlightLevel: float;
  103269. protected _reflectionTexture: Nullable<BaseTexture>;
  103270. /**
  103271. * Reflection Texture used in the material.
  103272. * Should be author in a specific way for the best result (refer to the documentation).
  103273. */
  103274. reflectionTexture: Nullable<BaseTexture>;
  103275. protected _reflectionBlur: float;
  103276. /**
  103277. * Reflection Texture level of blur.
  103278. *
  103279. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  103280. * texture twice.
  103281. */
  103282. reflectionBlur: float;
  103283. protected _diffuseTexture: Nullable<BaseTexture>;
  103284. /**
  103285. * Diffuse Texture used in the material.
  103286. * Should be author in a specific way for the best result (refer to the documentation).
  103287. */
  103288. diffuseTexture: Nullable<BaseTexture>;
  103289. protected _shadowLights: Nullable<IShadowLight[]>;
  103290. /**
  103291. * Specify the list of lights casting shadow on the material.
  103292. * All scene shadow lights will be included if null.
  103293. */
  103294. shadowLights: Nullable<IShadowLight[]>;
  103295. protected _shadowLevel: float;
  103296. /**
  103297. * Helps adjusting the shadow to a softer level if required.
  103298. * 0 means black shadows and 1 means no shadows.
  103299. */
  103300. shadowLevel: float;
  103301. protected _sceneCenter: Vector3;
  103302. /**
  103303. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  103304. * It is usually zero but might be interesting to modify according to your setup.
  103305. */
  103306. sceneCenter: Vector3;
  103307. protected _opacityFresnel: boolean;
  103308. /**
  103309. * This helps specifying that the material is falling off to the sky box at grazing angle.
  103310. * This helps ensuring a nice transition when the camera goes under the ground.
  103311. */
  103312. opacityFresnel: boolean;
  103313. protected _reflectionFresnel: boolean;
  103314. /**
  103315. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  103316. * This helps adding a mirror texture on the ground.
  103317. */
  103318. reflectionFresnel: boolean;
  103319. protected _reflectionFalloffDistance: number;
  103320. /**
  103321. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  103322. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  103323. */
  103324. reflectionFalloffDistance: number;
  103325. protected _reflectionAmount: number;
  103326. /**
  103327. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  103328. */
  103329. reflectionAmount: number;
  103330. protected _reflectionReflectance0: number;
  103331. /**
  103332. * This specifies the weight of the reflection at grazing angle.
  103333. */
  103334. reflectionReflectance0: number;
  103335. protected _reflectionReflectance90: number;
  103336. /**
  103337. * This specifies the weight of the reflection at a perpendicular point of view.
  103338. */
  103339. reflectionReflectance90: number;
  103340. /**
  103341. * Sets the reflection reflectance fresnel values according to the default standard
  103342. * empirically know to work well :-)
  103343. */
  103344. reflectionStandardFresnelWeight: number;
  103345. protected _useRGBColor: boolean;
  103346. /**
  103347. * Helps to directly use the maps channels instead of their level.
  103348. */
  103349. useRGBColor: boolean;
  103350. protected _enableNoise: boolean;
  103351. /**
  103352. * This helps reducing the banding effect that could occur on the background.
  103353. */
  103354. enableNoise: boolean;
  103355. /**
  103356. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103357. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  103358. * Recommended to be keep at 1.0 except for special cases.
  103359. */
  103360. fovMultiplier: number;
  103361. private _fovMultiplier;
  103362. /**
  103363. * Enable the FOV adjustment feature controlled by fovMultiplier.
  103364. */
  103365. useEquirectangularFOV: boolean;
  103366. private _maxSimultaneousLights;
  103367. /**
  103368. * Number of Simultaneous lights allowed on the material.
  103369. */
  103370. maxSimultaneousLights: int;
  103371. /**
  103372. * Default configuration related to image processing available in the Background Material.
  103373. */
  103374. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103375. /**
  103376. * Keep track of the image processing observer to allow dispose and replace.
  103377. */
  103378. private _imageProcessingObserver;
  103379. /**
  103380. * Attaches a new image processing configuration to the PBR Material.
  103381. * @param configuration (if null the scene configuration will be use)
  103382. */
  103383. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103384. /**
  103385. * Gets the image processing configuration used either in this material.
  103386. */
  103387. /**
  103388. * Sets the Default image processing configuration used either in the this material.
  103389. *
  103390. * If sets to null, the scene one is in use.
  103391. */
  103392. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  103393. /**
  103394. * Gets wether the color curves effect is enabled.
  103395. */
  103396. /**
  103397. * Sets wether the color curves effect is enabled.
  103398. */
  103399. cameraColorCurvesEnabled: boolean;
  103400. /**
  103401. * Gets wether the color grading effect is enabled.
  103402. */
  103403. /**
  103404. * Gets wether the color grading effect is enabled.
  103405. */
  103406. cameraColorGradingEnabled: boolean;
  103407. /**
  103408. * Gets wether tonemapping is enabled or not.
  103409. */
  103410. /**
  103411. * Sets wether tonemapping is enabled or not
  103412. */
  103413. cameraToneMappingEnabled: boolean;
  103414. /**
  103415. * The camera exposure used on this material.
  103416. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103417. * This corresponds to a photographic exposure.
  103418. */
  103419. /**
  103420. * The camera exposure used on this material.
  103421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103422. * This corresponds to a photographic exposure.
  103423. */
  103424. cameraExposure: float;
  103425. /**
  103426. * Gets The camera contrast used on this material.
  103427. */
  103428. /**
  103429. * Sets The camera contrast used on this material.
  103430. */
  103431. cameraContrast: float;
  103432. /**
  103433. * Gets the Color Grading 2D Lookup Texture.
  103434. */
  103435. /**
  103436. * Sets the Color Grading 2D Lookup Texture.
  103437. */
  103438. cameraColorGradingTexture: Nullable<BaseTexture>;
  103439. /**
  103440. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103441. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103442. * 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;
  103443. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103444. */
  103445. /**
  103446. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103447. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103448. * 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;
  103449. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103450. */
  103451. cameraColorCurves: Nullable<ColorCurves>;
  103452. /**
  103453. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  103454. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  103455. */
  103456. switchToBGR: boolean;
  103457. private _renderTargets;
  103458. private _reflectionControls;
  103459. private _white;
  103460. private _primaryShadowColor;
  103461. private _primaryHighlightColor;
  103462. /**
  103463. * Instantiates a Background Material in the given scene
  103464. * @param name The friendly name of the material
  103465. * @param scene The scene to add the material to
  103466. */
  103467. constructor(name: string, scene: Scene);
  103468. /**
  103469. * Gets a boolean indicating that current material needs to register RTT
  103470. */
  103471. readonly hasRenderTargetTextures: boolean;
  103472. /**
  103473. * The entire material has been created in order to prevent overdraw.
  103474. * @returns false
  103475. */
  103476. needAlphaTesting(): boolean;
  103477. /**
  103478. * The entire material has been created in order to prevent overdraw.
  103479. * @returns true if blending is enable
  103480. */
  103481. needAlphaBlending(): boolean;
  103482. /**
  103483. * Checks wether the material is ready to be rendered for a given mesh.
  103484. * @param mesh The mesh to render
  103485. * @param subMesh The submesh to check against
  103486. * @param useInstances Specify wether or not the material is used with instances
  103487. * @returns true if all the dependencies are ready (Textures, Effects...)
  103488. */
  103489. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103490. /**
  103491. * Compute the primary color according to the chosen perceptual color.
  103492. */
  103493. private _computePrimaryColorFromPerceptualColor;
  103494. /**
  103495. * Compute the highlights and shadow colors according to their chosen levels.
  103496. */
  103497. private _computePrimaryColors;
  103498. /**
  103499. * Build the uniform buffer used in the material.
  103500. */
  103501. buildUniformLayout(): void;
  103502. /**
  103503. * Unbind the material.
  103504. */
  103505. unbind(): void;
  103506. /**
  103507. * Bind only the world matrix to the material.
  103508. * @param world The world matrix to bind.
  103509. */
  103510. bindOnlyWorldMatrix(world: Matrix): void;
  103511. /**
  103512. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  103513. * @param world The world matrix to bind.
  103514. * @param subMesh The submesh to bind for.
  103515. */
  103516. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103517. /**
  103518. * Dispose the material.
  103519. * @param forceDisposeEffect Force disposal of the associated effect.
  103520. * @param forceDisposeTextures Force disposal of the associated textures.
  103521. */
  103522. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103523. /**
  103524. * Clones the material.
  103525. * @param name The cloned name.
  103526. * @returns The cloned material.
  103527. */
  103528. clone(name: string): BackgroundMaterial;
  103529. /**
  103530. * Serializes the current material to its JSON representation.
  103531. * @returns The JSON representation.
  103532. */
  103533. serialize(): any;
  103534. /**
  103535. * Gets the class name of the material
  103536. * @returns "BackgroundMaterial"
  103537. */
  103538. getClassName(): string;
  103539. /**
  103540. * Parse a JSON input to create back a background material.
  103541. * @param source The JSON data to parse
  103542. * @param scene The scene to create the parsed material in
  103543. * @param rootUrl The root url of the assets the material depends upon
  103544. * @returns the instantiated BackgroundMaterial.
  103545. */
  103546. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  103547. }
  103548. }
  103549. declare module BABYLON {
  103550. /**
  103551. * Represents the different options available during the creation of
  103552. * a Environment helper.
  103553. *
  103554. * This can control the default ground, skybox and image processing setup of your scene.
  103555. */
  103556. export interface IEnvironmentHelperOptions {
  103557. /**
  103558. * Specifies wether or not to create a ground.
  103559. * True by default.
  103560. */
  103561. createGround: boolean;
  103562. /**
  103563. * Specifies the ground size.
  103564. * 15 by default.
  103565. */
  103566. groundSize: number;
  103567. /**
  103568. * The texture used on the ground for the main color.
  103569. * Comes from the BabylonJS CDN by default.
  103570. *
  103571. * Remarks: Can be either a texture or a url.
  103572. */
  103573. groundTexture: string | BaseTexture;
  103574. /**
  103575. * The color mixed in the ground texture by default.
  103576. * BabylonJS clearColor by default.
  103577. */
  103578. groundColor: Color3;
  103579. /**
  103580. * Specifies the ground opacity.
  103581. * 1 by default.
  103582. */
  103583. groundOpacity: number;
  103584. /**
  103585. * Enables the ground to receive shadows.
  103586. * True by default.
  103587. */
  103588. enableGroundShadow: boolean;
  103589. /**
  103590. * Helps preventing the shadow to be fully black on the ground.
  103591. * 0.5 by default.
  103592. */
  103593. groundShadowLevel: number;
  103594. /**
  103595. * Creates a mirror texture attach to the ground.
  103596. * false by default.
  103597. */
  103598. enableGroundMirror: boolean;
  103599. /**
  103600. * Specifies the ground mirror size ratio.
  103601. * 0.3 by default as the default kernel is 64.
  103602. */
  103603. groundMirrorSizeRatio: number;
  103604. /**
  103605. * Specifies the ground mirror blur kernel size.
  103606. * 64 by default.
  103607. */
  103608. groundMirrorBlurKernel: number;
  103609. /**
  103610. * Specifies the ground mirror visibility amount.
  103611. * 1 by default
  103612. */
  103613. groundMirrorAmount: number;
  103614. /**
  103615. * Specifies the ground mirror reflectance weight.
  103616. * This uses the standard weight of the background material to setup the fresnel effect
  103617. * of the mirror.
  103618. * 1 by default.
  103619. */
  103620. groundMirrorFresnelWeight: number;
  103621. /**
  103622. * Specifies the ground mirror Falloff distance.
  103623. * This can helps reducing the size of the reflection.
  103624. * 0 by Default.
  103625. */
  103626. groundMirrorFallOffDistance: number;
  103627. /**
  103628. * Specifies the ground mirror texture type.
  103629. * Unsigned Int by Default.
  103630. */
  103631. groundMirrorTextureType: number;
  103632. /**
  103633. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  103634. * the shown objects.
  103635. */
  103636. groundYBias: number;
  103637. /**
  103638. * Specifies wether or not to create a skybox.
  103639. * True by default.
  103640. */
  103641. createSkybox: boolean;
  103642. /**
  103643. * Specifies the skybox size.
  103644. * 20 by default.
  103645. */
  103646. skyboxSize: number;
  103647. /**
  103648. * The texture used on the skybox for the main color.
  103649. * Comes from the BabylonJS CDN by default.
  103650. *
  103651. * Remarks: Can be either a texture or a url.
  103652. */
  103653. skyboxTexture: string | BaseTexture;
  103654. /**
  103655. * The color mixed in the skybox texture by default.
  103656. * BabylonJS clearColor by default.
  103657. */
  103658. skyboxColor: Color3;
  103659. /**
  103660. * The background rotation around the Y axis of the scene.
  103661. * This helps aligning the key lights of your scene with the background.
  103662. * 0 by default.
  103663. */
  103664. backgroundYRotation: number;
  103665. /**
  103666. * Compute automatically the size of the elements to best fit with the scene.
  103667. */
  103668. sizeAuto: boolean;
  103669. /**
  103670. * Default position of the rootMesh if autoSize is not true.
  103671. */
  103672. rootPosition: Vector3;
  103673. /**
  103674. * Sets up the image processing in the scene.
  103675. * true by default.
  103676. */
  103677. setupImageProcessing: boolean;
  103678. /**
  103679. * The texture used as your environment texture in the scene.
  103680. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103681. *
  103682. * Remarks: Can be either a texture or a url.
  103683. */
  103684. environmentTexture: string | BaseTexture;
  103685. /**
  103686. * The value of the exposure to apply to the scene.
  103687. * 0.6 by default if setupImageProcessing is true.
  103688. */
  103689. cameraExposure: number;
  103690. /**
  103691. * The value of the contrast to apply to the scene.
  103692. * 1.6 by default if setupImageProcessing is true.
  103693. */
  103694. cameraContrast: number;
  103695. /**
  103696. * Specifies wether or not tonemapping should be enabled in the scene.
  103697. * true by default if setupImageProcessing is true.
  103698. */
  103699. toneMappingEnabled: boolean;
  103700. }
  103701. /**
  103702. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103703. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103704. * It also helps with the default setup of your imageProcessing configuration.
  103705. */
  103706. export class EnvironmentHelper {
  103707. /**
  103708. * Default ground texture URL.
  103709. */
  103710. private static _groundTextureCDNUrl;
  103711. /**
  103712. * Default skybox texture URL.
  103713. */
  103714. private static _skyboxTextureCDNUrl;
  103715. /**
  103716. * Default environment texture URL.
  103717. */
  103718. private static _environmentTextureCDNUrl;
  103719. /**
  103720. * Creates the default options for the helper.
  103721. */
  103722. private static _getDefaultOptions;
  103723. private _rootMesh;
  103724. /**
  103725. * Gets the root mesh created by the helper.
  103726. */
  103727. readonly rootMesh: Mesh;
  103728. private _skybox;
  103729. /**
  103730. * Gets the skybox created by the helper.
  103731. */
  103732. readonly skybox: Nullable<Mesh>;
  103733. private _skyboxTexture;
  103734. /**
  103735. * Gets the skybox texture created by the helper.
  103736. */
  103737. readonly skyboxTexture: Nullable<BaseTexture>;
  103738. private _skyboxMaterial;
  103739. /**
  103740. * Gets the skybox material created by the helper.
  103741. */
  103742. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103743. private _ground;
  103744. /**
  103745. * Gets the ground mesh created by the helper.
  103746. */
  103747. readonly ground: Nullable<Mesh>;
  103748. private _groundTexture;
  103749. /**
  103750. * Gets the ground texture created by the helper.
  103751. */
  103752. readonly groundTexture: Nullable<BaseTexture>;
  103753. private _groundMirror;
  103754. /**
  103755. * Gets the ground mirror created by the helper.
  103756. */
  103757. readonly groundMirror: Nullable<MirrorTexture>;
  103758. /**
  103759. * Gets the ground mirror render list to helps pushing the meshes
  103760. * you wish in the ground reflection.
  103761. */
  103762. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103763. private _groundMaterial;
  103764. /**
  103765. * Gets the ground material created by the helper.
  103766. */
  103767. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103768. /**
  103769. * Stores the creation options.
  103770. */
  103771. private readonly _scene;
  103772. private _options;
  103773. /**
  103774. * This observable will be notified with any error during the creation of the environment,
  103775. * mainly texture creation errors.
  103776. */
  103777. onErrorObservable: Observable<{
  103778. message?: string;
  103779. exception?: any;
  103780. }>;
  103781. /**
  103782. * constructor
  103783. * @param options Defines the options we want to customize the helper
  103784. * @param scene The scene to add the material to
  103785. */
  103786. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103787. /**
  103788. * Updates the background according to the new options
  103789. * @param options
  103790. */
  103791. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103792. /**
  103793. * Sets the primary color of all the available elements.
  103794. * @param color the main color to affect to the ground and the background
  103795. */
  103796. setMainColor(color: Color3): void;
  103797. /**
  103798. * Setup the image processing according to the specified options.
  103799. */
  103800. private _setupImageProcessing;
  103801. /**
  103802. * Setup the environment texture according to the specified options.
  103803. */
  103804. private _setupEnvironmentTexture;
  103805. /**
  103806. * Setup the background according to the specified options.
  103807. */
  103808. private _setupBackground;
  103809. /**
  103810. * Get the scene sizes according to the setup.
  103811. */
  103812. private _getSceneSize;
  103813. /**
  103814. * Setup the ground according to the specified options.
  103815. */
  103816. private _setupGround;
  103817. /**
  103818. * Setup the ground material according to the specified options.
  103819. */
  103820. private _setupGroundMaterial;
  103821. /**
  103822. * Setup the ground diffuse texture according to the specified options.
  103823. */
  103824. private _setupGroundDiffuseTexture;
  103825. /**
  103826. * Setup the ground mirror texture according to the specified options.
  103827. */
  103828. private _setupGroundMirrorTexture;
  103829. /**
  103830. * Setup the ground to receive the mirror texture.
  103831. */
  103832. private _setupMirrorInGroundMaterial;
  103833. /**
  103834. * Setup the skybox according to the specified options.
  103835. */
  103836. private _setupSkybox;
  103837. /**
  103838. * Setup the skybox material according to the specified options.
  103839. */
  103840. private _setupSkyboxMaterial;
  103841. /**
  103842. * Setup the skybox reflection texture according to the specified options.
  103843. */
  103844. private _setupSkyboxReflectionTexture;
  103845. private _errorHandler;
  103846. /**
  103847. * Dispose all the elements created by the Helper.
  103848. */
  103849. dispose(): void;
  103850. }
  103851. }
  103852. declare module BABYLON {
  103853. /**
  103854. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103855. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103856. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103857. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103858. */
  103859. export class PhotoDome extends TransformNode {
  103860. private _useDirectMapping;
  103861. /**
  103862. * The texture being displayed on the sphere
  103863. */
  103864. protected _photoTexture: Texture;
  103865. /**
  103866. * Gets or sets the texture being displayed on the sphere
  103867. */
  103868. photoTexture: Texture;
  103869. /**
  103870. * Observable raised when an error occured while loading the 360 image
  103871. */
  103872. onLoadErrorObservable: Observable<string>;
  103873. /**
  103874. * The skybox material
  103875. */
  103876. protected _material: BackgroundMaterial;
  103877. /**
  103878. * The surface used for the skybox
  103879. */
  103880. protected _mesh: Mesh;
  103881. /**
  103882. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103883. * Also see the options.resolution property.
  103884. */
  103885. fovMultiplier: number;
  103886. /**
  103887. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103888. * @param name Element's name, child elements will append suffixes for their own names.
  103889. * @param urlsOfPhoto defines the url of the photo to display
  103890. * @param options defines an object containing optional or exposed sub element properties
  103891. * @param onError defines a callback called when an error occured while loading the texture
  103892. */
  103893. constructor(name: string, urlOfPhoto: string, options: {
  103894. resolution?: number;
  103895. size?: number;
  103896. useDirectMapping?: boolean;
  103897. faceForward?: boolean;
  103898. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103899. /**
  103900. * Releases resources associated with this node.
  103901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103903. */
  103904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103905. }
  103906. }
  103907. declare module BABYLON {
  103908. /** @hidden */
  103909. export var rgbdDecodePixelShader: {
  103910. name: string;
  103911. shader: string;
  103912. };
  103913. }
  103914. declare module BABYLON {
  103915. /**
  103916. * Class used to host texture specific utilities
  103917. */
  103918. export class BRDFTextureTools {
  103919. /**
  103920. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103921. * @param texture the texture to expand.
  103922. */
  103923. private static _ExpandDefaultBRDFTexture;
  103924. /**
  103925. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103926. * @param scene defines the hosting scene
  103927. * @returns the environment BRDF texture
  103928. */
  103929. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103930. private static _environmentBRDFBase64Texture;
  103931. }
  103932. }
  103933. declare module BABYLON {
  103934. /**
  103935. * @hidden
  103936. */
  103937. export interface IMaterialClearCoatDefines {
  103938. CLEARCOAT: boolean;
  103939. CLEARCOAT_DEFAULTIOR: boolean;
  103940. CLEARCOAT_TEXTURE: boolean;
  103941. CLEARCOAT_TEXTUREDIRECTUV: number;
  103942. CLEARCOAT_BUMP: boolean;
  103943. CLEARCOAT_BUMPDIRECTUV: number;
  103944. CLEARCOAT_TINT: boolean;
  103945. CLEARCOAT_TINT_TEXTURE: boolean;
  103946. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103947. /** @hidden */
  103948. _areTexturesDirty: boolean;
  103949. }
  103950. /**
  103951. * Define the code related to the clear coat parameters of the pbr material.
  103952. */
  103953. export class PBRClearCoatConfiguration {
  103954. /**
  103955. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103956. * The default fits with a polyurethane material.
  103957. */
  103958. private static readonly _DefaultIndiceOfRefraction;
  103959. private _isEnabled;
  103960. /**
  103961. * Defines if the clear coat is enabled in the material.
  103962. */
  103963. isEnabled: boolean;
  103964. /**
  103965. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103966. */
  103967. intensity: number;
  103968. /**
  103969. * Defines the clear coat layer roughness.
  103970. */
  103971. roughness: number;
  103972. private _indiceOfRefraction;
  103973. /**
  103974. * Defines the indice of refraction of the clear coat.
  103975. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103976. * The default fits with a polyurethane material.
  103977. * Changing the default value is more performance intensive.
  103978. */
  103979. indiceOfRefraction: number;
  103980. private _texture;
  103981. /**
  103982. * Stores the clear coat values in a texture.
  103983. */
  103984. texture: Nullable<BaseTexture>;
  103985. private _bumpTexture;
  103986. /**
  103987. * Define the clear coat specific bump texture.
  103988. */
  103989. bumpTexture: Nullable<BaseTexture>;
  103990. private _isTintEnabled;
  103991. /**
  103992. * Defines if the clear coat tint is enabled in the material.
  103993. */
  103994. isTintEnabled: boolean;
  103995. /**
  103996. * Defines the clear coat tint of the material.
  103997. * This is only use if tint is enabled
  103998. */
  103999. tintColor: Color3;
  104000. /**
  104001. * Defines the distance at which the tint color should be found in the
  104002. * clear coat media.
  104003. * This is only use if tint is enabled
  104004. */
  104005. tintColorAtDistance: number;
  104006. /**
  104007. * Defines the clear coat layer thickness.
  104008. * This is only use if tint is enabled
  104009. */
  104010. tintThickness: number;
  104011. private _tintTexture;
  104012. /**
  104013. * Stores the clear tint values in a texture.
  104014. * rgb is tint
  104015. * a is a thickness factor
  104016. */
  104017. tintTexture: Nullable<BaseTexture>;
  104018. /** @hidden */
  104019. private _internalMarkAllSubMeshesAsTexturesDirty;
  104020. /** @hidden */
  104021. _markAllSubMeshesAsTexturesDirty(): void;
  104022. /**
  104023. * Instantiate a new istance of clear coat configuration.
  104024. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104025. */
  104026. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104027. /**
  104028. * Gets wehter the submesh is ready to be used or not.
  104029. * @param defines the list of "defines" to update.
  104030. * @param scene defines the scene the material belongs to.
  104031. * @param engine defines the engine the material belongs to.
  104032. * @param disableBumpMap defines wether the material disables bump or not.
  104033. * @returns - boolean indicating that the submesh is ready or not.
  104034. */
  104035. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104036. /**
  104037. * Checks to see if a texture is used in the material.
  104038. * @param defines the list of "defines" to update.
  104039. * @param scene defines the scene to the material belongs to.
  104040. */
  104041. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104042. /**
  104043. * Binds the material data.
  104044. * @param uniformBuffer defines the Uniform buffer to fill in.
  104045. * @param scene defines the scene the material belongs to.
  104046. * @param engine defines the engine the material belongs to.
  104047. * @param disableBumpMap defines wether the material disables bump or not.
  104048. * @param isFrozen defines wether the material is frozen or not.
  104049. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104050. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104051. */
  104052. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  104053. /**
  104054. * Checks to see if a texture is used in the material.
  104055. * @param texture - Base texture to use.
  104056. * @returns - Boolean specifying if a texture is used in the material.
  104057. */
  104058. hasTexture(texture: BaseTexture): boolean;
  104059. /**
  104060. * Returns an array of the actively used textures.
  104061. * @param activeTextures Array of BaseTextures
  104062. */
  104063. getActiveTextures(activeTextures: BaseTexture[]): void;
  104064. /**
  104065. * Returns the animatable textures.
  104066. * @param animatables Array of animatable textures.
  104067. */
  104068. getAnimatables(animatables: IAnimatable[]): void;
  104069. /**
  104070. * Disposes the resources of the material.
  104071. * @param forceDisposeTextures - Forces the disposal of all textures.
  104072. */
  104073. dispose(forceDisposeTextures?: boolean): void;
  104074. /**
  104075. * Get the current class name of the texture useful for serialization or dynamic coding.
  104076. * @returns "PBRClearCoatConfiguration"
  104077. */
  104078. getClassName(): string;
  104079. /**
  104080. * Add fallbacks to the effect fallbacks list.
  104081. * @param defines defines the Base texture to use.
  104082. * @param fallbacks defines the current fallback list.
  104083. * @param currentRank defines the current fallback rank.
  104084. * @returns the new fallback rank.
  104085. */
  104086. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104087. /**
  104088. * Add the required uniforms to the current list.
  104089. * @param uniforms defines the current uniform list.
  104090. */
  104091. static AddUniforms(uniforms: string[]): void;
  104092. /**
  104093. * Add the required samplers to the current list.
  104094. * @param samplers defines the current sampler list.
  104095. */
  104096. static AddSamplers(samplers: string[]): void;
  104097. /**
  104098. * Add the required uniforms to the current buffer.
  104099. * @param uniformBuffer defines the current uniform buffer.
  104100. */
  104101. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104102. /**
  104103. * Makes a duplicate of the current configuration into another one.
  104104. * @param clearCoatConfiguration define the config where to copy the info
  104105. */
  104106. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104107. /**
  104108. * Serializes this clear coat configuration.
  104109. * @returns - An object with the serialized config.
  104110. */
  104111. serialize(): any;
  104112. /**
  104113. * Parses a Clear Coat Configuration from a serialized object.
  104114. * @param source - Serialized object.
  104115. */
  104116. parse(source: any): void;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /**
  104121. * @hidden
  104122. */
  104123. export interface IMaterialAnisotropicDefines {
  104124. ANISOTROPIC: boolean;
  104125. ANISOTROPIC_TEXTURE: boolean;
  104126. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104127. MAINUV1: boolean;
  104128. _areTexturesDirty: boolean;
  104129. _needUVs: boolean;
  104130. }
  104131. /**
  104132. * Define the code related to the anisotropic parameters of the pbr material.
  104133. */
  104134. export class PBRAnisotropicConfiguration {
  104135. private _isEnabled;
  104136. /**
  104137. * Defines if the anisotropy is enabled in the material.
  104138. */
  104139. isEnabled: boolean;
  104140. /**
  104141. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104142. */
  104143. intensity: number;
  104144. /**
  104145. * Defines if the effect is along the tangents, bitangents or in between.
  104146. * By default, the effect is "strectching" the highlights along the tangents.
  104147. */
  104148. direction: Vector2;
  104149. private _texture;
  104150. /**
  104151. * Stores the anisotropy values in a texture.
  104152. * rg is direction (like normal from -1 to 1)
  104153. * b is a intensity
  104154. */
  104155. texture: Nullable<BaseTexture>;
  104156. /** @hidden */
  104157. private _internalMarkAllSubMeshesAsTexturesDirty;
  104158. /** @hidden */
  104159. _markAllSubMeshesAsTexturesDirty(): void;
  104160. /**
  104161. * Instantiate a new istance of anisotropy configuration.
  104162. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104163. */
  104164. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104165. /**
  104166. * Specifies that the submesh is ready to be used.
  104167. * @param defines the list of "defines" to update.
  104168. * @param scene defines the scene the material belongs to.
  104169. * @returns - boolean indicating that the submesh is ready or not.
  104170. */
  104171. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104172. /**
  104173. * Checks to see if a texture is used in the material.
  104174. * @param defines the list of "defines" to update.
  104175. * @param mesh the mesh we are preparing the defines for.
  104176. * @param scene defines the scene the material belongs to.
  104177. */
  104178. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104179. /**
  104180. * Binds the material data.
  104181. * @param uniformBuffer defines the Uniform buffer to fill in.
  104182. * @param scene defines the scene the material belongs to.
  104183. * @param isFrozen defines wether the material is frozen or not.
  104184. */
  104185. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104186. /**
  104187. * Checks to see if a texture is used in the material.
  104188. * @param texture - Base texture to use.
  104189. * @returns - Boolean specifying if a texture is used in the material.
  104190. */
  104191. hasTexture(texture: BaseTexture): boolean;
  104192. /**
  104193. * Returns an array of the actively used textures.
  104194. * @param activeTextures Array of BaseTextures
  104195. */
  104196. getActiveTextures(activeTextures: BaseTexture[]): void;
  104197. /**
  104198. * Returns the animatable textures.
  104199. * @param animatables Array of animatable textures.
  104200. */
  104201. getAnimatables(animatables: IAnimatable[]): void;
  104202. /**
  104203. * Disposes the resources of the material.
  104204. * @param forceDisposeTextures - Forces the disposal of all textures.
  104205. */
  104206. dispose(forceDisposeTextures?: boolean): void;
  104207. /**
  104208. * Get the current class name of the texture useful for serialization or dynamic coding.
  104209. * @returns "PBRAnisotropicConfiguration"
  104210. */
  104211. getClassName(): string;
  104212. /**
  104213. * Add fallbacks to the effect fallbacks list.
  104214. * @param defines defines the Base texture to use.
  104215. * @param fallbacks defines the current fallback list.
  104216. * @param currentRank defines the current fallback rank.
  104217. * @returns the new fallback rank.
  104218. */
  104219. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104220. /**
  104221. * Add the required uniforms to the current list.
  104222. * @param uniforms defines the current uniform list.
  104223. */
  104224. static AddUniforms(uniforms: string[]): void;
  104225. /**
  104226. * Add the required uniforms to the current buffer.
  104227. * @param uniformBuffer defines the current uniform buffer.
  104228. */
  104229. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104230. /**
  104231. * Add the required samplers to the current list.
  104232. * @param samplers defines the current sampler list.
  104233. */
  104234. static AddSamplers(samplers: string[]): void;
  104235. /**
  104236. * Makes a duplicate of the current configuration into another one.
  104237. * @param anisotropicConfiguration define the config where to copy the info
  104238. */
  104239. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104240. /**
  104241. * Serializes this anisotropy configuration.
  104242. * @returns - An object with the serialized config.
  104243. */
  104244. serialize(): any;
  104245. /**
  104246. * Parses a anisotropy Configuration from a serialized object.
  104247. * @param source - Serialized object.
  104248. */
  104249. parse(source: any): void;
  104250. }
  104251. }
  104252. declare module BABYLON {
  104253. /**
  104254. * @hidden
  104255. */
  104256. export interface IMaterialBRDFDefines {
  104257. BRDF_V_HEIGHT_CORRELATED: boolean;
  104258. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104259. SPHERICAL_HARMONICS: boolean;
  104260. /** @hidden */
  104261. _areMiscDirty: boolean;
  104262. }
  104263. /**
  104264. * Define the code related to the BRDF parameters of the pbr material.
  104265. */
  104266. export class PBRBRDFConfiguration {
  104267. /**
  104268. * Default value used for the energy conservation.
  104269. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104270. */
  104271. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104272. /**
  104273. * Default value used for the Smith Visibility Height Correlated mode.
  104274. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104275. */
  104276. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104277. /**
  104278. * Default value used for the IBL diffuse part.
  104279. * This can help switching back to the polynomials mode globally which is a tiny bit
  104280. * less GPU intensive at the drawback of a lower quality.
  104281. */
  104282. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104283. private _useEnergyConservation;
  104284. /**
  104285. * Defines if the material uses energy conservation.
  104286. */
  104287. useEnergyConservation: boolean;
  104288. private _useSmithVisibilityHeightCorrelated;
  104289. /**
  104290. * LEGACY Mode set to false
  104291. * Defines if the material uses height smith correlated visibility term.
  104292. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104293. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104294. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104295. * Not relying on height correlated will also disable energy conservation.
  104296. */
  104297. useSmithVisibilityHeightCorrelated: boolean;
  104298. private _useSphericalHarmonics;
  104299. /**
  104300. * LEGACY Mode set to false
  104301. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104302. * diffuse part of the IBL.
  104303. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104304. * to the ground truth.
  104305. */
  104306. useSphericalHarmonics: boolean;
  104307. /** @hidden */
  104308. private _internalMarkAllSubMeshesAsMiscDirty;
  104309. /** @hidden */
  104310. _markAllSubMeshesAsMiscDirty(): void;
  104311. /**
  104312. * Instantiate a new istance of clear coat configuration.
  104313. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104314. */
  104315. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104316. /**
  104317. * Checks to see if a texture is used in the material.
  104318. * @param defines the list of "defines" to update.
  104319. */
  104320. prepareDefines(defines: IMaterialBRDFDefines): void;
  104321. /**
  104322. * Get the current class name of the texture useful for serialization or dynamic coding.
  104323. * @returns "PBRClearCoatConfiguration"
  104324. */
  104325. getClassName(): string;
  104326. /**
  104327. * Makes a duplicate of the current configuration into another one.
  104328. * @param brdfConfiguration define the config where to copy the info
  104329. */
  104330. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104331. /**
  104332. * Serializes this BRDF configuration.
  104333. * @returns - An object with the serialized config.
  104334. */
  104335. serialize(): any;
  104336. /**
  104337. * Parses a BRDF Configuration from a serialized object.
  104338. * @param source - Serialized object.
  104339. */
  104340. parse(source: any): void;
  104341. }
  104342. }
  104343. declare module BABYLON {
  104344. /**
  104345. * @hidden
  104346. */
  104347. export interface IMaterialSheenDefines {
  104348. SHEEN: boolean;
  104349. SHEEN_TEXTURE: boolean;
  104350. SHEEN_TEXTUREDIRECTUV: number;
  104351. SHEEN_LINKWITHALBEDO: boolean;
  104352. /** @hidden */
  104353. _areTexturesDirty: boolean;
  104354. }
  104355. /**
  104356. * Define the code related to the Sheen parameters of the pbr material.
  104357. */
  104358. export class PBRSheenConfiguration {
  104359. private _isEnabled;
  104360. /**
  104361. * Defines if the material uses sheen.
  104362. */
  104363. isEnabled: boolean;
  104364. private _linkSheenWithAlbedo;
  104365. /**
  104366. * Defines if the sheen is linked to the sheen color.
  104367. */
  104368. linkSheenWithAlbedo: boolean;
  104369. /**
  104370. * Defines the sheen intensity.
  104371. */
  104372. intensity: number;
  104373. /**
  104374. * Defines the sheen color.
  104375. */
  104376. color: Color3;
  104377. private _texture;
  104378. /**
  104379. * Stores the sheen tint values in a texture.
  104380. * rgb is tint
  104381. * a is a intensity
  104382. */
  104383. texture: Nullable<BaseTexture>;
  104384. /** @hidden */
  104385. private _internalMarkAllSubMeshesAsTexturesDirty;
  104386. /** @hidden */
  104387. _markAllSubMeshesAsTexturesDirty(): void;
  104388. /**
  104389. * Instantiate a new istance of clear coat configuration.
  104390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104391. */
  104392. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104393. /**
  104394. * Specifies that the submesh is ready to be used.
  104395. * @param defines the list of "defines" to update.
  104396. * @param scene defines the scene the material belongs to.
  104397. * @returns - boolean indicating that the submesh is ready or not.
  104398. */
  104399. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  104400. /**
  104401. * Checks to see if a texture is used in the material.
  104402. * @param defines the list of "defines" to update.
  104403. * @param scene defines the scene the material belongs to.
  104404. */
  104405. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  104406. /**
  104407. * Binds the material data.
  104408. * @param uniformBuffer defines the Uniform buffer to fill in.
  104409. * @param scene defines the scene the material belongs to.
  104410. * @param isFrozen defines wether the material is frozen or not.
  104411. */
  104412. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104413. /**
  104414. * Checks to see if a texture is used in the material.
  104415. * @param texture - Base texture to use.
  104416. * @returns - Boolean specifying if a texture is used in the material.
  104417. */
  104418. hasTexture(texture: BaseTexture): boolean;
  104419. /**
  104420. * Returns an array of the actively used textures.
  104421. * @param activeTextures Array of BaseTextures
  104422. */
  104423. getActiveTextures(activeTextures: BaseTexture[]): void;
  104424. /**
  104425. * Returns the animatable textures.
  104426. * @param animatables Array of animatable textures.
  104427. */
  104428. getAnimatables(animatables: IAnimatable[]): void;
  104429. /**
  104430. * Disposes the resources of the material.
  104431. * @param forceDisposeTextures - Forces the disposal of all textures.
  104432. */
  104433. dispose(forceDisposeTextures?: boolean): void;
  104434. /**
  104435. * Get the current class name of the texture useful for serialization or dynamic coding.
  104436. * @returns "PBRSheenConfiguration"
  104437. */
  104438. getClassName(): string;
  104439. /**
  104440. * Add fallbacks to the effect fallbacks list.
  104441. * @param defines defines the Base texture to use.
  104442. * @param fallbacks defines the current fallback list.
  104443. * @param currentRank defines the current fallback rank.
  104444. * @returns the new fallback rank.
  104445. */
  104446. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104447. /**
  104448. * Add the required uniforms to the current list.
  104449. * @param uniforms defines the current uniform list.
  104450. */
  104451. static AddUniforms(uniforms: string[]): void;
  104452. /**
  104453. * Add the required uniforms to the current buffer.
  104454. * @param uniformBuffer defines the current uniform buffer.
  104455. */
  104456. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104457. /**
  104458. * Add the required samplers to the current list.
  104459. * @param samplers defines the current sampler list.
  104460. */
  104461. static AddSamplers(samplers: string[]): void;
  104462. /**
  104463. * Makes a duplicate of the current configuration into another one.
  104464. * @param sheenConfiguration define the config where to copy the info
  104465. */
  104466. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  104467. /**
  104468. * Serializes this BRDF configuration.
  104469. * @returns - An object with the serialized config.
  104470. */
  104471. serialize(): any;
  104472. /**
  104473. * Parses a Sheen Configuration from a serialized object.
  104474. * @param source - Serialized object.
  104475. */
  104476. parse(source: any): void;
  104477. }
  104478. }
  104479. declare module BABYLON {
  104480. /**
  104481. * @hidden
  104482. */
  104483. export interface IMaterialSubSurfaceDefines {
  104484. SUBSURFACE: boolean;
  104485. SS_REFRACTION: boolean;
  104486. SS_TRANSLUCENCY: boolean;
  104487. SS_SCATERRING: boolean;
  104488. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104489. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104490. SS_REFRACTIONMAP_3D: boolean;
  104491. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104492. SS_LODINREFRACTIONALPHA: boolean;
  104493. SS_GAMMAREFRACTION: boolean;
  104494. SS_RGBDREFRACTION: boolean;
  104495. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104496. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104497. /** @hidden */
  104498. _areTexturesDirty: boolean;
  104499. }
  104500. /**
  104501. * Define the code related to the sub surface parameters of the pbr material.
  104502. */
  104503. export class PBRSubSurfaceConfiguration {
  104504. private _isRefractionEnabled;
  104505. /**
  104506. * Defines if the refraction is enabled in the material.
  104507. */
  104508. isRefractionEnabled: boolean;
  104509. private _isTranslucencyEnabled;
  104510. /**
  104511. * Defines if the translucency is enabled in the material.
  104512. */
  104513. isTranslucencyEnabled: boolean;
  104514. private _isScatteringEnabled;
  104515. /**
  104516. * Defines the refraction intensity of the material.
  104517. * The refraction when enabled replaces the Diffuse part of the material.
  104518. * The intensity helps transitionning between diffuse and refraction.
  104519. */
  104520. refractionIntensity: number;
  104521. /**
  104522. * Defines the translucency intensity of the material.
  104523. * When translucency has been enabled, this defines how much of the "translucency"
  104524. * is addded to the diffuse part of the material.
  104525. */
  104526. translucencyIntensity: number;
  104527. /**
  104528. * Defines the scattering intensity of the material.
  104529. * When scattering has been enabled, this defines how much of the "scattered light"
  104530. * is addded to the diffuse part of the material.
  104531. */
  104532. scatteringIntensity: number;
  104533. private _thicknessTexture;
  104534. /**
  104535. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  104536. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  104537. * 0 would mean minimumThickness
  104538. * 1 would mean maximumThickness
  104539. * The other channels might be use as a mask to vary the different effects intensity.
  104540. */
  104541. thicknessTexture: Nullable<BaseTexture>;
  104542. private _refractionTexture;
  104543. /**
  104544. * Defines the texture to use for refraction.
  104545. */
  104546. refractionTexture: Nullable<BaseTexture>;
  104547. private _indexOfRefraction;
  104548. /**
  104549. * Defines the indice of refraction used in the material.
  104550. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  104551. */
  104552. indexOfRefraction: number;
  104553. private _invertRefractionY;
  104554. /**
  104555. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104556. */
  104557. invertRefractionY: boolean;
  104558. private _linkRefractionWithTransparency;
  104559. /**
  104560. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104561. * Materials half opaque for instance using refraction could benefit from this control.
  104562. */
  104563. linkRefractionWithTransparency: boolean;
  104564. /**
  104565. * Defines the minimum thickness stored in the thickness map.
  104566. * If no thickness map is defined, this value will be used to simulate thickness.
  104567. */
  104568. minimumThickness: number;
  104569. /**
  104570. * Defines the maximum thickness stored in the thickness map.
  104571. */
  104572. maximumThickness: number;
  104573. /**
  104574. * Defines the volume tint of the material.
  104575. * This is used for both translucency and scattering.
  104576. */
  104577. tintColor: Color3;
  104578. /**
  104579. * Defines the distance at which the tint color should be found in the media.
  104580. * This is used for refraction only.
  104581. */
  104582. tintColorAtDistance: number;
  104583. /**
  104584. * Defines how far each channel transmit through the media.
  104585. * It is defined as a color to simplify it selection.
  104586. */
  104587. diffusionDistance: Color3;
  104588. private _useMaskFromThicknessTexture;
  104589. /**
  104590. * Stores the intensity of the different subsurface effects in the thickness texture.
  104591. * * the green channel is the translucency intensity.
  104592. * * the blue channel is the scattering intensity.
  104593. * * the alpha channel is the refraction intensity.
  104594. */
  104595. useMaskFromThicknessTexture: boolean;
  104596. /** @hidden */
  104597. private _internalMarkAllSubMeshesAsTexturesDirty;
  104598. /** @hidden */
  104599. _markAllSubMeshesAsTexturesDirty(): void;
  104600. /**
  104601. * Instantiate a new istance of sub surface configuration.
  104602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104603. */
  104604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104605. /**
  104606. * Gets wehter the submesh is ready to be used or not.
  104607. * @param defines the list of "defines" to update.
  104608. * @param scene defines the scene the material belongs to.
  104609. * @returns - boolean indicating that the submesh is ready or not.
  104610. */
  104611. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  104612. /**
  104613. * Checks to see if a texture is used in the material.
  104614. * @param defines the list of "defines" to update.
  104615. * @param scene defines the scene to the material belongs to.
  104616. */
  104617. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  104618. /**
  104619. * Binds the material data.
  104620. * @param uniformBuffer defines the Uniform buffer to fill in.
  104621. * @param scene defines the scene the material belongs to.
  104622. * @param engine defines the engine the material belongs to.
  104623. * @param isFrozen defines wether the material is frozen or not.
  104624. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  104625. */
  104626. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  104627. /**
  104628. * Unbinds the material from the mesh.
  104629. * @param activeEffect defines the effect that should be unbound from.
  104630. * @returns true if unbound, otherwise false
  104631. */
  104632. unbind(activeEffect: Effect): boolean;
  104633. /**
  104634. * Returns the texture used for refraction or null if none is used.
  104635. * @param scene defines the scene the material belongs to.
  104636. * @returns - Refraction texture if present. If no refraction texture and refraction
  104637. * is linked with transparency, returns environment texture. Otherwise, returns null.
  104638. */
  104639. private _getRefractionTexture;
  104640. /**
  104641. * Returns true if alpha blending should be disabled.
  104642. */
  104643. readonly disableAlphaBlending: boolean;
  104644. /**
  104645. * Fills the list of render target textures.
  104646. * @param renderTargets the list of render targets to update
  104647. */
  104648. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  104649. /**
  104650. * Checks to see if a texture is used in the material.
  104651. * @param texture - Base texture to use.
  104652. * @returns - Boolean specifying if a texture is used in the material.
  104653. */
  104654. hasTexture(texture: BaseTexture): boolean;
  104655. /**
  104656. * Gets a boolean indicating that current material needs to register RTT
  104657. * @returns true if this uses a render target otherwise false.
  104658. */
  104659. hasRenderTargetTextures(): boolean;
  104660. /**
  104661. * Returns an array of the actively used textures.
  104662. * @param activeTextures Array of BaseTextures
  104663. */
  104664. getActiveTextures(activeTextures: BaseTexture[]): void;
  104665. /**
  104666. * Returns the animatable textures.
  104667. * @param animatables Array of animatable textures.
  104668. */
  104669. getAnimatables(animatables: IAnimatable[]): void;
  104670. /**
  104671. * Disposes the resources of the material.
  104672. * @param forceDisposeTextures - Forces the disposal of all textures.
  104673. */
  104674. dispose(forceDisposeTextures?: boolean): void;
  104675. /**
  104676. * Get the current class name of the texture useful for serialization or dynamic coding.
  104677. * @returns "PBRSubSurfaceConfiguration"
  104678. */
  104679. getClassName(): string;
  104680. /**
  104681. * Add fallbacks to the effect fallbacks list.
  104682. * @param defines defines the Base texture to use.
  104683. * @param fallbacks defines the current fallback list.
  104684. * @param currentRank defines the current fallback rank.
  104685. * @returns the new fallback rank.
  104686. */
  104687. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104688. /**
  104689. * Add the required uniforms to the current list.
  104690. * @param uniforms defines the current uniform list.
  104691. */
  104692. static AddUniforms(uniforms: string[]): void;
  104693. /**
  104694. * Add the required samplers to the current list.
  104695. * @param samplers defines the current sampler list.
  104696. */
  104697. static AddSamplers(samplers: string[]): void;
  104698. /**
  104699. * Add the required uniforms to the current buffer.
  104700. * @param uniformBuffer defines the current uniform buffer.
  104701. */
  104702. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104703. /**
  104704. * Makes a duplicate of the current configuration into another one.
  104705. * @param configuration define the config where to copy the info
  104706. */
  104707. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104708. /**
  104709. * Serializes this Sub Surface configuration.
  104710. * @returns - An object with the serialized config.
  104711. */
  104712. serialize(): any;
  104713. /**
  104714. * Parses a Sub Surface Configuration from a serialized object.
  104715. * @param source - Serialized object.
  104716. */
  104717. parse(source: any): void;
  104718. }
  104719. }
  104720. declare module BABYLON {
  104721. /** @hidden */
  104722. export var pbrFragmentDeclaration: {
  104723. name: string;
  104724. shader: string;
  104725. };
  104726. }
  104727. declare module BABYLON {
  104728. /** @hidden */
  104729. export var pbrUboDeclaration: {
  104730. name: string;
  104731. shader: string;
  104732. };
  104733. }
  104734. declare module BABYLON {
  104735. /** @hidden */
  104736. export var pbrFragmentExtraDeclaration: {
  104737. name: string;
  104738. shader: string;
  104739. };
  104740. }
  104741. declare module BABYLON {
  104742. /** @hidden */
  104743. export var pbrFragmentSamplersDeclaration: {
  104744. name: string;
  104745. shader: string;
  104746. };
  104747. }
  104748. declare module BABYLON {
  104749. /** @hidden */
  104750. export var pbrHelperFunctions: {
  104751. name: string;
  104752. shader: string;
  104753. };
  104754. }
  104755. declare module BABYLON {
  104756. /** @hidden */
  104757. export var harmonicsFunctions: {
  104758. name: string;
  104759. shader: string;
  104760. };
  104761. }
  104762. declare module BABYLON {
  104763. /** @hidden */
  104764. export var pbrDirectLightingSetupFunctions: {
  104765. name: string;
  104766. shader: string;
  104767. };
  104768. }
  104769. declare module BABYLON {
  104770. /** @hidden */
  104771. export var pbrDirectLightingFalloffFunctions: {
  104772. name: string;
  104773. shader: string;
  104774. };
  104775. }
  104776. declare module BABYLON {
  104777. /** @hidden */
  104778. export var pbrBRDFFunctions: {
  104779. name: string;
  104780. shader: string;
  104781. };
  104782. }
  104783. declare module BABYLON {
  104784. /** @hidden */
  104785. export var pbrDirectLightingFunctions: {
  104786. name: string;
  104787. shader: string;
  104788. };
  104789. }
  104790. declare module BABYLON {
  104791. /** @hidden */
  104792. export var pbrIBLFunctions: {
  104793. name: string;
  104794. shader: string;
  104795. };
  104796. }
  104797. declare module BABYLON {
  104798. /** @hidden */
  104799. export var pbrDebug: {
  104800. name: string;
  104801. shader: string;
  104802. };
  104803. }
  104804. declare module BABYLON {
  104805. /** @hidden */
  104806. export var pbrPixelShader: {
  104807. name: string;
  104808. shader: string;
  104809. };
  104810. }
  104811. declare module BABYLON {
  104812. /** @hidden */
  104813. export var pbrVertexDeclaration: {
  104814. name: string;
  104815. shader: string;
  104816. };
  104817. }
  104818. declare module BABYLON {
  104819. /** @hidden */
  104820. export var pbrVertexShader: {
  104821. name: string;
  104822. shader: string;
  104823. };
  104824. }
  104825. declare module BABYLON {
  104826. /**
  104827. * Manages the defines for the PBR Material.
  104828. * @hidden
  104829. */
  104830. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104831. PBR: boolean;
  104832. MAINUV1: boolean;
  104833. MAINUV2: boolean;
  104834. UV1: boolean;
  104835. UV2: boolean;
  104836. ALBEDO: boolean;
  104837. ALBEDODIRECTUV: number;
  104838. VERTEXCOLOR: boolean;
  104839. AMBIENT: boolean;
  104840. AMBIENTDIRECTUV: number;
  104841. AMBIENTINGRAYSCALE: boolean;
  104842. OPACITY: boolean;
  104843. VERTEXALPHA: boolean;
  104844. OPACITYDIRECTUV: number;
  104845. OPACITYRGB: boolean;
  104846. ALPHATEST: boolean;
  104847. DEPTHPREPASS: boolean;
  104848. ALPHABLEND: boolean;
  104849. ALPHAFROMALBEDO: boolean;
  104850. ALPHATESTVALUE: string;
  104851. SPECULAROVERALPHA: boolean;
  104852. RADIANCEOVERALPHA: boolean;
  104853. ALPHAFRESNEL: boolean;
  104854. LINEARALPHAFRESNEL: boolean;
  104855. PREMULTIPLYALPHA: boolean;
  104856. EMISSIVE: boolean;
  104857. EMISSIVEDIRECTUV: number;
  104858. REFLECTIVITY: boolean;
  104859. REFLECTIVITYDIRECTUV: number;
  104860. SPECULARTERM: boolean;
  104861. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104862. MICROSURFACEAUTOMATIC: boolean;
  104863. LODBASEDMICROSFURACE: boolean;
  104864. MICROSURFACEMAP: boolean;
  104865. MICROSURFACEMAPDIRECTUV: number;
  104866. METALLICWORKFLOW: boolean;
  104867. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104868. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104869. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104870. AOSTOREINMETALMAPRED: boolean;
  104871. ENVIRONMENTBRDF: boolean;
  104872. ENVIRONMENTBRDF_RGBD: boolean;
  104873. NORMAL: boolean;
  104874. TANGENT: boolean;
  104875. BUMP: boolean;
  104876. BUMPDIRECTUV: number;
  104877. OBJECTSPACE_NORMALMAP: boolean;
  104878. PARALLAX: boolean;
  104879. PARALLAXOCCLUSION: boolean;
  104880. NORMALXYSCALE: boolean;
  104881. LIGHTMAP: boolean;
  104882. LIGHTMAPDIRECTUV: number;
  104883. USELIGHTMAPASSHADOWMAP: boolean;
  104884. GAMMALIGHTMAP: boolean;
  104885. REFLECTION: boolean;
  104886. REFLECTIONMAP_3D: boolean;
  104887. REFLECTIONMAP_SPHERICAL: boolean;
  104888. REFLECTIONMAP_PLANAR: boolean;
  104889. REFLECTIONMAP_CUBIC: boolean;
  104890. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104891. REFLECTIONMAP_PROJECTION: boolean;
  104892. REFLECTIONMAP_SKYBOX: boolean;
  104893. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104894. REFLECTIONMAP_EXPLICIT: boolean;
  104895. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104896. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104897. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104898. INVERTCUBICMAP: boolean;
  104899. USESPHERICALFROMREFLECTIONMAP: boolean;
  104900. SPHERICAL_HARMONICS: boolean;
  104901. USESPHERICALINVERTEX: boolean;
  104902. REFLECTIONMAP_OPPOSITEZ: boolean;
  104903. LODINREFLECTIONALPHA: boolean;
  104904. GAMMAREFLECTION: boolean;
  104905. RGBDREFLECTION: boolean;
  104906. RADIANCEOCCLUSION: boolean;
  104907. HORIZONOCCLUSION: boolean;
  104908. INSTANCES: boolean;
  104909. NUM_BONE_INFLUENCERS: number;
  104910. BonesPerMesh: number;
  104911. BONETEXTURE: boolean;
  104912. NONUNIFORMSCALING: boolean;
  104913. MORPHTARGETS: boolean;
  104914. MORPHTARGETS_NORMAL: boolean;
  104915. MORPHTARGETS_TANGENT: boolean;
  104916. NUM_MORPH_INFLUENCERS: number;
  104917. IMAGEPROCESSING: boolean;
  104918. VIGNETTE: boolean;
  104919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104920. VIGNETTEBLENDMODEOPAQUE: boolean;
  104921. TONEMAPPING: boolean;
  104922. TONEMAPPING_ACES: boolean;
  104923. CONTRAST: boolean;
  104924. COLORCURVES: boolean;
  104925. COLORGRADING: boolean;
  104926. COLORGRADING3D: boolean;
  104927. SAMPLER3DGREENDEPTH: boolean;
  104928. SAMPLER3DBGRMAP: boolean;
  104929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104930. EXPOSURE: boolean;
  104931. MULTIVIEW: boolean;
  104932. USEPHYSICALLIGHTFALLOFF: boolean;
  104933. USEGLTFLIGHTFALLOFF: boolean;
  104934. TWOSIDEDLIGHTING: boolean;
  104935. SHADOWFLOAT: boolean;
  104936. CLIPPLANE: boolean;
  104937. CLIPPLANE2: boolean;
  104938. CLIPPLANE3: boolean;
  104939. CLIPPLANE4: boolean;
  104940. POINTSIZE: boolean;
  104941. FOG: boolean;
  104942. LOGARITHMICDEPTH: boolean;
  104943. FORCENORMALFORWARD: boolean;
  104944. SPECULARAA: boolean;
  104945. CLEARCOAT: boolean;
  104946. CLEARCOAT_DEFAULTIOR: boolean;
  104947. CLEARCOAT_TEXTURE: boolean;
  104948. CLEARCOAT_TEXTUREDIRECTUV: number;
  104949. CLEARCOAT_BUMP: boolean;
  104950. CLEARCOAT_BUMPDIRECTUV: number;
  104951. CLEARCOAT_TINT: boolean;
  104952. CLEARCOAT_TINT_TEXTURE: boolean;
  104953. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104954. ANISOTROPIC: boolean;
  104955. ANISOTROPIC_TEXTURE: boolean;
  104956. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104957. BRDF_V_HEIGHT_CORRELATED: boolean;
  104958. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104959. SHEEN: boolean;
  104960. SHEEN_TEXTURE: boolean;
  104961. SHEEN_TEXTUREDIRECTUV: number;
  104962. SHEEN_LINKWITHALBEDO: boolean;
  104963. SUBSURFACE: boolean;
  104964. SS_REFRACTION: boolean;
  104965. SS_TRANSLUCENCY: boolean;
  104966. SS_SCATERRING: boolean;
  104967. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104968. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104969. SS_REFRACTIONMAP_3D: boolean;
  104970. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104971. SS_LODINREFRACTIONALPHA: boolean;
  104972. SS_GAMMAREFRACTION: boolean;
  104973. SS_RGBDREFRACTION: boolean;
  104974. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104975. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104976. UNLIT: boolean;
  104977. DEBUGMODE: number;
  104978. /**
  104979. * Initializes the PBR Material defines.
  104980. */
  104981. constructor();
  104982. /**
  104983. * Resets the PBR Material defines.
  104984. */
  104985. reset(): void;
  104986. }
  104987. /**
  104988. * The Physically based material base class of BJS.
  104989. *
  104990. * This offers the main features of a standard PBR material.
  104991. * For more information, please refer to the documentation :
  104992. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104993. */
  104994. export abstract class PBRBaseMaterial extends PushMaterial {
  104995. /**
  104996. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104997. */
  104998. static readonly PBRMATERIAL_OPAQUE: number;
  104999. /**
  105000. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105001. */
  105002. static readonly PBRMATERIAL_ALPHATEST: number;
  105003. /**
  105004. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105005. */
  105006. static readonly PBRMATERIAL_ALPHABLEND: number;
  105007. /**
  105008. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105009. * They are also discarded below the alpha cutoff threshold to improve performances.
  105010. */
  105011. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105012. /**
  105013. * Defines the default value of how much AO map is occluding the analytical lights
  105014. * (point spot...).
  105015. */
  105016. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105017. /**
  105018. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  105019. */
  105020. static readonly LIGHTFALLOFF_PHYSICAL: number;
  105021. /**
  105022. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  105023. * to enhance interoperability with other engines.
  105024. */
  105025. static readonly LIGHTFALLOFF_GLTF: number;
  105026. /**
  105027. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  105028. * to enhance interoperability with other materials.
  105029. */
  105030. static readonly LIGHTFALLOFF_STANDARD: number;
  105031. /**
  105032. * Intensity of the direct lights e.g. the four lights available in your scene.
  105033. * This impacts both the direct diffuse and specular highlights.
  105034. */
  105035. protected _directIntensity: number;
  105036. /**
  105037. * Intensity of the emissive part of the material.
  105038. * This helps controlling the emissive effect without modifying the emissive color.
  105039. */
  105040. protected _emissiveIntensity: number;
  105041. /**
  105042. * Intensity of the environment e.g. how much the environment will light the object
  105043. * either through harmonics for rough material or through the refelction for shiny ones.
  105044. */
  105045. protected _environmentIntensity: number;
  105046. /**
  105047. * This is a special control allowing the reduction of the specular highlights coming from the
  105048. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105049. */
  105050. protected _specularIntensity: number;
  105051. /**
  105052. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  105053. */
  105054. private _lightingInfos;
  105055. /**
  105056. * Debug Control allowing disabling the bump map on this material.
  105057. */
  105058. protected _disableBumpMap: boolean;
  105059. /**
  105060. * AKA Diffuse Texture in standard nomenclature.
  105061. */
  105062. protected _albedoTexture: Nullable<BaseTexture>;
  105063. /**
  105064. * AKA Occlusion Texture in other nomenclature.
  105065. */
  105066. protected _ambientTexture: Nullable<BaseTexture>;
  105067. /**
  105068. * AKA Occlusion Texture Intensity in other nomenclature.
  105069. */
  105070. protected _ambientTextureStrength: number;
  105071. /**
  105072. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105073. * 1 means it completely occludes it
  105074. * 0 mean it has no impact
  105075. */
  105076. protected _ambientTextureImpactOnAnalyticalLights: number;
  105077. /**
  105078. * Stores the alpha values in a texture.
  105079. */
  105080. protected _opacityTexture: Nullable<BaseTexture>;
  105081. /**
  105082. * Stores the reflection values in a texture.
  105083. */
  105084. protected _reflectionTexture: Nullable<BaseTexture>;
  105085. /**
  105086. * Stores the emissive values in a texture.
  105087. */
  105088. protected _emissiveTexture: Nullable<BaseTexture>;
  105089. /**
  105090. * AKA Specular texture in other nomenclature.
  105091. */
  105092. protected _reflectivityTexture: Nullable<BaseTexture>;
  105093. /**
  105094. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105095. */
  105096. protected _metallicTexture: Nullable<BaseTexture>;
  105097. /**
  105098. * Specifies the metallic scalar of the metallic/roughness workflow.
  105099. * Can also be used to scale the metalness values of the metallic texture.
  105100. */
  105101. protected _metallic: Nullable<number>;
  105102. /**
  105103. * Specifies the roughness scalar of the metallic/roughness workflow.
  105104. * Can also be used to scale the roughness values of the metallic texture.
  105105. */
  105106. protected _roughness: Nullable<number>;
  105107. /**
  105108. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105109. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105110. */
  105111. protected _microSurfaceTexture: Nullable<BaseTexture>;
  105112. /**
  105113. * Stores surface normal data used to displace a mesh in a texture.
  105114. */
  105115. protected _bumpTexture: Nullable<BaseTexture>;
  105116. /**
  105117. * Stores the pre-calculated light information of a mesh in a texture.
  105118. */
  105119. protected _lightmapTexture: Nullable<BaseTexture>;
  105120. /**
  105121. * The color of a material in ambient lighting.
  105122. */
  105123. protected _ambientColor: Color3;
  105124. /**
  105125. * AKA Diffuse Color in other nomenclature.
  105126. */
  105127. protected _albedoColor: Color3;
  105128. /**
  105129. * AKA Specular Color in other nomenclature.
  105130. */
  105131. protected _reflectivityColor: Color3;
  105132. /**
  105133. * The color applied when light is reflected from a material.
  105134. */
  105135. protected _reflectionColor: Color3;
  105136. /**
  105137. * The color applied when light is emitted from a material.
  105138. */
  105139. protected _emissiveColor: Color3;
  105140. /**
  105141. * AKA Glossiness in other nomenclature.
  105142. */
  105143. protected _microSurface: number;
  105144. /**
  105145. * Specifies that the material will use the light map as a show map.
  105146. */
  105147. protected _useLightmapAsShadowmap: boolean;
  105148. /**
  105149. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105150. * makes the reflect vector face the model (under horizon).
  105151. */
  105152. protected _useHorizonOcclusion: boolean;
  105153. /**
  105154. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105155. * too much the area relying on ambient texture to define their ambient occlusion.
  105156. */
  105157. protected _useRadianceOcclusion: boolean;
  105158. /**
  105159. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105160. */
  105161. protected _useAlphaFromAlbedoTexture: boolean;
  105162. /**
  105163. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  105164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105165. */
  105166. protected _useSpecularOverAlpha: boolean;
  105167. /**
  105168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105169. */
  105170. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105171. /**
  105172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105173. */
  105174. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  105175. /**
  105176. * Specifies if the metallic texture contains the roughness information in its green channel.
  105177. */
  105178. protected _useRoughnessFromMetallicTextureGreen: boolean;
  105179. /**
  105180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105181. */
  105182. protected _useMetallnessFromMetallicTextureBlue: boolean;
  105183. /**
  105184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105185. */
  105186. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  105187. /**
  105188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105189. */
  105190. protected _useAmbientInGrayScale: boolean;
  105191. /**
  105192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105193. * The material will try to infer what glossiness each pixel should be.
  105194. */
  105195. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  105196. /**
  105197. * Defines the falloff type used in this material.
  105198. * It by default is Physical.
  105199. */
  105200. protected _lightFalloff: number;
  105201. /**
  105202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105204. */
  105205. protected _useRadianceOverAlpha: boolean;
  105206. /**
  105207. * Allows using an object space normal map (instead of tangent space).
  105208. */
  105209. protected _useObjectSpaceNormalMap: boolean;
  105210. /**
  105211. * Allows using the bump map in parallax mode.
  105212. */
  105213. protected _useParallax: boolean;
  105214. /**
  105215. * Allows using the bump map in parallax occlusion mode.
  105216. */
  105217. protected _useParallaxOcclusion: boolean;
  105218. /**
  105219. * Controls the scale bias of the parallax mode.
  105220. */
  105221. protected _parallaxScaleBias: number;
  105222. /**
  105223. * If sets to true, disables all the lights affecting the material.
  105224. */
  105225. protected _disableLighting: boolean;
  105226. /**
  105227. * Number of Simultaneous lights allowed on the material.
  105228. */
  105229. protected _maxSimultaneousLights: number;
  105230. /**
  105231. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  105232. */
  105233. protected _invertNormalMapX: boolean;
  105234. /**
  105235. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  105236. */
  105237. protected _invertNormalMapY: boolean;
  105238. /**
  105239. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105240. */
  105241. protected _twoSidedLighting: boolean;
  105242. /**
  105243. * Defines the alpha limits in alpha test mode.
  105244. */
  105245. protected _alphaCutOff: number;
  105246. /**
  105247. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105248. */
  105249. protected _forceAlphaTest: boolean;
  105250. /**
  105251. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105252. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105253. */
  105254. protected _useAlphaFresnel: boolean;
  105255. /**
  105256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105257. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105258. */
  105259. protected _useLinearAlphaFresnel: boolean;
  105260. /**
  105261. * The transparency mode of the material.
  105262. */
  105263. protected _transparencyMode: Nullable<number>;
  105264. /**
  105265. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  105266. * from cos thetav and roughness:
  105267. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  105268. */
  105269. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  105270. /**
  105271. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105272. */
  105273. protected _forceIrradianceInFragment: boolean;
  105274. /**
  105275. * Force normal to face away from face.
  105276. */
  105277. protected _forceNormalForward: boolean;
  105278. /**
  105279. * Enables specular anti aliasing in the PBR shader.
  105280. * It will both interacts on the Geometry for analytical and IBL lighting.
  105281. * It also prefilter the roughness map based on the bump values.
  105282. */
  105283. protected _enableSpecularAntiAliasing: boolean;
  105284. /**
  105285. * Default configuration related to image processing available in the PBR Material.
  105286. */
  105287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105288. /**
  105289. * Keep track of the image processing observer to allow dispose and replace.
  105290. */
  105291. private _imageProcessingObserver;
  105292. /**
  105293. * Attaches a new image processing configuration to the PBR Material.
  105294. * @param configuration
  105295. */
  105296. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105297. /**
  105298. * Stores the available render targets.
  105299. */
  105300. private _renderTargets;
  105301. /**
  105302. * Sets the global ambient color for the material used in lighting calculations.
  105303. */
  105304. private _globalAmbientColor;
  105305. /**
  105306. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  105307. */
  105308. private _useLogarithmicDepth;
  105309. /**
  105310. * If set to true, no lighting calculations will be applied.
  105311. */
  105312. private _unlit;
  105313. private _debugMode;
  105314. /**
  105315. * @hidden
  105316. * This is reserved for the inspector.
  105317. * Defines the material debug mode.
  105318. * It helps seeing only some components of the material while troubleshooting.
  105319. */
  105320. debugMode: number;
  105321. /**
  105322. * @hidden
  105323. * This is reserved for the inspector.
  105324. * Specify from where on screen the debug mode should start.
  105325. * The value goes from -1 (full screen) to 1 (not visible)
  105326. * It helps with side by side comparison against the final render
  105327. * This defaults to -1
  105328. */
  105329. private debugLimit;
  105330. /**
  105331. * @hidden
  105332. * This is reserved for the inspector.
  105333. * As the default viewing range might not be enough (if the ambient is really small for instance)
  105334. * You can use the factor to better multiply the final value.
  105335. */
  105336. private debugFactor;
  105337. /**
  105338. * Defines the clear coat layer parameters for the material.
  105339. */
  105340. readonly clearCoat: PBRClearCoatConfiguration;
  105341. /**
  105342. * Defines the anisotropic parameters for the material.
  105343. */
  105344. readonly anisotropy: PBRAnisotropicConfiguration;
  105345. /**
  105346. * Defines the BRDF parameters for the material.
  105347. */
  105348. readonly brdf: PBRBRDFConfiguration;
  105349. /**
  105350. * Defines the Sheen parameters for the material.
  105351. */
  105352. readonly sheen: PBRSheenConfiguration;
  105353. /**
  105354. * Defines the SubSurface parameters for the material.
  105355. */
  105356. readonly subSurface: PBRSubSurfaceConfiguration;
  105357. /**
  105358. * Custom callback helping to override the default shader used in the material.
  105359. */
  105360. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  105361. /**
  105362. * Instantiates a new PBRMaterial instance.
  105363. *
  105364. * @param name The material name
  105365. * @param scene The scene the material will be use in.
  105366. */
  105367. constructor(name: string, scene: Scene);
  105368. /**
  105369. * Gets a boolean indicating that current material needs to register RTT
  105370. */
  105371. readonly hasRenderTargetTextures: boolean;
  105372. /**
  105373. * Gets the name of the material class.
  105374. */
  105375. getClassName(): string;
  105376. /**
  105377. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105378. */
  105379. /**
  105380. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  105381. */
  105382. useLogarithmicDepth: boolean;
  105383. /**
  105384. * Gets the current transparency mode.
  105385. */
  105386. /**
  105387. * Sets the transparency mode of the material.
  105388. *
  105389. * | Value | Type | Description |
  105390. * | ----- | ----------------------------------- | ----------- |
  105391. * | 0 | OPAQUE | |
  105392. * | 1 | ALPHATEST | |
  105393. * | 2 | ALPHABLEND | |
  105394. * | 3 | ALPHATESTANDBLEND | |
  105395. *
  105396. */
  105397. transparencyMode: Nullable<number>;
  105398. /**
  105399. * Returns true if alpha blending should be disabled.
  105400. */
  105401. private readonly _disableAlphaBlending;
  105402. /**
  105403. * Specifies whether or not this material should be rendered in alpha blend mode.
  105404. */
  105405. needAlphaBlending(): boolean;
  105406. /**
  105407. * Specifies if the mesh will require alpha blending.
  105408. * @param mesh - BJS mesh.
  105409. */
  105410. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105411. /**
  105412. * Specifies whether or not this material should be rendered in alpha test mode.
  105413. */
  105414. needAlphaTesting(): boolean;
  105415. /**
  105416. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  105417. */
  105418. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  105419. /**
  105420. * Gets the texture used for the alpha test.
  105421. */
  105422. getAlphaTestTexture(): Nullable<BaseTexture>;
  105423. /**
  105424. * Specifies that the submesh is ready to be used.
  105425. * @param mesh - BJS mesh.
  105426. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  105427. * @param useInstances - Specifies that instances should be used.
  105428. * @returns - boolean indicating that the submesh is ready or not.
  105429. */
  105430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105431. /**
  105432. * Specifies if the material uses metallic roughness workflow.
  105433. * @returns boolean specifiying if the material uses metallic roughness workflow.
  105434. */
  105435. isMetallicWorkflow(): boolean;
  105436. private _prepareEffect;
  105437. private _prepareDefines;
  105438. /**
  105439. * Force shader compilation
  105440. */
  105441. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  105442. clipPlane: boolean;
  105443. }>): void;
  105444. /**
  105445. * Initializes the uniform buffer layout for the shader.
  105446. */
  105447. buildUniformLayout(): void;
  105448. /**
  105449. * Unbinds the material from the mesh
  105450. */
  105451. unbind(): void;
  105452. /**
  105453. * Binds the submesh data.
  105454. * @param world - The world matrix.
  105455. * @param mesh - The BJS mesh.
  105456. * @param subMesh - A submesh of the BJS mesh.
  105457. */
  105458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105459. /**
  105460. * Returns the animatable textures.
  105461. * @returns - Array of animatable textures.
  105462. */
  105463. getAnimatables(): IAnimatable[];
  105464. /**
  105465. * Returns the texture used for reflections.
  105466. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  105467. */
  105468. private _getReflectionTexture;
  105469. /**
  105470. * Returns an array of the actively used textures.
  105471. * @returns - Array of BaseTextures
  105472. */
  105473. getActiveTextures(): BaseTexture[];
  105474. /**
  105475. * Checks to see if a texture is used in the material.
  105476. * @param texture - Base texture to use.
  105477. * @returns - Boolean specifying if a texture is used in the material.
  105478. */
  105479. hasTexture(texture: BaseTexture): boolean;
  105480. /**
  105481. * Disposes the resources of the material.
  105482. * @param forceDisposeEffect - Forces the disposal of effects.
  105483. * @param forceDisposeTextures - Forces the disposal of all textures.
  105484. */
  105485. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105486. }
  105487. }
  105488. declare module BABYLON {
  105489. /**
  105490. * The Physically based material of BJS.
  105491. *
  105492. * This offers the main features of a standard PBR material.
  105493. * For more information, please refer to the documentation :
  105494. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  105495. */
  105496. export class PBRMaterial extends PBRBaseMaterial {
  105497. /**
  105498. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105499. */
  105500. static readonly PBRMATERIAL_OPAQUE: number;
  105501. /**
  105502. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105503. */
  105504. static readonly PBRMATERIAL_ALPHATEST: number;
  105505. /**
  105506. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105507. */
  105508. static readonly PBRMATERIAL_ALPHABLEND: number;
  105509. /**
  105510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105511. * They are also discarded below the alpha cutoff threshold to improve performances.
  105512. */
  105513. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  105514. /**
  105515. * Defines the default value of how much AO map is occluding the analytical lights
  105516. * (point spot...).
  105517. */
  105518. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  105519. /**
  105520. * Intensity of the direct lights e.g. the four lights available in your scene.
  105521. * This impacts both the direct diffuse and specular highlights.
  105522. */
  105523. directIntensity: number;
  105524. /**
  105525. * Intensity of the emissive part of the material.
  105526. * This helps controlling the emissive effect without modifying the emissive color.
  105527. */
  105528. emissiveIntensity: number;
  105529. /**
  105530. * Intensity of the environment e.g. how much the environment will light the object
  105531. * either through harmonics for rough material or through the refelction for shiny ones.
  105532. */
  105533. environmentIntensity: number;
  105534. /**
  105535. * This is a special control allowing the reduction of the specular highlights coming from the
  105536. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  105537. */
  105538. specularIntensity: number;
  105539. /**
  105540. * Debug Control allowing disabling the bump map on this material.
  105541. */
  105542. disableBumpMap: boolean;
  105543. /**
  105544. * AKA Diffuse Texture in standard nomenclature.
  105545. */
  105546. albedoTexture: BaseTexture;
  105547. /**
  105548. * AKA Occlusion Texture in other nomenclature.
  105549. */
  105550. ambientTexture: BaseTexture;
  105551. /**
  105552. * AKA Occlusion Texture Intensity in other nomenclature.
  105553. */
  105554. ambientTextureStrength: number;
  105555. /**
  105556. * Defines how much the AO map is occluding the analytical lights (point spot...).
  105557. * 1 means it completely occludes it
  105558. * 0 mean it has no impact
  105559. */
  105560. ambientTextureImpactOnAnalyticalLights: number;
  105561. /**
  105562. * Stores the alpha values in a texture.
  105563. */
  105564. opacityTexture: BaseTexture;
  105565. /**
  105566. * Stores the reflection values in a texture.
  105567. */
  105568. reflectionTexture: Nullable<BaseTexture>;
  105569. /**
  105570. * Stores the emissive values in a texture.
  105571. */
  105572. emissiveTexture: BaseTexture;
  105573. /**
  105574. * AKA Specular texture in other nomenclature.
  105575. */
  105576. reflectivityTexture: BaseTexture;
  105577. /**
  105578. * Used to switch from specular/glossiness to metallic/roughness workflow.
  105579. */
  105580. metallicTexture: BaseTexture;
  105581. /**
  105582. * Specifies the metallic scalar of the metallic/roughness workflow.
  105583. * Can also be used to scale the metalness values of the metallic texture.
  105584. */
  105585. metallic: Nullable<number>;
  105586. /**
  105587. * Specifies the roughness scalar of the metallic/roughness workflow.
  105588. * Can also be used to scale the roughness values of the metallic texture.
  105589. */
  105590. roughness: Nullable<number>;
  105591. /**
  105592. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  105593. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  105594. */
  105595. microSurfaceTexture: BaseTexture;
  105596. /**
  105597. * Stores surface normal data used to displace a mesh in a texture.
  105598. */
  105599. bumpTexture: BaseTexture;
  105600. /**
  105601. * Stores the pre-calculated light information of a mesh in a texture.
  105602. */
  105603. lightmapTexture: BaseTexture;
  105604. /**
  105605. * Stores the refracted light information in a texture.
  105606. */
  105607. refractionTexture: Nullable<BaseTexture>;
  105608. /**
  105609. * The color of a material in ambient lighting.
  105610. */
  105611. ambientColor: Color3;
  105612. /**
  105613. * AKA Diffuse Color in other nomenclature.
  105614. */
  105615. albedoColor: Color3;
  105616. /**
  105617. * AKA Specular Color in other nomenclature.
  105618. */
  105619. reflectivityColor: Color3;
  105620. /**
  105621. * The color reflected from the material.
  105622. */
  105623. reflectionColor: Color3;
  105624. /**
  105625. * The color emitted from the material.
  105626. */
  105627. emissiveColor: Color3;
  105628. /**
  105629. * AKA Glossiness in other nomenclature.
  105630. */
  105631. microSurface: number;
  105632. /**
  105633. * source material index of refraction (IOR)' / 'destination material IOR.
  105634. */
  105635. indexOfRefraction: number;
  105636. /**
  105637. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105638. */
  105639. invertRefractionY: boolean;
  105640. /**
  105641. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105642. * Materials half opaque for instance using refraction could benefit from this control.
  105643. */
  105644. linkRefractionWithTransparency: boolean;
  105645. /**
  105646. * If true, the light map contains occlusion information instead of lighting info.
  105647. */
  105648. useLightmapAsShadowmap: boolean;
  105649. /**
  105650. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  105651. */
  105652. useAlphaFromAlbedoTexture: boolean;
  105653. /**
  105654. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105655. */
  105656. forceAlphaTest: boolean;
  105657. /**
  105658. * Defines the alpha limits in alpha test mode.
  105659. */
  105660. alphaCutOff: number;
  105661. /**
  105662. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105663. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105664. */
  105665. useSpecularOverAlpha: boolean;
  105666. /**
  105667. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  105668. */
  105669. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  105670. /**
  105671. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105672. */
  105673. useRoughnessFromMetallicTextureAlpha: boolean;
  105674. /**
  105675. * Specifies if the metallic texture contains the roughness information in its green channel.
  105676. */
  105677. useRoughnessFromMetallicTextureGreen: boolean;
  105678. /**
  105679. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105680. */
  105681. useMetallnessFromMetallicTextureBlue: boolean;
  105682. /**
  105683. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105684. */
  105685. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105686. /**
  105687. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105688. */
  105689. useAmbientInGrayScale: boolean;
  105690. /**
  105691. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105692. * The material will try to infer what glossiness each pixel should be.
  105693. */
  105694. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105695. /**
  105696. * BJS is using an harcoded light falloff based on a manually sets up range.
  105697. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105698. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105699. */
  105700. /**
  105701. * BJS is using an harcoded light falloff based on a manually sets up range.
  105702. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105703. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105704. */
  105705. usePhysicalLightFalloff: boolean;
  105706. /**
  105707. * In order to support the falloff compatibility with gltf, a special mode has been added
  105708. * to reproduce the gltf light falloff.
  105709. */
  105710. /**
  105711. * In order to support the falloff compatibility with gltf, a special mode has been added
  105712. * to reproduce the gltf light falloff.
  105713. */
  105714. useGLTFLightFalloff: boolean;
  105715. /**
  105716. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105717. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105718. */
  105719. useRadianceOverAlpha: boolean;
  105720. /**
  105721. * Allows using an object space normal map (instead of tangent space).
  105722. */
  105723. useObjectSpaceNormalMap: boolean;
  105724. /**
  105725. * Allows using the bump map in parallax mode.
  105726. */
  105727. useParallax: boolean;
  105728. /**
  105729. * Allows using the bump map in parallax occlusion mode.
  105730. */
  105731. useParallaxOcclusion: boolean;
  105732. /**
  105733. * Controls the scale bias of the parallax mode.
  105734. */
  105735. parallaxScaleBias: number;
  105736. /**
  105737. * If sets to true, disables all the lights affecting the material.
  105738. */
  105739. disableLighting: boolean;
  105740. /**
  105741. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105742. */
  105743. forceIrradianceInFragment: boolean;
  105744. /**
  105745. * Number of Simultaneous lights allowed on the material.
  105746. */
  105747. maxSimultaneousLights: number;
  105748. /**
  105749. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105750. */
  105751. invertNormalMapX: boolean;
  105752. /**
  105753. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105754. */
  105755. invertNormalMapY: boolean;
  105756. /**
  105757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105758. */
  105759. twoSidedLighting: boolean;
  105760. /**
  105761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105762. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105763. */
  105764. useAlphaFresnel: boolean;
  105765. /**
  105766. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105767. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105768. */
  105769. useLinearAlphaFresnel: boolean;
  105770. /**
  105771. * Let user defines the brdf lookup texture used for IBL.
  105772. * A default 8bit version is embedded but you could point at :
  105773. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105774. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105775. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105776. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105777. */
  105778. environmentBRDFTexture: Nullable<BaseTexture>;
  105779. /**
  105780. * Force normal to face away from face.
  105781. */
  105782. forceNormalForward: boolean;
  105783. /**
  105784. * Enables specular anti aliasing in the PBR shader.
  105785. * It will both interacts on the Geometry for analytical and IBL lighting.
  105786. * It also prefilter the roughness map based on the bump values.
  105787. */
  105788. enableSpecularAntiAliasing: boolean;
  105789. /**
  105790. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105791. * makes the reflect vector face the model (under horizon).
  105792. */
  105793. useHorizonOcclusion: boolean;
  105794. /**
  105795. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105796. * too much the area relying on ambient texture to define their ambient occlusion.
  105797. */
  105798. useRadianceOcclusion: boolean;
  105799. /**
  105800. * If set to true, no lighting calculations will be applied.
  105801. */
  105802. unlit: boolean;
  105803. /**
  105804. * Gets the image processing configuration used either in this material.
  105805. */
  105806. /**
  105807. * Sets the Default image processing configuration used either in the this material.
  105808. *
  105809. * If sets to null, the scene one is in use.
  105810. */
  105811. imageProcessingConfiguration: ImageProcessingConfiguration;
  105812. /**
  105813. * Gets wether the color curves effect is enabled.
  105814. */
  105815. /**
  105816. * Sets wether the color curves effect is enabled.
  105817. */
  105818. cameraColorCurvesEnabled: boolean;
  105819. /**
  105820. * Gets wether the color grading effect is enabled.
  105821. */
  105822. /**
  105823. * Gets wether the color grading effect is enabled.
  105824. */
  105825. cameraColorGradingEnabled: boolean;
  105826. /**
  105827. * Gets wether tonemapping is enabled or not.
  105828. */
  105829. /**
  105830. * Sets wether tonemapping is enabled or not
  105831. */
  105832. cameraToneMappingEnabled: boolean;
  105833. /**
  105834. * The camera exposure used on this material.
  105835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105836. * This corresponds to a photographic exposure.
  105837. */
  105838. /**
  105839. * The camera exposure used on this material.
  105840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105841. * This corresponds to a photographic exposure.
  105842. */
  105843. cameraExposure: number;
  105844. /**
  105845. * Gets The camera contrast used on this material.
  105846. */
  105847. /**
  105848. * Sets The camera contrast used on this material.
  105849. */
  105850. cameraContrast: number;
  105851. /**
  105852. * Gets the Color Grading 2D Lookup Texture.
  105853. */
  105854. /**
  105855. * Sets the Color Grading 2D Lookup Texture.
  105856. */
  105857. cameraColorGradingTexture: Nullable<BaseTexture>;
  105858. /**
  105859. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105860. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105861. * 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;
  105862. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105863. */
  105864. /**
  105865. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105866. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105867. * 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;
  105868. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105869. */
  105870. cameraColorCurves: Nullable<ColorCurves>;
  105871. /**
  105872. * Instantiates a new PBRMaterial instance.
  105873. *
  105874. * @param name The material name
  105875. * @param scene The scene the material will be use in.
  105876. */
  105877. constructor(name: string, scene: Scene);
  105878. /**
  105879. * Returns the name of this material class.
  105880. */
  105881. getClassName(): string;
  105882. /**
  105883. * Makes a duplicate of the current material.
  105884. * @param name - name to use for the new material.
  105885. */
  105886. clone(name: string): PBRMaterial;
  105887. /**
  105888. * Serializes this PBR Material.
  105889. * @returns - An object with the serialized material.
  105890. */
  105891. serialize(): any;
  105892. /**
  105893. * Parses a PBR Material from a serialized object.
  105894. * @param source - Serialized object.
  105895. * @param scene - BJS scene instance.
  105896. * @param rootUrl - url for the scene object
  105897. * @returns - PBRMaterial
  105898. */
  105899. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105900. }
  105901. }
  105902. declare module BABYLON {
  105903. /**
  105904. * Direct draw surface info
  105905. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105906. */
  105907. export interface DDSInfo {
  105908. /**
  105909. * Width of the texture
  105910. */
  105911. width: number;
  105912. /**
  105913. * Width of the texture
  105914. */
  105915. height: number;
  105916. /**
  105917. * Number of Mipmaps for the texture
  105918. * @see https://en.wikipedia.org/wiki/Mipmap
  105919. */
  105920. mipmapCount: number;
  105921. /**
  105922. * If the textures format is a known fourCC format
  105923. * @see https://www.fourcc.org/
  105924. */
  105925. isFourCC: boolean;
  105926. /**
  105927. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105928. */
  105929. isRGB: boolean;
  105930. /**
  105931. * If the texture is a lumincance format
  105932. */
  105933. isLuminance: boolean;
  105934. /**
  105935. * If this is a cube texture
  105936. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105937. */
  105938. isCube: boolean;
  105939. /**
  105940. * If the texture is a compressed format eg. FOURCC_DXT1
  105941. */
  105942. isCompressed: boolean;
  105943. /**
  105944. * The dxgiFormat of the texture
  105945. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105946. */
  105947. dxgiFormat: number;
  105948. /**
  105949. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105950. */
  105951. textureType: number;
  105952. /**
  105953. * Sphericle polynomial created for the dds texture
  105954. */
  105955. sphericalPolynomial?: SphericalPolynomial;
  105956. }
  105957. /**
  105958. * Class used to provide DDS decompression tools
  105959. */
  105960. export class DDSTools {
  105961. /**
  105962. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105963. */
  105964. static StoreLODInAlphaChannel: boolean;
  105965. /**
  105966. * Gets DDS information from an array buffer
  105967. * @param arrayBuffer defines the array buffer to read data from
  105968. * @returns the DDS information
  105969. */
  105970. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105971. private static _FloatView;
  105972. private static _Int32View;
  105973. private static _ToHalfFloat;
  105974. private static _FromHalfFloat;
  105975. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105976. private static _GetHalfFloatRGBAArrayBuffer;
  105977. private static _GetFloatRGBAArrayBuffer;
  105978. private static _GetFloatAsUIntRGBAArrayBuffer;
  105979. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105980. private static _GetRGBAArrayBuffer;
  105981. private static _ExtractLongWordOrder;
  105982. private static _GetRGBArrayBuffer;
  105983. private static _GetLuminanceArrayBuffer;
  105984. /**
  105985. * Uploads DDS Levels to a Babylon Texture
  105986. * @hidden
  105987. */
  105988. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105989. }
  105990. interface Engine {
  105991. /**
  105992. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105993. * @param rootUrl defines the url where the file to load is located
  105994. * @param scene defines the current scene
  105995. * @param lodScale defines scale to apply to the mip map selection
  105996. * @param lodOffset defines offset to apply to the mip map selection
  105997. * @param onLoad defines an optional callback raised when the texture is loaded
  105998. * @param onError defines an optional callback raised if there is an issue to load the texture
  105999. * @param format defines the format of the data
  106000. * @param forcedExtension defines the extension to use to pick the right loader
  106001. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  106002. * @returns the cube texture as an InternalTexture
  106003. */
  106004. 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;
  106005. }
  106006. }
  106007. declare module BABYLON {
  106008. /**
  106009. * Implementation of the DDS Texture Loader.
  106010. * @hidden
  106011. */
  106012. export class _DDSTextureLoader implements IInternalTextureLoader {
  106013. /**
  106014. * Defines wether the loader supports cascade loading the different faces.
  106015. */
  106016. readonly supportCascades: boolean;
  106017. /**
  106018. * This returns if the loader support the current file information.
  106019. * @param extension defines the file extension of the file being loaded
  106020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106021. * @param fallback defines the fallback internal texture if any
  106022. * @param isBase64 defines whether the texture is encoded as a base64
  106023. * @param isBuffer defines whether the texture data are stored as a buffer
  106024. * @returns true if the loader can load the specified file
  106025. */
  106026. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106027. /**
  106028. * Transform the url before loading if required.
  106029. * @param rootUrl the url of the texture
  106030. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106031. * @returns the transformed texture
  106032. */
  106033. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106034. /**
  106035. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106036. * @param rootUrl the url of the texture
  106037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106038. * @returns the fallback texture
  106039. */
  106040. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106041. /**
  106042. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106043. * @param data contains the texture data
  106044. * @param texture defines the BabylonJS internal texture
  106045. * @param createPolynomials will be true if polynomials have been requested
  106046. * @param onLoad defines the callback to trigger once the texture is ready
  106047. * @param onError defines the callback to trigger in case of error
  106048. */
  106049. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106050. /**
  106051. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106052. * @param data contains the texture data
  106053. * @param texture defines the BabylonJS internal texture
  106054. * @param callback defines the method to call once ready to upload
  106055. */
  106056. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106057. }
  106058. }
  106059. declare module BABYLON {
  106060. /** @hidden */
  106061. export var rgbdEncodePixelShader: {
  106062. name: string;
  106063. shader: string;
  106064. };
  106065. }
  106066. declare module BABYLON {
  106067. /**
  106068. * Raw texture data and descriptor sufficient for WebGL texture upload
  106069. */
  106070. export interface EnvironmentTextureInfo {
  106071. /**
  106072. * Version of the environment map
  106073. */
  106074. version: number;
  106075. /**
  106076. * Width of image
  106077. */
  106078. width: number;
  106079. /**
  106080. * Irradiance information stored in the file.
  106081. */
  106082. irradiance: any;
  106083. /**
  106084. * Specular information stored in the file.
  106085. */
  106086. specular: any;
  106087. }
  106088. /**
  106089. * Sets of helpers addressing the serialization and deserialization of environment texture
  106090. * stored in a BabylonJS env file.
  106091. * Those files are usually stored as .env files.
  106092. */
  106093. export class EnvironmentTextureTools {
  106094. /**
  106095. * Magic number identifying the env file.
  106096. */
  106097. private static _MagicBytes;
  106098. /**
  106099. * Gets the environment info from an env file.
  106100. * @param data The array buffer containing the .env bytes.
  106101. * @returns the environment file info (the json header) if successfully parsed.
  106102. */
  106103. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  106104. /**
  106105. * Creates an environment texture from a loaded cube texture.
  106106. * @param texture defines the cube texture to convert in env file
  106107. * @return a promise containing the environment data if succesfull.
  106108. */
  106109. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  106110. /**
  106111. * Creates a JSON representation of the spherical data.
  106112. * @param texture defines the texture containing the polynomials
  106113. * @return the JSON representation of the spherical info
  106114. */
  106115. private static _CreateEnvTextureIrradiance;
  106116. /**
  106117. * Uploads the texture info contained in the env file to the GPU.
  106118. * @param texture defines the internal texture to upload to
  106119. * @param arrayBuffer defines the buffer cotaining the data to load
  106120. * @param info defines the texture info retrieved through the GetEnvInfo method
  106121. * @returns a promise
  106122. */
  106123. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  106124. /**
  106125. * Uploads the levels of image data to the GPU.
  106126. * @param texture defines the internal texture to upload to
  106127. * @param imageData defines the array buffer views of image data [mipmap][face]
  106128. * @returns a promise
  106129. */
  106130. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  106131. /**
  106132. * Uploads spherical polynomials information to the texture.
  106133. * @param texture defines the texture we are trying to upload the information to
  106134. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  106135. */
  106136. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  106137. /** @hidden */
  106138. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106139. }
  106140. }
  106141. declare module BABYLON {
  106142. /**
  106143. * Implementation of the ENV Texture Loader.
  106144. * @hidden
  106145. */
  106146. export class _ENVTextureLoader implements IInternalTextureLoader {
  106147. /**
  106148. * Defines wether the loader supports cascade loading the different faces.
  106149. */
  106150. readonly supportCascades: boolean;
  106151. /**
  106152. * This returns if the loader support the current file information.
  106153. * @param extension defines the file extension of the file being loaded
  106154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106155. * @param fallback defines the fallback internal texture if any
  106156. * @param isBase64 defines whether the texture is encoded as a base64
  106157. * @param isBuffer defines whether the texture data are stored as a buffer
  106158. * @returns true if the loader can load the specified file
  106159. */
  106160. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106161. /**
  106162. * Transform the url before loading if required.
  106163. * @param rootUrl the url of the texture
  106164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106165. * @returns the transformed texture
  106166. */
  106167. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106168. /**
  106169. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106170. * @param rootUrl the url of the texture
  106171. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106172. * @returns the fallback texture
  106173. */
  106174. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106175. /**
  106176. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106177. * @param data contains the texture data
  106178. * @param texture defines the BabylonJS internal texture
  106179. * @param createPolynomials will be true if polynomials have been requested
  106180. * @param onLoad defines the callback to trigger once the texture is ready
  106181. * @param onError defines the callback to trigger in case of error
  106182. */
  106183. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106184. /**
  106185. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106186. * @param data contains the texture data
  106187. * @param texture defines the BabylonJS internal texture
  106188. * @param callback defines the method to call once ready to upload
  106189. */
  106190. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106191. }
  106192. }
  106193. declare module BABYLON {
  106194. /**
  106195. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106196. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106197. */
  106198. export class KhronosTextureContainer {
  106199. /** contents of the KTX container file */
  106200. arrayBuffer: any;
  106201. private static HEADER_LEN;
  106202. private static COMPRESSED_2D;
  106203. private static COMPRESSED_3D;
  106204. private static TEX_2D;
  106205. private static TEX_3D;
  106206. /**
  106207. * Gets the openGL type
  106208. */
  106209. glType: number;
  106210. /**
  106211. * Gets the openGL type size
  106212. */
  106213. glTypeSize: number;
  106214. /**
  106215. * Gets the openGL format
  106216. */
  106217. glFormat: number;
  106218. /**
  106219. * Gets the openGL internal format
  106220. */
  106221. glInternalFormat: number;
  106222. /**
  106223. * Gets the base internal format
  106224. */
  106225. glBaseInternalFormat: number;
  106226. /**
  106227. * Gets image width in pixel
  106228. */
  106229. pixelWidth: number;
  106230. /**
  106231. * Gets image height in pixel
  106232. */
  106233. pixelHeight: number;
  106234. /**
  106235. * Gets image depth in pixels
  106236. */
  106237. pixelDepth: number;
  106238. /**
  106239. * Gets the number of array elements
  106240. */
  106241. numberOfArrayElements: number;
  106242. /**
  106243. * Gets the number of faces
  106244. */
  106245. numberOfFaces: number;
  106246. /**
  106247. * Gets the number of mipmap levels
  106248. */
  106249. numberOfMipmapLevels: number;
  106250. /**
  106251. * Gets the bytes of key value data
  106252. */
  106253. bytesOfKeyValueData: number;
  106254. /**
  106255. * Gets the load type
  106256. */
  106257. loadType: number;
  106258. /**
  106259. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  106260. */
  106261. isInvalid: boolean;
  106262. /**
  106263. * Creates a new KhronosTextureContainer
  106264. * @param arrayBuffer contents of the KTX container file
  106265. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  106266. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  106267. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  106268. */
  106269. constructor(
  106270. /** contents of the KTX container file */
  106271. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  106272. /**
  106273. * Uploads KTX content to a Babylon Texture.
  106274. * It is assumed that the texture has already been created & is currently bound
  106275. * @hidden
  106276. */
  106277. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  106278. private _upload2DCompressedLevels;
  106279. }
  106280. }
  106281. declare module BABYLON {
  106282. /**
  106283. * Implementation of the KTX Texture Loader.
  106284. * @hidden
  106285. */
  106286. export class _KTXTextureLoader implements IInternalTextureLoader {
  106287. /**
  106288. * Defines wether the loader supports cascade loading the different faces.
  106289. */
  106290. readonly supportCascades: boolean;
  106291. /**
  106292. * This returns if the loader support the current file information.
  106293. * @param extension defines the file extension of the file being loaded
  106294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106295. * @param fallback defines the fallback internal texture if any
  106296. * @param isBase64 defines whether the texture is encoded as a base64
  106297. * @param isBuffer defines whether the texture data are stored as a buffer
  106298. * @returns true if the loader can load the specified file
  106299. */
  106300. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106301. /**
  106302. * Transform the url before loading if required.
  106303. * @param rootUrl the url of the texture
  106304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106305. * @returns the transformed texture
  106306. */
  106307. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106308. /**
  106309. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106310. * @param rootUrl the url of the texture
  106311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106312. * @returns the fallback texture
  106313. */
  106314. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106315. /**
  106316. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106317. * @param data contains the texture data
  106318. * @param texture defines the BabylonJS internal texture
  106319. * @param createPolynomials will be true if polynomials have been requested
  106320. * @param onLoad defines the callback to trigger once the texture is ready
  106321. * @param onError defines the callback to trigger in case of error
  106322. */
  106323. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106324. /**
  106325. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106326. * @param data contains the texture data
  106327. * @param texture defines the BabylonJS internal texture
  106328. * @param callback defines the method to call once ready to upload
  106329. */
  106330. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  106331. }
  106332. }
  106333. declare module BABYLON {
  106334. /** @hidden */
  106335. export var _forceSceneHelpersToBundle: boolean;
  106336. interface Scene {
  106337. /**
  106338. * Creates a default light for the scene.
  106339. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  106340. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  106341. */
  106342. createDefaultLight(replace?: boolean): void;
  106343. /**
  106344. * Creates a default camera for the scene.
  106345. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  106346. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106347. * @param replace has default false, when true replaces the active camera in the scene
  106348. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  106349. */
  106350. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106351. /**
  106352. * Creates a default camera and a default light.
  106353. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  106354. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  106355. * @param replace has the default false, when true replaces the active camera/light in the scene
  106356. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  106357. */
  106358. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  106359. /**
  106360. * Creates a new sky box
  106361. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  106362. * @param environmentTexture defines the texture to use as environment texture
  106363. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  106364. * @param scale defines the overall scale of the skybox
  106365. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  106366. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  106367. * @returns a new mesh holding the sky box
  106368. */
  106369. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  106370. /**
  106371. * Creates a new environment
  106372. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  106373. * @param options defines the options you can use to configure the environment
  106374. * @returns the new EnvironmentHelper
  106375. */
  106376. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  106377. /**
  106378. * Creates a new VREXperienceHelper
  106379. * @see http://doc.babylonjs.com/how_to/webvr_helper
  106380. * @param webVROptions defines the options used to create the new VREXperienceHelper
  106381. * @returns a new VREXperienceHelper
  106382. */
  106383. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  106384. /**
  106385. * Creates a new XREXperienceHelper
  106386. * @see http://doc.babylonjs.com/how_to/webxr
  106387. * @returns a promise for a new XREXperienceHelper
  106388. */
  106389. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  106390. }
  106391. }
  106392. declare module BABYLON {
  106393. /**
  106394. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  106395. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  106396. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  106397. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106398. */
  106399. export class VideoDome extends TransformNode {
  106400. /**
  106401. * Define the video source as a Monoscopic panoramic 360 video.
  106402. */
  106403. static readonly MODE_MONOSCOPIC: number;
  106404. /**
  106405. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106406. */
  106407. static readonly MODE_TOPBOTTOM: number;
  106408. /**
  106409. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106410. */
  106411. static readonly MODE_SIDEBYSIDE: number;
  106412. private _useDirectMapping;
  106413. /**
  106414. * The video texture being displayed on the sphere
  106415. */
  106416. protected _videoTexture: VideoTexture;
  106417. /**
  106418. * Gets the video texture being displayed on the sphere
  106419. */
  106420. readonly videoTexture: VideoTexture;
  106421. /**
  106422. * The skybox material
  106423. */
  106424. protected _material: BackgroundMaterial;
  106425. /**
  106426. * The surface used for the skybox
  106427. */
  106428. protected _mesh: Mesh;
  106429. /**
  106430. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106431. * Also see the options.resolution property.
  106432. */
  106433. fovMultiplier: number;
  106434. private _videoMode;
  106435. /**
  106436. * Gets or set the current video mode for the video. It can be:
  106437. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  106438. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  106439. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  106440. */
  106441. videoMode: number;
  106442. /**
  106443. * Oberserver used in Stereoscopic VR Mode.
  106444. */
  106445. private _onBeforeCameraRenderObserver;
  106446. /**
  106447. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  106448. * @param name Element's name, child elements will append suffixes for their own names.
  106449. * @param urlsOrVideo defines the url(s) or the video element to use
  106450. * @param options An object containing optional or exposed sub element properties
  106451. */
  106452. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  106453. resolution?: number;
  106454. clickToPlay?: boolean;
  106455. autoPlay?: boolean;
  106456. loop?: boolean;
  106457. size?: number;
  106458. poster?: string;
  106459. faceForward?: boolean;
  106460. useDirectMapping?: boolean;
  106461. }, scene: Scene);
  106462. private _changeVideoMode;
  106463. /**
  106464. * Releases resources associated with this node.
  106465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106467. */
  106468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106469. }
  106470. }
  106471. declare module BABYLON {
  106472. /**
  106473. * This class can be used to get instrumentation data from a Babylon engine
  106474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106475. */
  106476. export class EngineInstrumentation implements IDisposable {
  106477. /**
  106478. * Define the instrumented engine.
  106479. */
  106480. engine: Engine;
  106481. private _captureGPUFrameTime;
  106482. private _gpuFrameTimeToken;
  106483. private _gpuFrameTime;
  106484. private _captureShaderCompilationTime;
  106485. private _shaderCompilationTime;
  106486. private _onBeginFrameObserver;
  106487. private _onEndFrameObserver;
  106488. private _onBeforeShaderCompilationObserver;
  106489. private _onAfterShaderCompilationObserver;
  106490. /**
  106491. * Gets the perf counter used for GPU frame time
  106492. */
  106493. readonly gpuFrameTimeCounter: PerfCounter;
  106494. /**
  106495. * Gets the GPU frame time capture status
  106496. */
  106497. /**
  106498. * Enable or disable the GPU frame time capture
  106499. */
  106500. captureGPUFrameTime: boolean;
  106501. /**
  106502. * Gets the perf counter used for shader compilation time
  106503. */
  106504. readonly shaderCompilationTimeCounter: PerfCounter;
  106505. /**
  106506. * Gets the shader compilation time capture status
  106507. */
  106508. /**
  106509. * Enable or disable the shader compilation time capture
  106510. */
  106511. captureShaderCompilationTime: boolean;
  106512. /**
  106513. * Instantiates a new engine instrumentation.
  106514. * This class can be used to get instrumentation data from a Babylon engine
  106515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106516. * @param engine Defines the engine to instrument
  106517. */
  106518. constructor(
  106519. /**
  106520. * Define the instrumented engine.
  106521. */
  106522. engine: Engine);
  106523. /**
  106524. * Dispose and release associated resources.
  106525. */
  106526. dispose(): void;
  106527. }
  106528. }
  106529. declare module BABYLON {
  106530. /**
  106531. * This class can be used to get instrumentation data from a Babylon engine
  106532. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106533. */
  106534. export class SceneInstrumentation implements IDisposable {
  106535. /**
  106536. * Defines the scene to instrument
  106537. */
  106538. scene: Scene;
  106539. private _captureActiveMeshesEvaluationTime;
  106540. private _activeMeshesEvaluationTime;
  106541. private _captureRenderTargetsRenderTime;
  106542. private _renderTargetsRenderTime;
  106543. private _captureFrameTime;
  106544. private _frameTime;
  106545. private _captureRenderTime;
  106546. private _renderTime;
  106547. private _captureInterFrameTime;
  106548. private _interFrameTime;
  106549. private _captureParticlesRenderTime;
  106550. private _particlesRenderTime;
  106551. private _captureSpritesRenderTime;
  106552. private _spritesRenderTime;
  106553. private _capturePhysicsTime;
  106554. private _physicsTime;
  106555. private _captureAnimationsTime;
  106556. private _animationsTime;
  106557. private _captureCameraRenderTime;
  106558. private _cameraRenderTime;
  106559. private _onBeforeActiveMeshesEvaluationObserver;
  106560. private _onAfterActiveMeshesEvaluationObserver;
  106561. private _onBeforeRenderTargetsRenderObserver;
  106562. private _onAfterRenderTargetsRenderObserver;
  106563. private _onAfterRenderObserver;
  106564. private _onBeforeDrawPhaseObserver;
  106565. private _onAfterDrawPhaseObserver;
  106566. private _onBeforeAnimationsObserver;
  106567. private _onBeforeParticlesRenderingObserver;
  106568. private _onAfterParticlesRenderingObserver;
  106569. private _onBeforeSpritesRenderingObserver;
  106570. private _onAfterSpritesRenderingObserver;
  106571. private _onBeforePhysicsObserver;
  106572. private _onAfterPhysicsObserver;
  106573. private _onAfterAnimationsObserver;
  106574. private _onBeforeCameraRenderObserver;
  106575. private _onAfterCameraRenderObserver;
  106576. /**
  106577. * Gets the perf counter used for active meshes evaluation time
  106578. */
  106579. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  106580. /**
  106581. * Gets the active meshes evaluation time capture status
  106582. */
  106583. /**
  106584. * Enable or disable the active meshes evaluation time capture
  106585. */
  106586. captureActiveMeshesEvaluationTime: boolean;
  106587. /**
  106588. * Gets the perf counter used for render targets render time
  106589. */
  106590. readonly renderTargetsRenderTimeCounter: PerfCounter;
  106591. /**
  106592. * Gets the render targets render time capture status
  106593. */
  106594. /**
  106595. * Enable or disable the render targets render time capture
  106596. */
  106597. captureRenderTargetsRenderTime: boolean;
  106598. /**
  106599. * Gets the perf counter used for particles render time
  106600. */
  106601. readonly particlesRenderTimeCounter: PerfCounter;
  106602. /**
  106603. * Gets the particles render time capture status
  106604. */
  106605. /**
  106606. * Enable or disable the particles render time capture
  106607. */
  106608. captureParticlesRenderTime: boolean;
  106609. /**
  106610. * Gets the perf counter used for sprites render time
  106611. */
  106612. readonly spritesRenderTimeCounter: PerfCounter;
  106613. /**
  106614. * Gets the sprites render time capture status
  106615. */
  106616. /**
  106617. * Enable or disable the sprites render time capture
  106618. */
  106619. captureSpritesRenderTime: boolean;
  106620. /**
  106621. * Gets the perf counter used for physics time
  106622. */
  106623. readonly physicsTimeCounter: PerfCounter;
  106624. /**
  106625. * Gets the physics time capture status
  106626. */
  106627. /**
  106628. * Enable or disable the physics time capture
  106629. */
  106630. capturePhysicsTime: boolean;
  106631. /**
  106632. * Gets the perf counter used for animations time
  106633. */
  106634. readonly animationsTimeCounter: PerfCounter;
  106635. /**
  106636. * Gets the animations time capture status
  106637. */
  106638. /**
  106639. * Enable or disable the animations time capture
  106640. */
  106641. captureAnimationsTime: boolean;
  106642. /**
  106643. * Gets the perf counter used for frame time capture
  106644. */
  106645. readonly frameTimeCounter: PerfCounter;
  106646. /**
  106647. * Gets the frame time capture status
  106648. */
  106649. /**
  106650. * Enable or disable the frame time capture
  106651. */
  106652. captureFrameTime: boolean;
  106653. /**
  106654. * Gets the perf counter used for inter-frames time capture
  106655. */
  106656. readonly interFrameTimeCounter: PerfCounter;
  106657. /**
  106658. * Gets the inter-frames time capture status
  106659. */
  106660. /**
  106661. * Enable or disable the inter-frames time capture
  106662. */
  106663. captureInterFrameTime: boolean;
  106664. /**
  106665. * Gets the perf counter used for render time capture
  106666. */
  106667. readonly renderTimeCounter: PerfCounter;
  106668. /**
  106669. * Gets the render time capture status
  106670. */
  106671. /**
  106672. * Enable or disable the render time capture
  106673. */
  106674. captureRenderTime: boolean;
  106675. /**
  106676. * Gets the perf counter used for camera render time capture
  106677. */
  106678. readonly cameraRenderTimeCounter: PerfCounter;
  106679. /**
  106680. * Gets the camera render time capture status
  106681. */
  106682. /**
  106683. * Enable or disable the camera render time capture
  106684. */
  106685. captureCameraRenderTime: boolean;
  106686. /**
  106687. * Gets the perf counter used for draw calls
  106688. */
  106689. readonly drawCallsCounter: PerfCounter;
  106690. /**
  106691. * Instantiates a new scene instrumentation.
  106692. * This class can be used to get instrumentation data from a Babylon engine
  106693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106694. * @param scene Defines the scene to instrument
  106695. */
  106696. constructor(
  106697. /**
  106698. * Defines the scene to instrument
  106699. */
  106700. scene: Scene);
  106701. /**
  106702. * Dispose and release associated resources.
  106703. */
  106704. dispose(): void;
  106705. }
  106706. }
  106707. declare module BABYLON {
  106708. /** @hidden */
  106709. export var glowMapGenerationPixelShader: {
  106710. name: string;
  106711. shader: string;
  106712. };
  106713. }
  106714. declare module BABYLON {
  106715. /** @hidden */
  106716. export var glowMapGenerationVertexShader: {
  106717. name: string;
  106718. shader: string;
  106719. };
  106720. }
  106721. declare module BABYLON {
  106722. /**
  106723. * Effect layer options. This helps customizing the behaviour
  106724. * of the effect layer.
  106725. */
  106726. export interface IEffectLayerOptions {
  106727. /**
  106728. * Multiplication factor apply to the canvas size to compute the render target size
  106729. * used to generated the objects (the smaller the faster).
  106730. */
  106731. mainTextureRatio: number;
  106732. /**
  106733. * Enforces a fixed size texture to ensure effect stability across devices.
  106734. */
  106735. mainTextureFixedSize?: number;
  106736. /**
  106737. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106738. */
  106739. alphaBlendingMode: number;
  106740. /**
  106741. * The camera attached to the layer.
  106742. */
  106743. camera: Nullable<Camera>;
  106744. /**
  106745. * The rendering group to draw the layer in.
  106746. */
  106747. renderingGroupId: number;
  106748. }
  106749. /**
  106750. * The effect layer Helps adding post process effect blended with the main pass.
  106751. *
  106752. * This can be for instance use to generate glow or higlight effects on the scene.
  106753. *
  106754. * The effect layer class can not be used directly and is intented to inherited from to be
  106755. * customized per effects.
  106756. */
  106757. export abstract class EffectLayer {
  106758. private _vertexBuffers;
  106759. private _indexBuffer;
  106760. private _cachedDefines;
  106761. private _effectLayerMapGenerationEffect;
  106762. private _effectLayerOptions;
  106763. private _mergeEffect;
  106764. protected _scene: Scene;
  106765. protected _engine: Engine;
  106766. protected _maxSize: number;
  106767. protected _mainTextureDesiredSize: ISize;
  106768. protected _mainTexture: RenderTargetTexture;
  106769. protected _shouldRender: boolean;
  106770. protected _postProcesses: PostProcess[];
  106771. protected _textures: BaseTexture[];
  106772. protected _emissiveTextureAndColor: {
  106773. texture: Nullable<BaseTexture>;
  106774. color: Color4;
  106775. };
  106776. /**
  106777. * The name of the layer
  106778. */
  106779. name: string;
  106780. /**
  106781. * The clear color of the texture used to generate the glow map.
  106782. */
  106783. neutralColor: Color4;
  106784. /**
  106785. * Specifies wether the highlight layer is enabled or not.
  106786. */
  106787. isEnabled: boolean;
  106788. /**
  106789. * Gets the camera attached to the layer.
  106790. */
  106791. readonly camera: Nullable<Camera>;
  106792. /**
  106793. * Gets the rendering group id the layer should render in.
  106794. */
  106795. readonly renderingGroupId: number;
  106796. /**
  106797. * An event triggered when the effect layer has been disposed.
  106798. */
  106799. onDisposeObservable: Observable<EffectLayer>;
  106800. /**
  106801. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106802. */
  106803. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106804. /**
  106805. * An event triggered when the generated texture is being merged in the scene.
  106806. */
  106807. onBeforeComposeObservable: Observable<EffectLayer>;
  106808. /**
  106809. * An event triggered when the generated texture has been merged in the scene.
  106810. */
  106811. onAfterComposeObservable: Observable<EffectLayer>;
  106812. /**
  106813. * An event triggered when the efffect layer changes its size.
  106814. */
  106815. onSizeChangedObservable: Observable<EffectLayer>;
  106816. /** @hidden */
  106817. static _SceneComponentInitialization: (scene: Scene) => void;
  106818. /**
  106819. * Instantiates a new effect Layer and references it in the scene.
  106820. * @param name The name of the layer
  106821. * @param scene The scene to use the layer in
  106822. */
  106823. constructor(
  106824. /** The Friendly of the effect in the scene */
  106825. name: string, scene: Scene);
  106826. /**
  106827. * Get the effect name of the layer.
  106828. * @return The effect name
  106829. */
  106830. abstract getEffectName(): string;
  106831. /**
  106832. * Checks for the readiness of the element composing the layer.
  106833. * @param subMesh the mesh to check for
  106834. * @param useInstances specify wether or not to use instances to render the mesh
  106835. * @return true if ready otherwise, false
  106836. */
  106837. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106838. /**
  106839. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106840. * @returns true if the effect requires stencil during the main canvas render pass.
  106841. */
  106842. abstract needStencil(): boolean;
  106843. /**
  106844. * Create the merge effect. This is the shader use to blit the information back
  106845. * to the main canvas at the end of the scene rendering.
  106846. * @returns The effect containing the shader used to merge the effect on the main canvas
  106847. */
  106848. protected abstract _createMergeEffect(): Effect;
  106849. /**
  106850. * Creates the render target textures and post processes used in the effect layer.
  106851. */
  106852. protected abstract _createTextureAndPostProcesses(): void;
  106853. /**
  106854. * Implementation specific of rendering the generating effect on the main canvas.
  106855. * @param effect The effect used to render through
  106856. */
  106857. protected abstract _internalRender(effect: Effect): void;
  106858. /**
  106859. * Sets the required values for both the emissive texture and and the main color.
  106860. */
  106861. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106862. /**
  106863. * Free any resources and references associated to a mesh.
  106864. * Internal use
  106865. * @param mesh The mesh to free.
  106866. */
  106867. abstract _disposeMesh(mesh: Mesh): void;
  106868. /**
  106869. * Serializes this layer (Glow or Highlight for example)
  106870. * @returns a serialized layer object
  106871. */
  106872. abstract serialize?(): any;
  106873. /**
  106874. * Initializes the effect layer with the required options.
  106875. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106876. */
  106877. protected _init(options: Partial<IEffectLayerOptions>): void;
  106878. /**
  106879. * Generates the index buffer of the full screen quad blending to the main canvas.
  106880. */
  106881. private _generateIndexBuffer;
  106882. /**
  106883. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106884. */
  106885. private _generateVertexBuffer;
  106886. /**
  106887. * Sets the main texture desired size which is the closest power of two
  106888. * of the engine canvas size.
  106889. */
  106890. private _setMainTextureSize;
  106891. /**
  106892. * Creates the main texture for the effect layer.
  106893. */
  106894. protected _createMainTexture(): void;
  106895. /**
  106896. * Adds specific effects defines.
  106897. * @param defines The defines to add specifics to.
  106898. */
  106899. protected _addCustomEffectDefines(defines: string[]): void;
  106900. /**
  106901. * Checks for the readiness of the element composing the layer.
  106902. * @param subMesh the mesh to check for
  106903. * @param useInstances specify wether or not to use instances to render the mesh
  106904. * @param emissiveTexture the associated emissive texture used to generate the glow
  106905. * @return true if ready otherwise, false
  106906. */
  106907. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106908. /**
  106909. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106910. */
  106911. render(): void;
  106912. /**
  106913. * Determine if a given mesh will be used in the current effect.
  106914. * @param mesh mesh to test
  106915. * @returns true if the mesh will be used
  106916. */
  106917. hasMesh(mesh: AbstractMesh): boolean;
  106918. /**
  106919. * Returns true if the layer contains information to display, otherwise false.
  106920. * @returns true if the glow layer should be rendered
  106921. */
  106922. shouldRender(): boolean;
  106923. /**
  106924. * Returns true if the mesh should render, otherwise false.
  106925. * @param mesh The mesh to render
  106926. * @returns true if it should render otherwise false
  106927. */
  106928. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106929. /**
  106930. * Returns true if the mesh can be rendered, otherwise false.
  106931. * @param mesh The mesh to render
  106932. * @param material The material used on the mesh
  106933. * @returns true if it can be rendered otherwise false
  106934. */
  106935. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106936. /**
  106937. * Returns true if the mesh should render, otherwise false.
  106938. * @param mesh The mesh to render
  106939. * @returns true if it should render otherwise false
  106940. */
  106941. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106942. /**
  106943. * Renders the submesh passed in parameter to the generation map.
  106944. */
  106945. protected _renderSubMesh(subMesh: SubMesh): void;
  106946. /**
  106947. * Rebuild the required buffers.
  106948. * @hidden Internal use only.
  106949. */
  106950. _rebuild(): void;
  106951. /**
  106952. * Dispose only the render target textures and post process.
  106953. */
  106954. private _disposeTextureAndPostProcesses;
  106955. /**
  106956. * Dispose the highlight layer and free resources.
  106957. */
  106958. dispose(): void;
  106959. /**
  106960. * Gets the class name of the effect layer
  106961. * @returns the string with the class name of the effect layer
  106962. */
  106963. getClassName(): string;
  106964. /**
  106965. * Creates an effect layer from parsed effect layer data
  106966. * @param parsedEffectLayer defines effect layer data
  106967. * @param scene defines the current scene
  106968. * @param rootUrl defines the root URL containing the effect layer information
  106969. * @returns a parsed effect Layer
  106970. */
  106971. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106972. }
  106973. }
  106974. declare module BABYLON {
  106975. interface AbstractScene {
  106976. /**
  106977. * The list of effect layers (highlights/glow) added to the scene
  106978. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106979. * @see http://doc.babylonjs.com/how_to/glow_layer
  106980. */
  106981. effectLayers: Array<EffectLayer>;
  106982. /**
  106983. * Removes the given effect layer from this scene.
  106984. * @param toRemove defines the effect layer to remove
  106985. * @returns the index of the removed effect layer
  106986. */
  106987. removeEffectLayer(toRemove: EffectLayer): number;
  106988. /**
  106989. * Adds the given effect layer to this scene
  106990. * @param newEffectLayer defines the effect layer to add
  106991. */
  106992. addEffectLayer(newEffectLayer: EffectLayer): void;
  106993. }
  106994. /**
  106995. * Defines the layer scene component responsible to manage any effect layers
  106996. * in a given scene.
  106997. */
  106998. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106999. /**
  107000. * The component name helpfull to identify the component in the list of scene components.
  107001. */
  107002. readonly name: string;
  107003. /**
  107004. * The scene the component belongs to.
  107005. */
  107006. scene: Scene;
  107007. private _engine;
  107008. private _renderEffects;
  107009. private _needStencil;
  107010. private _previousStencilState;
  107011. /**
  107012. * Creates a new instance of the component for the given scene
  107013. * @param scene Defines the scene to register the component in
  107014. */
  107015. constructor(scene: Scene);
  107016. /**
  107017. * Registers the component in a given scene
  107018. */
  107019. register(): void;
  107020. /**
  107021. * Rebuilds the elements related to this component in case of
  107022. * context lost for instance.
  107023. */
  107024. rebuild(): void;
  107025. /**
  107026. * Serializes the component data to the specified json object
  107027. * @param serializationObject The object to serialize to
  107028. */
  107029. serialize(serializationObject: any): void;
  107030. /**
  107031. * Adds all the element from the container to the scene
  107032. * @param container the container holding the elements
  107033. */
  107034. addFromContainer(container: AbstractScene): void;
  107035. /**
  107036. * Removes all the elements in the container from the scene
  107037. * @param container contains the elements to remove
  107038. * @param dispose if the removed element should be disposed (default: false)
  107039. */
  107040. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107041. /**
  107042. * Disposes the component and the associated ressources.
  107043. */
  107044. dispose(): void;
  107045. private _isReadyForMesh;
  107046. private _renderMainTexture;
  107047. private _setStencil;
  107048. private _setStencilBack;
  107049. private _draw;
  107050. private _drawCamera;
  107051. private _drawRenderingGroup;
  107052. }
  107053. }
  107054. declare module BABYLON {
  107055. /** @hidden */
  107056. export var glowMapMergePixelShader: {
  107057. name: string;
  107058. shader: string;
  107059. };
  107060. }
  107061. declare module BABYLON {
  107062. /** @hidden */
  107063. export var glowMapMergeVertexShader: {
  107064. name: string;
  107065. shader: string;
  107066. };
  107067. }
  107068. declare module BABYLON {
  107069. interface AbstractScene {
  107070. /**
  107071. * Return a the first highlight layer of the scene with a given name.
  107072. * @param name The name of the highlight layer to look for.
  107073. * @return The highlight layer if found otherwise null.
  107074. */
  107075. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  107076. }
  107077. /**
  107078. * Glow layer options. This helps customizing the behaviour
  107079. * of the glow layer.
  107080. */
  107081. export interface IGlowLayerOptions {
  107082. /**
  107083. * Multiplication factor apply to the canvas size to compute the render target size
  107084. * used to generated the glowing objects (the smaller the faster).
  107085. */
  107086. mainTextureRatio: number;
  107087. /**
  107088. * Enforces a fixed size texture to ensure resize independant blur.
  107089. */
  107090. mainTextureFixedSize?: number;
  107091. /**
  107092. * How big is the kernel of the blur texture.
  107093. */
  107094. blurKernelSize: number;
  107095. /**
  107096. * The camera attached to the layer.
  107097. */
  107098. camera: Nullable<Camera>;
  107099. /**
  107100. * Enable MSAA by chosing the number of samples.
  107101. */
  107102. mainTextureSamples?: number;
  107103. /**
  107104. * The rendering group to draw the layer in.
  107105. */
  107106. renderingGroupId: number;
  107107. }
  107108. /**
  107109. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  107110. *
  107111. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107112. * glowy meshes to your scene.
  107113. *
  107114. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  107115. */
  107116. export class GlowLayer extends EffectLayer {
  107117. /**
  107118. * Effect Name of the layer.
  107119. */
  107120. static readonly EffectName: string;
  107121. /**
  107122. * The default blur kernel size used for the glow.
  107123. */
  107124. static DefaultBlurKernelSize: number;
  107125. /**
  107126. * The default texture size ratio used for the glow.
  107127. */
  107128. static DefaultTextureRatio: number;
  107129. /**
  107130. * Sets the kernel size of the blur.
  107131. */
  107132. /**
  107133. * Gets the kernel size of the blur.
  107134. */
  107135. blurKernelSize: number;
  107136. /**
  107137. * Sets the glow intensity.
  107138. */
  107139. /**
  107140. * Gets the glow intensity.
  107141. */
  107142. intensity: number;
  107143. private _options;
  107144. private _intensity;
  107145. private _horizontalBlurPostprocess1;
  107146. private _verticalBlurPostprocess1;
  107147. private _horizontalBlurPostprocess2;
  107148. private _verticalBlurPostprocess2;
  107149. private _blurTexture1;
  107150. private _blurTexture2;
  107151. private _postProcesses1;
  107152. private _postProcesses2;
  107153. private _includedOnlyMeshes;
  107154. private _excludedMeshes;
  107155. /**
  107156. * Callback used to let the user override the color selection on a per mesh basis
  107157. */
  107158. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  107159. /**
  107160. * Callback used to let the user override the texture selection on a per mesh basis
  107161. */
  107162. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  107163. /**
  107164. * Instantiates a new glow Layer and references it to the scene.
  107165. * @param name The name of the layer
  107166. * @param scene The scene to use the layer in
  107167. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  107168. */
  107169. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  107170. /**
  107171. * Get the effect name of the layer.
  107172. * @return The effect name
  107173. */
  107174. getEffectName(): string;
  107175. /**
  107176. * Create the merge effect. This is the shader use to blit the information back
  107177. * to the main canvas at the end of the scene rendering.
  107178. */
  107179. protected _createMergeEffect(): Effect;
  107180. /**
  107181. * Creates the render target textures and post processes used in the glow layer.
  107182. */
  107183. protected _createTextureAndPostProcesses(): void;
  107184. /**
  107185. * Checks for the readiness of the element composing the layer.
  107186. * @param subMesh the mesh to check for
  107187. * @param useInstances specify wether or not to use instances to render the mesh
  107188. * @param emissiveTexture the associated emissive texture used to generate the glow
  107189. * @return true if ready otherwise, false
  107190. */
  107191. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107192. /**
  107193. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107194. */
  107195. needStencil(): boolean;
  107196. /**
  107197. * Returns true if the mesh can be rendered, otherwise false.
  107198. * @param mesh The mesh to render
  107199. * @param material The material used on the mesh
  107200. * @returns true if it can be rendered otherwise false
  107201. */
  107202. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  107203. /**
  107204. * Implementation specific of rendering the generating effect on the main canvas.
  107205. * @param effect The effect used to render through
  107206. */
  107207. protected _internalRender(effect: Effect): void;
  107208. /**
  107209. * Sets the required values for both the emissive texture and and the main color.
  107210. */
  107211. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107212. /**
  107213. * Returns true if the mesh should render, otherwise false.
  107214. * @param mesh The mesh to render
  107215. * @returns true if it should render otherwise false
  107216. */
  107217. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107218. /**
  107219. * Adds specific effects defines.
  107220. * @param defines The defines to add specifics to.
  107221. */
  107222. protected _addCustomEffectDefines(defines: string[]): void;
  107223. /**
  107224. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  107225. * @param mesh The mesh to exclude from the glow layer
  107226. */
  107227. addExcludedMesh(mesh: Mesh): void;
  107228. /**
  107229. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  107230. * @param mesh The mesh to remove
  107231. */
  107232. removeExcludedMesh(mesh: Mesh): void;
  107233. /**
  107234. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  107235. * @param mesh The mesh to include in the glow layer
  107236. */
  107237. addIncludedOnlyMesh(mesh: Mesh): void;
  107238. /**
  107239. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  107240. * @param mesh The mesh to remove
  107241. */
  107242. removeIncludedOnlyMesh(mesh: Mesh): void;
  107243. /**
  107244. * Determine if a given mesh will be used in the glow layer
  107245. * @param mesh The mesh to test
  107246. * @returns true if the mesh will be highlighted by the current glow layer
  107247. */
  107248. hasMesh(mesh: AbstractMesh): boolean;
  107249. /**
  107250. * Free any resources and references associated to a mesh.
  107251. * Internal use
  107252. * @param mesh The mesh to free.
  107253. * @hidden
  107254. */
  107255. _disposeMesh(mesh: Mesh): void;
  107256. /**
  107257. * Gets the class name of the effect layer
  107258. * @returns the string with the class name of the effect layer
  107259. */
  107260. getClassName(): string;
  107261. /**
  107262. * Serializes this glow layer
  107263. * @returns a serialized glow layer object
  107264. */
  107265. serialize(): any;
  107266. /**
  107267. * Creates a Glow Layer from parsed glow layer data
  107268. * @param parsedGlowLayer defines glow layer data
  107269. * @param scene defines the current scene
  107270. * @param rootUrl defines the root URL containing the glow layer information
  107271. * @returns a parsed Glow Layer
  107272. */
  107273. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  107274. }
  107275. }
  107276. declare module BABYLON {
  107277. /** @hidden */
  107278. export var glowBlurPostProcessPixelShader: {
  107279. name: string;
  107280. shader: string;
  107281. };
  107282. }
  107283. declare module BABYLON {
  107284. interface AbstractScene {
  107285. /**
  107286. * Return a the first highlight layer of the scene with a given name.
  107287. * @param name The name of the highlight layer to look for.
  107288. * @return The highlight layer if found otherwise null.
  107289. */
  107290. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  107291. }
  107292. /**
  107293. * Highlight layer options. This helps customizing the behaviour
  107294. * of the highlight layer.
  107295. */
  107296. export interface IHighlightLayerOptions {
  107297. /**
  107298. * Multiplication factor apply to the canvas size to compute the render target size
  107299. * used to generated the glowing objects (the smaller the faster).
  107300. */
  107301. mainTextureRatio: number;
  107302. /**
  107303. * Enforces a fixed size texture to ensure resize independant blur.
  107304. */
  107305. mainTextureFixedSize?: number;
  107306. /**
  107307. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  107308. * of the picture to blur (the smaller the faster).
  107309. */
  107310. blurTextureSizeRatio: number;
  107311. /**
  107312. * How big in texel of the blur texture is the vertical blur.
  107313. */
  107314. blurVerticalSize: number;
  107315. /**
  107316. * How big in texel of the blur texture is the horizontal blur.
  107317. */
  107318. blurHorizontalSize: number;
  107319. /**
  107320. * Alpha blending mode used to apply the blur. Default is combine.
  107321. */
  107322. alphaBlendingMode: number;
  107323. /**
  107324. * The camera attached to the layer.
  107325. */
  107326. camera: Nullable<Camera>;
  107327. /**
  107328. * Should we display highlight as a solid stroke?
  107329. */
  107330. isStroke?: boolean;
  107331. /**
  107332. * The rendering group to draw the layer in.
  107333. */
  107334. renderingGroupId: number;
  107335. }
  107336. /**
  107337. * The highlight layer Helps adding a glow effect around a mesh.
  107338. *
  107339. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  107340. * glowy meshes to your scene.
  107341. *
  107342. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  107343. */
  107344. export class HighlightLayer extends EffectLayer {
  107345. name: string;
  107346. /**
  107347. * Effect Name of the highlight layer.
  107348. */
  107349. static readonly EffectName: string;
  107350. /**
  107351. * The neutral color used during the preparation of the glow effect.
  107352. * This is black by default as the blend operation is a blend operation.
  107353. */
  107354. static NeutralColor: Color4;
  107355. /**
  107356. * Stencil value used for glowing meshes.
  107357. */
  107358. static GlowingMeshStencilReference: number;
  107359. /**
  107360. * Stencil value used for the other meshes in the scene.
  107361. */
  107362. static NormalMeshStencilReference: number;
  107363. /**
  107364. * Specifies whether or not the inner glow is ACTIVE in the layer.
  107365. */
  107366. innerGlow: boolean;
  107367. /**
  107368. * Specifies whether or not the outer glow is ACTIVE in the layer.
  107369. */
  107370. outerGlow: boolean;
  107371. /**
  107372. * Specifies the horizontal size of the blur.
  107373. */
  107374. /**
  107375. * Gets the horizontal size of the blur.
  107376. */
  107377. blurHorizontalSize: number;
  107378. /**
  107379. * Specifies the vertical size of the blur.
  107380. */
  107381. /**
  107382. * Gets the vertical size of the blur.
  107383. */
  107384. blurVerticalSize: number;
  107385. /**
  107386. * An event triggered when the highlight layer is being blurred.
  107387. */
  107388. onBeforeBlurObservable: Observable<HighlightLayer>;
  107389. /**
  107390. * An event triggered when the highlight layer has been blurred.
  107391. */
  107392. onAfterBlurObservable: Observable<HighlightLayer>;
  107393. private _instanceGlowingMeshStencilReference;
  107394. private _options;
  107395. private _downSamplePostprocess;
  107396. private _horizontalBlurPostprocess;
  107397. private _verticalBlurPostprocess;
  107398. private _blurTexture;
  107399. private _meshes;
  107400. private _excludedMeshes;
  107401. /**
  107402. * Instantiates a new highlight Layer and references it to the scene..
  107403. * @param name The name of the layer
  107404. * @param scene The scene to use the layer in
  107405. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  107406. */
  107407. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  107408. /**
  107409. * Get the effect name of the layer.
  107410. * @return The effect name
  107411. */
  107412. getEffectName(): string;
  107413. /**
  107414. * Create the merge effect. This is the shader use to blit the information back
  107415. * to the main canvas at the end of the scene rendering.
  107416. */
  107417. protected _createMergeEffect(): Effect;
  107418. /**
  107419. * Creates the render target textures and post processes used in the highlight layer.
  107420. */
  107421. protected _createTextureAndPostProcesses(): void;
  107422. /**
  107423. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  107424. */
  107425. needStencil(): boolean;
  107426. /**
  107427. * Checks for the readiness of the element composing the layer.
  107428. * @param subMesh the mesh to check for
  107429. * @param useInstances specify wether or not to use instances to render the mesh
  107430. * @param emissiveTexture the associated emissive texture used to generate the glow
  107431. * @return true if ready otherwise, false
  107432. */
  107433. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107434. /**
  107435. * Implementation specific of rendering the generating effect on the main canvas.
  107436. * @param effect The effect used to render through
  107437. */
  107438. protected _internalRender(effect: Effect): void;
  107439. /**
  107440. * Returns true if the layer contains information to display, otherwise false.
  107441. */
  107442. shouldRender(): boolean;
  107443. /**
  107444. * Returns true if the mesh should render, otherwise false.
  107445. * @param mesh The mesh to render
  107446. * @returns true if it should render otherwise false
  107447. */
  107448. protected _shouldRenderMesh(mesh: Mesh): boolean;
  107449. /**
  107450. * Sets the required values for both the emissive texture and and the main color.
  107451. */
  107452. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  107453. /**
  107454. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  107455. * @param mesh The mesh to exclude from the highlight layer
  107456. */
  107457. addExcludedMesh(mesh: Mesh): void;
  107458. /**
  107459. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  107460. * @param mesh The mesh to highlight
  107461. */
  107462. removeExcludedMesh(mesh: Mesh): void;
  107463. /**
  107464. * Determine if a given mesh will be highlighted by the current HighlightLayer
  107465. * @param mesh mesh to test
  107466. * @returns true if the mesh will be highlighted by the current HighlightLayer
  107467. */
  107468. hasMesh(mesh: AbstractMesh): boolean;
  107469. /**
  107470. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  107471. * @param mesh The mesh to highlight
  107472. * @param color The color of the highlight
  107473. * @param glowEmissiveOnly Extract the glow from the emissive texture
  107474. */
  107475. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  107476. /**
  107477. * Remove a mesh from the highlight layer in order to make it stop glowing.
  107478. * @param mesh The mesh to highlight
  107479. */
  107480. removeMesh(mesh: Mesh): void;
  107481. /**
  107482. * Force the stencil to the normal expected value for none glowing parts
  107483. */
  107484. private _defaultStencilReference;
  107485. /**
  107486. * Free any resources and references associated to a mesh.
  107487. * Internal use
  107488. * @param mesh The mesh to free.
  107489. * @hidden
  107490. */
  107491. _disposeMesh(mesh: Mesh): void;
  107492. /**
  107493. * Dispose the highlight layer and free resources.
  107494. */
  107495. dispose(): void;
  107496. /**
  107497. * Gets the class name of the effect layer
  107498. * @returns the string with the class name of the effect layer
  107499. */
  107500. getClassName(): string;
  107501. /**
  107502. * Serializes this Highlight layer
  107503. * @returns a serialized Highlight layer object
  107504. */
  107505. serialize(): any;
  107506. /**
  107507. * Creates a Highlight layer from parsed Highlight layer data
  107508. * @param parsedHightlightLayer defines the Highlight layer data
  107509. * @param scene defines the current scene
  107510. * @param rootUrl defines the root URL containing the Highlight layer information
  107511. * @returns a parsed Highlight layer
  107512. */
  107513. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  107514. }
  107515. }
  107516. declare module BABYLON {
  107517. /** @hidden */
  107518. export var lensFlarePixelShader: {
  107519. name: string;
  107520. shader: string;
  107521. };
  107522. }
  107523. declare module BABYLON {
  107524. /** @hidden */
  107525. export var lensFlareVertexShader: {
  107526. name: string;
  107527. shader: string;
  107528. };
  107529. }
  107530. declare module BABYLON {
  107531. /**
  107532. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107533. * It is usually composed of several `lensFlare`.
  107534. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107535. */
  107536. export class LensFlareSystem {
  107537. /**
  107538. * Define the name of the lens flare system
  107539. */
  107540. name: string;
  107541. /**
  107542. * List of lens flares used in this system.
  107543. */
  107544. lensFlares: LensFlare[];
  107545. /**
  107546. * Define a limit from the border the lens flare can be visible.
  107547. */
  107548. borderLimit: number;
  107549. /**
  107550. * Define a viewport border we do not want to see the lens flare in.
  107551. */
  107552. viewportBorder: number;
  107553. /**
  107554. * Define a predicate which could limit the list of meshes able to occlude the effect.
  107555. */
  107556. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107557. /**
  107558. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  107559. */
  107560. layerMask: number;
  107561. /**
  107562. * Define the id of the lens flare system in the scene.
  107563. * (equal to name by default)
  107564. */
  107565. id: string;
  107566. private _scene;
  107567. private _emitter;
  107568. private _vertexBuffers;
  107569. private _indexBuffer;
  107570. private _effect;
  107571. private _positionX;
  107572. private _positionY;
  107573. private _isEnabled;
  107574. /** @hidden */
  107575. static _SceneComponentInitialization: (scene: Scene) => void;
  107576. /**
  107577. * Instantiates a lens flare system.
  107578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  107579. * It is usually composed of several `lensFlare`.
  107580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107581. * @param name Define the name of the lens flare system in the scene
  107582. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  107583. * @param scene Define the scene the lens flare system belongs to
  107584. */
  107585. constructor(
  107586. /**
  107587. * Define the name of the lens flare system
  107588. */
  107589. name: string, emitter: any, scene: Scene);
  107590. /**
  107591. * Define if the lens flare system is enabled.
  107592. */
  107593. isEnabled: boolean;
  107594. /**
  107595. * Get the scene the effects belongs to.
  107596. * @returns the scene holding the lens flare system
  107597. */
  107598. getScene(): Scene;
  107599. /**
  107600. * Get the emitter of the lens flare system.
  107601. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107602. * @returns the emitter of the lens flare system
  107603. */
  107604. getEmitter(): any;
  107605. /**
  107606. * Set the emitter of the lens flare system.
  107607. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  107608. * @param newEmitter Define the new emitter of the system
  107609. */
  107610. setEmitter(newEmitter: any): void;
  107611. /**
  107612. * Get the lens flare system emitter position.
  107613. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  107614. * @returns the position
  107615. */
  107616. getEmitterPosition(): Vector3;
  107617. /**
  107618. * @hidden
  107619. */
  107620. computeEffectivePosition(globalViewport: Viewport): boolean;
  107621. /** @hidden */
  107622. _isVisible(): boolean;
  107623. /**
  107624. * @hidden
  107625. */
  107626. render(): boolean;
  107627. /**
  107628. * Dispose and release the lens flare with its associated resources.
  107629. */
  107630. dispose(): void;
  107631. /**
  107632. * Parse a lens flare system from a JSON repressentation
  107633. * @param parsedLensFlareSystem Define the JSON to parse
  107634. * @param scene Define the scene the parsed system should be instantiated in
  107635. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  107636. * @returns the parsed system
  107637. */
  107638. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  107639. /**
  107640. * Serialize the current Lens Flare System into a JSON representation.
  107641. * @returns the serialized JSON
  107642. */
  107643. serialize(): any;
  107644. }
  107645. }
  107646. declare module BABYLON {
  107647. /**
  107648. * This represents one of the lens effect in a `lensFlareSystem`.
  107649. * It controls one of the indiviual texture used in the effect.
  107650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107651. */
  107652. export class LensFlare {
  107653. /**
  107654. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107655. */
  107656. size: number;
  107657. /**
  107658. * 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.
  107659. */
  107660. position: number;
  107661. /**
  107662. * Define the lens color.
  107663. */
  107664. color: Color3;
  107665. /**
  107666. * Define the lens texture.
  107667. */
  107668. texture: Nullable<Texture>;
  107669. /**
  107670. * Define the alpha mode to render this particular lens.
  107671. */
  107672. alphaMode: number;
  107673. private _system;
  107674. /**
  107675. * Creates a new Lens Flare.
  107676. * This represents one of the lens effect in a `lensFlareSystem`.
  107677. * It controls one of the indiviual texture used in the effect.
  107678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107679. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107680. * @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.
  107681. * @param color Define the lens color
  107682. * @param imgUrl Define the lens texture url
  107683. * @param system Define the `lensFlareSystem` this flare is part of
  107684. * @returns The newly created Lens Flare
  107685. */
  107686. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107687. /**
  107688. * Instantiates a new Lens Flare.
  107689. * This represents one of the lens effect in a `lensFlareSystem`.
  107690. * It controls one of the indiviual texture used in the effect.
  107691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107692. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107693. * @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.
  107694. * @param color Define the lens color
  107695. * @param imgUrl Define the lens texture url
  107696. * @param system Define the `lensFlareSystem` this flare is part of
  107697. */
  107698. constructor(
  107699. /**
  107700. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107701. */
  107702. size: number,
  107703. /**
  107704. * 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.
  107705. */
  107706. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107707. /**
  107708. * Dispose and release the lens flare with its associated resources.
  107709. */
  107710. dispose(): void;
  107711. }
  107712. }
  107713. declare module BABYLON {
  107714. interface AbstractScene {
  107715. /**
  107716. * The list of lens flare system added to the scene
  107717. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107718. */
  107719. lensFlareSystems: Array<LensFlareSystem>;
  107720. /**
  107721. * Removes the given lens flare system from this scene.
  107722. * @param toRemove The lens flare system to remove
  107723. * @returns The index of the removed lens flare system
  107724. */
  107725. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107726. /**
  107727. * Adds the given lens flare system to this scene
  107728. * @param newLensFlareSystem The lens flare system to add
  107729. */
  107730. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107731. /**
  107732. * Gets a lens flare system using its name
  107733. * @param name defines the name to look for
  107734. * @returns the lens flare system or null if not found
  107735. */
  107736. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107737. /**
  107738. * Gets a lens flare system using its id
  107739. * @param id defines the id to look for
  107740. * @returns the lens flare system or null if not found
  107741. */
  107742. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107743. }
  107744. /**
  107745. * Defines the lens flare scene component responsible to manage any lens flares
  107746. * in a given scene.
  107747. */
  107748. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107749. /**
  107750. * The component name helpfull to identify the component in the list of scene components.
  107751. */
  107752. readonly name: string;
  107753. /**
  107754. * The scene the component belongs to.
  107755. */
  107756. scene: Scene;
  107757. /**
  107758. * Creates a new instance of the component for the given scene
  107759. * @param scene Defines the scene to register the component in
  107760. */
  107761. constructor(scene: Scene);
  107762. /**
  107763. * Registers the component in a given scene
  107764. */
  107765. register(): void;
  107766. /**
  107767. * Rebuilds the elements related to this component in case of
  107768. * context lost for instance.
  107769. */
  107770. rebuild(): void;
  107771. /**
  107772. * Adds all the element from the container to the scene
  107773. * @param container the container holding the elements
  107774. */
  107775. addFromContainer(container: AbstractScene): void;
  107776. /**
  107777. * Removes all the elements in the container from the scene
  107778. * @param container contains the elements to remove
  107779. * @param dispose if the removed element should be disposed (default: false)
  107780. */
  107781. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107782. /**
  107783. * Serializes the component data to the specified json object
  107784. * @param serializationObject The object to serialize to
  107785. */
  107786. serialize(serializationObject: any): void;
  107787. /**
  107788. * Disposes the component and the associated ressources.
  107789. */
  107790. dispose(): void;
  107791. private _draw;
  107792. }
  107793. }
  107794. declare module BABYLON {
  107795. /**
  107796. * Defines the shadow generator component responsible to manage any shadow generators
  107797. * in a given scene.
  107798. */
  107799. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107800. /**
  107801. * The component name helpfull to identify the component in the list of scene components.
  107802. */
  107803. readonly name: string;
  107804. /**
  107805. * The scene the component belongs to.
  107806. */
  107807. scene: Scene;
  107808. /**
  107809. * Creates a new instance of the component for the given scene
  107810. * @param scene Defines the scene to register the component in
  107811. */
  107812. constructor(scene: Scene);
  107813. /**
  107814. * Registers the component in a given scene
  107815. */
  107816. register(): void;
  107817. /**
  107818. * Rebuilds the elements related to this component in case of
  107819. * context lost for instance.
  107820. */
  107821. rebuild(): void;
  107822. /**
  107823. * Serializes the component data to the specified json object
  107824. * @param serializationObject The object to serialize to
  107825. */
  107826. serialize(serializationObject: any): void;
  107827. /**
  107828. * Adds all the element from the container to the scene
  107829. * @param container the container holding the elements
  107830. */
  107831. addFromContainer(container: AbstractScene): void;
  107832. /**
  107833. * Removes all the elements in the container from the scene
  107834. * @param container contains the elements to remove
  107835. * @param dispose if the removed element should be disposed (default: false)
  107836. */
  107837. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107838. /**
  107839. * Rebuilds the elements related to this component in case of
  107840. * context lost for instance.
  107841. */
  107842. dispose(): void;
  107843. private _gatherRenderTargets;
  107844. }
  107845. }
  107846. declare module BABYLON {
  107847. /**
  107848. * A point light is a light defined by an unique point in world space.
  107849. * The light is emitted in every direction from this point.
  107850. * A good example of a point light is a standard light bulb.
  107851. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107852. */
  107853. export class PointLight extends ShadowLight {
  107854. private _shadowAngle;
  107855. /**
  107856. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107857. * This specifies what angle the shadow will use to be created.
  107858. *
  107859. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107860. */
  107861. /**
  107862. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107863. * This specifies what angle the shadow will use to be created.
  107864. *
  107865. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107866. */
  107867. shadowAngle: number;
  107868. /**
  107869. * Gets the direction if it has been set.
  107870. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107871. */
  107872. /**
  107873. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107874. */
  107875. direction: Vector3;
  107876. /**
  107877. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107878. * A PointLight emits the light in every direction.
  107879. * It can cast shadows.
  107880. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107881. * ```javascript
  107882. * var pointLight = new PointLight("pl", camera.position, scene);
  107883. * ```
  107884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107885. * @param name The light friendly name
  107886. * @param position The position of the point light in the scene
  107887. * @param scene The scene the lights belongs to
  107888. */
  107889. constructor(name: string, position: Vector3, scene: Scene);
  107890. /**
  107891. * Returns the string "PointLight"
  107892. * @returns the class name
  107893. */
  107894. getClassName(): string;
  107895. /**
  107896. * Returns the integer 0.
  107897. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107898. */
  107899. getTypeID(): number;
  107900. /**
  107901. * Specifies wether or not the shadowmap should be a cube texture.
  107902. * @returns true if the shadowmap needs to be a cube texture.
  107903. */
  107904. needCube(): boolean;
  107905. /**
  107906. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107907. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107908. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107909. */
  107910. getShadowDirection(faceIndex?: number): Vector3;
  107911. /**
  107912. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107913. * - fov = PI / 2
  107914. * - aspect ratio : 1.0
  107915. * - z-near and far equal to the active camera minZ and maxZ.
  107916. * Returns the PointLight.
  107917. */
  107918. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107919. protected _buildUniformLayout(): void;
  107920. /**
  107921. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107922. * @param effect The effect to update
  107923. * @param lightIndex The index of the light in the effect to update
  107924. * @returns The point light
  107925. */
  107926. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107927. /**
  107928. * Prepares the list of defines specific to the light type.
  107929. * @param defines the list of defines
  107930. * @param lightIndex defines the index of the light for the effect
  107931. */
  107932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107933. }
  107934. }
  107935. declare module BABYLON {
  107936. /**
  107937. * Header information of HDR texture files.
  107938. */
  107939. export interface HDRInfo {
  107940. /**
  107941. * The height of the texture in pixels.
  107942. */
  107943. height: number;
  107944. /**
  107945. * The width of the texture in pixels.
  107946. */
  107947. width: number;
  107948. /**
  107949. * The index of the beginning of the data in the binary file.
  107950. */
  107951. dataPosition: number;
  107952. }
  107953. /**
  107954. * This groups tools to convert HDR texture to native colors array.
  107955. */
  107956. export class HDRTools {
  107957. private static Ldexp;
  107958. private static Rgbe2float;
  107959. private static readStringLine;
  107960. /**
  107961. * Reads header information from an RGBE texture stored in a native array.
  107962. * More information on this format are available here:
  107963. * https://en.wikipedia.org/wiki/RGBE_image_format
  107964. *
  107965. * @param uint8array The binary file stored in native array.
  107966. * @return The header information.
  107967. */
  107968. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107969. /**
  107970. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107971. * This RGBE texture needs to store the information as a panorama.
  107972. *
  107973. * More information on this format are available here:
  107974. * https://en.wikipedia.org/wiki/RGBE_image_format
  107975. *
  107976. * @param buffer The binary file stored in an array buffer.
  107977. * @param size The expected size of the extracted cubemap.
  107978. * @return The Cube Map information.
  107979. */
  107980. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107981. /**
  107982. * Returns the pixels data extracted from an RGBE texture.
  107983. * This pixels will be stored left to right up to down in the R G B order in one array.
  107984. *
  107985. * More information on this format are available here:
  107986. * https://en.wikipedia.org/wiki/RGBE_image_format
  107987. *
  107988. * @param uint8array The binary file stored in an array buffer.
  107989. * @param hdrInfo The header information of the file.
  107990. * @return The pixels data in RGB right to left up to down order.
  107991. */
  107992. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107993. private static RGBE_ReadPixels_RLE;
  107994. }
  107995. }
  107996. declare module BABYLON {
  107997. /**
  107998. * This represents a texture coming from an HDR input.
  107999. *
  108000. * The only supported format is currently panorama picture stored in RGBE format.
  108001. * Example of such files can be found on HDRLib: http://hdrlib.com/
  108002. */
  108003. export class HDRCubeTexture extends BaseTexture {
  108004. private static _facesMapping;
  108005. private _generateHarmonics;
  108006. private _noMipmap;
  108007. private _textureMatrix;
  108008. private _size;
  108009. private _onLoad;
  108010. private _onError;
  108011. /**
  108012. * The texture URL.
  108013. */
  108014. url: string;
  108015. /**
  108016. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  108017. */
  108018. coordinatesMode: number;
  108019. protected _isBlocking: boolean;
  108020. /**
  108021. * Sets wether or not the texture is blocking during loading.
  108022. */
  108023. /**
  108024. * Gets wether or not the texture is blocking during loading.
  108025. */
  108026. isBlocking: boolean;
  108027. protected _rotationY: number;
  108028. /**
  108029. * Sets texture matrix rotation angle around Y axis in radians.
  108030. */
  108031. /**
  108032. * Gets texture matrix rotation angle around Y axis radians.
  108033. */
  108034. rotationY: number;
  108035. /**
  108036. * Gets or sets the center of the bounding box associated with the cube texture
  108037. * It must define where the camera used to render the texture was set
  108038. */
  108039. boundingBoxPosition: Vector3;
  108040. private _boundingBoxSize;
  108041. /**
  108042. * Gets or sets the size of the bounding box associated with the cube texture
  108043. * When defined, the cubemap will switch to local mode
  108044. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  108045. * @example https://www.babylonjs-playground.com/#RNASML
  108046. */
  108047. boundingBoxSize: Vector3;
  108048. /**
  108049. * Instantiates an HDRTexture from the following parameters.
  108050. *
  108051. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  108052. * @param scene The scene the texture will be used in
  108053. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108054. * @param noMipmap Forces to not generate the mipmap if true
  108055. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  108056. * @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)
  108057. * @param reserved Reserved flag for internal use.
  108058. */
  108059. 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>);
  108060. /**
  108061. * Get the current class name of the texture useful for serialization or dynamic coding.
  108062. * @returns "HDRCubeTexture"
  108063. */
  108064. getClassName(): string;
  108065. /**
  108066. * Occurs when the file is raw .hdr file.
  108067. */
  108068. private loadTexture;
  108069. clone(): HDRCubeTexture;
  108070. delayLoad(): void;
  108071. /**
  108072. * Get the texture reflection matrix used to rotate/transform the reflection.
  108073. * @returns the reflection matrix
  108074. */
  108075. getReflectionTextureMatrix(): Matrix;
  108076. /**
  108077. * Set the texture reflection matrix used to rotate/transform the reflection.
  108078. * @param value Define the reflection matrix to set
  108079. */
  108080. setReflectionTextureMatrix(value: Matrix): void;
  108081. /**
  108082. * Parses a JSON representation of an HDR Texture in order to create the texture
  108083. * @param parsedTexture Define the JSON representation
  108084. * @param scene Define the scene the texture should be created in
  108085. * @param rootUrl Define the root url in case we need to load relative dependencies
  108086. * @returns the newly created texture after parsing
  108087. */
  108088. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  108089. serialize(): any;
  108090. }
  108091. }
  108092. declare module BABYLON {
  108093. /**
  108094. * Class used to control physics engine
  108095. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108096. */
  108097. export class PhysicsEngine implements IPhysicsEngine {
  108098. private _physicsPlugin;
  108099. /**
  108100. * Global value used to control the smallest number supported by the simulation
  108101. */
  108102. static Epsilon: number;
  108103. private _impostors;
  108104. private _joints;
  108105. /**
  108106. * Gets the gravity vector used by the simulation
  108107. */
  108108. gravity: Vector3;
  108109. /**
  108110. * Factory used to create the default physics plugin.
  108111. * @returns The default physics plugin
  108112. */
  108113. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  108114. /**
  108115. * Creates a new Physics Engine
  108116. * @param gravity defines the gravity vector used by the simulation
  108117. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  108118. */
  108119. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  108120. /**
  108121. * Sets the gravity vector used by the simulation
  108122. * @param gravity defines the gravity vector to use
  108123. */
  108124. setGravity(gravity: Vector3): void;
  108125. /**
  108126. * Set the time step of the physics engine.
  108127. * Default is 1/60.
  108128. * To slow it down, enter 1/600 for example.
  108129. * To speed it up, 1/30
  108130. * @param newTimeStep defines the new timestep to apply to this world.
  108131. */
  108132. setTimeStep(newTimeStep?: number): void;
  108133. /**
  108134. * Get the time step of the physics engine.
  108135. * @returns the current time step
  108136. */
  108137. getTimeStep(): number;
  108138. /**
  108139. * Release all resources
  108140. */
  108141. dispose(): void;
  108142. /**
  108143. * Gets the name of the current physics plugin
  108144. * @returns the name of the plugin
  108145. */
  108146. getPhysicsPluginName(): string;
  108147. /**
  108148. * Adding a new impostor for the impostor tracking.
  108149. * This will be done by the impostor itself.
  108150. * @param impostor the impostor to add
  108151. */
  108152. addImpostor(impostor: PhysicsImpostor): void;
  108153. /**
  108154. * Remove an impostor from the engine.
  108155. * This impostor and its mesh will not longer be updated by the physics engine.
  108156. * @param impostor the impostor to remove
  108157. */
  108158. removeImpostor(impostor: PhysicsImpostor): void;
  108159. /**
  108160. * Add a joint to the physics engine
  108161. * @param mainImpostor defines the main impostor to which the joint is added.
  108162. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108163. * @param joint defines the joint that will connect both impostors.
  108164. */
  108165. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108166. /**
  108167. * Removes a joint from the simulation
  108168. * @param mainImpostor defines the impostor used with the joint
  108169. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108170. * @param joint defines the joint to remove
  108171. */
  108172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108173. /**
  108174. * Called by the scene. No need to call it.
  108175. * @param delta defines the timespam between frames
  108176. */
  108177. _step(delta: number): void;
  108178. /**
  108179. * Gets the current plugin used to run the simulation
  108180. * @returns current plugin
  108181. */
  108182. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108183. /**
  108184. * Gets the list of physic impostors
  108185. * @returns an array of PhysicsImpostor
  108186. */
  108187. getImpostors(): Array<PhysicsImpostor>;
  108188. /**
  108189. * Gets the impostor for a physics enabled object
  108190. * @param object defines the object impersonated by the impostor
  108191. * @returns the PhysicsImpostor or null if not found
  108192. */
  108193. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108194. /**
  108195. * Gets the impostor for a physics body object
  108196. * @param body defines physics body used by the impostor
  108197. * @returns the PhysicsImpostor or null if not found
  108198. */
  108199. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108200. /**
  108201. * Does a raycast in the physics world
  108202. * @param from when should the ray start?
  108203. * @param to when should the ray end?
  108204. * @returns PhysicsRaycastResult
  108205. */
  108206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108207. }
  108208. }
  108209. declare module BABYLON {
  108210. /** @hidden */
  108211. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  108212. private _useDeltaForWorldStep;
  108213. world: any;
  108214. name: string;
  108215. private _physicsMaterials;
  108216. private _fixedTimeStep;
  108217. private _cannonRaycastResult;
  108218. private _raycastResult;
  108219. private _removeAfterStep;
  108220. BJSCANNON: any;
  108221. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  108222. setGravity(gravity: Vector3): void;
  108223. setTimeStep(timeStep: number): void;
  108224. getTimeStep(): number;
  108225. executeStep(delta: number): void;
  108226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108227. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108228. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108229. private _processChildMeshes;
  108230. removePhysicsBody(impostor: PhysicsImpostor): void;
  108231. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108232. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108233. private _addMaterial;
  108234. private _checkWithEpsilon;
  108235. private _createShape;
  108236. private _createHeightmap;
  108237. private _minus90X;
  108238. private _plus90X;
  108239. private _tmpPosition;
  108240. private _tmpDeltaPosition;
  108241. private _tmpUnityRotation;
  108242. private _updatePhysicsBodyTransformation;
  108243. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108244. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108245. isSupported(): boolean;
  108246. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108247. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108248. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108249. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108250. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108251. getBodyMass(impostor: PhysicsImpostor): number;
  108252. getBodyFriction(impostor: PhysicsImpostor): number;
  108253. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108254. getBodyRestitution(impostor: PhysicsImpostor): number;
  108255. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108256. sleepBody(impostor: PhysicsImpostor): void;
  108257. wakeUpBody(impostor: PhysicsImpostor): void;
  108258. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  108259. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108260. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108261. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108262. getRadius(impostor: PhysicsImpostor): number;
  108263. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108264. dispose(): void;
  108265. private _extendNamespace;
  108266. /**
  108267. * Does a raycast in the physics world
  108268. * @param from when should the ray start?
  108269. * @param to when should the ray end?
  108270. * @returns PhysicsRaycastResult
  108271. */
  108272. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108273. }
  108274. }
  108275. declare module BABYLON {
  108276. /** @hidden */
  108277. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  108278. world: any;
  108279. name: string;
  108280. BJSOIMO: any;
  108281. private _raycastResult;
  108282. constructor(iterations?: number, oimoInjection?: any);
  108283. setGravity(gravity: Vector3): void;
  108284. setTimeStep(timeStep: number): void;
  108285. getTimeStep(): number;
  108286. private _tmpImpostorsArray;
  108287. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108288. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108289. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108290. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108291. private _tmpPositionVector;
  108292. removePhysicsBody(impostor: PhysicsImpostor): void;
  108293. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108294. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108295. isSupported(): boolean;
  108296. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108297. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108298. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108299. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108300. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108301. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108302. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108303. getBodyMass(impostor: PhysicsImpostor): number;
  108304. getBodyFriction(impostor: PhysicsImpostor): number;
  108305. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108306. getBodyRestitution(impostor: PhysicsImpostor): number;
  108307. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108308. sleepBody(impostor: PhysicsImpostor): void;
  108309. wakeUpBody(impostor: PhysicsImpostor): void;
  108310. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108311. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  108312. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  108313. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108314. getRadius(impostor: PhysicsImpostor): number;
  108315. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108316. dispose(): void;
  108317. /**
  108318. * Does a raycast in the physics world
  108319. * @param from when should the ray start?
  108320. * @param to when should the ray end?
  108321. * @returns PhysicsRaycastResult
  108322. */
  108323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108324. }
  108325. }
  108326. declare module BABYLON {
  108327. /**
  108328. * Class containing static functions to help procedurally build meshes
  108329. */
  108330. export class RibbonBuilder {
  108331. /**
  108332. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  108333. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  108334. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  108335. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  108336. * * 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
  108337. * * 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
  108338. * * 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
  108339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108342. * * 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
  108343. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  108344. * * 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
  108345. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  108346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108347. * @param name defines the name of the mesh
  108348. * @param options defines the options used to create the mesh
  108349. * @param scene defines the hosting scene
  108350. * @returns the ribbon mesh
  108351. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  108352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108353. */
  108354. static CreateRibbon(name: string, options: {
  108355. pathArray: Vector3[][];
  108356. closeArray?: boolean;
  108357. closePath?: boolean;
  108358. offset?: number;
  108359. updatable?: boolean;
  108360. sideOrientation?: number;
  108361. frontUVs?: Vector4;
  108362. backUVs?: Vector4;
  108363. instance?: Mesh;
  108364. invertUV?: boolean;
  108365. uvs?: Vector2[];
  108366. colors?: Color4[];
  108367. }, scene?: Nullable<Scene>): Mesh;
  108368. }
  108369. }
  108370. declare module BABYLON {
  108371. /**
  108372. * Class containing static functions to help procedurally build meshes
  108373. */
  108374. export class ShapeBuilder {
  108375. /**
  108376. * 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.
  108377. * * 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.
  108378. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108379. * * 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.
  108380. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  108381. * * 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
  108382. * * 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
  108383. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  108384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108386. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  108387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108388. * @param name defines the name of the mesh
  108389. * @param options defines the options used to create the mesh
  108390. * @param scene defines the hosting scene
  108391. * @returns the extruded shape mesh
  108392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108394. */
  108395. static ExtrudeShape(name: string, options: {
  108396. shape: Vector3[];
  108397. path: Vector3[];
  108398. scale?: number;
  108399. rotation?: number;
  108400. cap?: number;
  108401. updatable?: boolean;
  108402. sideOrientation?: number;
  108403. frontUVs?: Vector4;
  108404. backUVs?: Vector4;
  108405. instance?: Mesh;
  108406. invertUV?: boolean;
  108407. }, scene?: Nullable<Scene>): Mesh;
  108408. /**
  108409. * Creates an custom extruded shape mesh.
  108410. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  108411. * * 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.
  108412. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  108413. * * 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
  108414. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  108415. * * 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
  108416. * * It must returns a float value that will be the scale value applied to the shape on each path point
  108417. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108418. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  108419. * * 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
  108420. * * 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
  108421. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  108422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  108425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108426. * @param name defines the name of the mesh
  108427. * @param options defines the options used to create the mesh
  108428. * @param scene defines the hosting scene
  108429. * @returns the custom extruded shape mesh
  108430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  108431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108433. */
  108434. static ExtrudeShapeCustom(name: string, options: {
  108435. shape: Vector3[];
  108436. path: Vector3[];
  108437. scaleFunction?: any;
  108438. rotationFunction?: any;
  108439. ribbonCloseArray?: boolean;
  108440. ribbonClosePath?: boolean;
  108441. cap?: number;
  108442. updatable?: boolean;
  108443. sideOrientation?: number;
  108444. frontUVs?: Vector4;
  108445. backUVs?: Vector4;
  108446. instance?: Mesh;
  108447. invertUV?: boolean;
  108448. }, scene?: Nullable<Scene>): Mesh;
  108449. private static _ExtrudeShapeGeneric;
  108450. }
  108451. }
  108452. declare module BABYLON {
  108453. /**
  108454. * AmmoJS Physics plugin
  108455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108456. * @see https://github.com/kripken/ammo.js/
  108457. */
  108458. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108459. private _useDeltaForWorldStep;
  108460. /**
  108461. * Reference to the Ammo library
  108462. */
  108463. bjsAMMO: any;
  108464. /**
  108465. * Created ammoJS world which physics bodies are added to
  108466. */
  108467. world: any;
  108468. /**
  108469. * Name of the plugin
  108470. */
  108471. name: string;
  108472. private _timeStep;
  108473. private _fixedTimeStep;
  108474. private _maxSteps;
  108475. private _tmpQuaternion;
  108476. private _tmpAmmoTransform;
  108477. private _tmpAmmoQuaternion;
  108478. private _tmpAmmoConcreteContactResultCallback;
  108479. private _collisionConfiguration;
  108480. private _dispatcher;
  108481. private _overlappingPairCache;
  108482. private _solver;
  108483. private _softBodySolver;
  108484. private _tmpAmmoVectorA;
  108485. private _tmpAmmoVectorB;
  108486. private _tmpAmmoVectorC;
  108487. private _tmpAmmoVectorD;
  108488. private _tmpContactCallbackResult;
  108489. private _tmpAmmoVectorRCA;
  108490. private _tmpAmmoVectorRCB;
  108491. private _raycastResult;
  108492. private static readonly DISABLE_COLLISION_FLAG;
  108493. private static readonly KINEMATIC_FLAG;
  108494. private static readonly DISABLE_DEACTIVATION_FLAG;
  108495. /**
  108496. * Initializes the ammoJS plugin
  108497. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108498. * @param ammoInjection can be used to inject your own ammo reference
  108499. */
  108500. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  108501. /**
  108502. * Sets the gravity of the physics world (m/(s^2))
  108503. * @param gravity Gravity to set
  108504. */
  108505. setGravity(gravity: Vector3): void;
  108506. /**
  108507. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  108508. * @param timeStep timestep to use in seconds
  108509. */
  108510. setTimeStep(timeStep: number): void;
  108511. /**
  108512. * 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)
  108513. * @param fixedTimeStep fixedTimeStep to use in seconds
  108514. */
  108515. setFixedTimeStep(fixedTimeStep: number): void;
  108516. /**
  108517. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  108518. * @param maxSteps the maximum number of steps by the physics engine per frame
  108519. */
  108520. setMaxSteps(maxSteps: number): void;
  108521. /**
  108522. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  108523. * @returns the current timestep in seconds
  108524. */
  108525. getTimeStep(): number;
  108526. private _isImpostorInContact;
  108527. private _isImpostorPairInContact;
  108528. private _stepSimulation;
  108529. /**
  108530. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  108531. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  108532. * After the step the babylon meshes are set to the position of the physics imposters
  108533. * @param delta amount of time to step forward
  108534. * @param impostors array of imposters to update before/after the step
  108535. */
  108536. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  108537. /**
  108538. * Update babylon mesh to match physics world object
  108539. * @param impostor imposter to match
  108540. */
  108541. private _afterSoftStep;
  108542. /**
  108543. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108544. * @param impostor imposter to match
  108545. */
  108546. private _ropeStep;
  108547. /**
  108548. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  108549. * @param impostor imposter to match
  108550. */
  108551. private _softbodyOrClothStep;
  108552. private _tmpVector;
  108553. private _tmpMatrix;
  108554. /**
  108555. * Applies an impulse on the imposter
  108556. * @param impostor imposter to apply impulse to
  108557. * @param force amount of force to be applied to the imposter
  108558. * @param contactPoint the location to apply the impulse on the imposter
  108559. */
  108560. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108561. /**
  108562. * Applies a force on the imposter
  108563. * @param impostor imposter to apply force
  108564. * @param force amount of force to be applied to the imposter
  108565. * @param contactPoint the location to apply the force on the imposter
  108566. */
  108567. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  108568. /**
  108569. * Creates a physics body using the plugin
  108570. * @param impostor the imposter to create the physics body on
  108571. */
  108572. generatePhysicsBody(impostor: PhysicsImpostor): void;
  108573. /**
  108574. * Removes the physics body from the imposter and disposes of the body's memory
  108575. * @param impostor imposter to remove the physics body from
  108576. */
  108577. removePhysicsBody(impostor: PhysicsImpostor): void;
  108578. /**
  108579. * Generates a joint
  108580. * @param impostorJoint the imposter joint to create the joint with
  108581. */
  108582. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  108583. /**
  108584. * Removes a joint
  108585. * @param impostorJoint the imposter joint to remove the joint from
  108586. */
  108587. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  108588. private _addMeshVerts;
  108589. /**
  108590. * Initialise the soft body vertices to match its object's (mesh) vertices
  108591. * Softbody vertices (nodes) are in world space and to match this
  108592. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  108593. * @param impostor to create the softbody for
  108594. */
  108595. private _softVertexData;
  108596. /**
  108597. * Create an impostor's soft body
  108598. * @param impostor to create the softbody for
  108599. */
  108600. private _createSoftbody;
  108601. /**
  108602. * Create cloth for an impostor
  108603. * @param impostor to create the softbody for
  108604. */
  108605. private _createCloth;
  108606. /**
  108607. * Create rope for an impostor
  108608. * @param impostor to create the softbody for
  108609. */
  108610. private _createRope;
  108611. private _addHullVerts;
  108612. private _createShape;
  108613. /**
  108614. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  108615. * @param impostor imposter containing the physics body and babylon object
  108616. */
  108617. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  108618. /**
  108619. * Sets the babylon object's position/rotation from the physics body's position/rotation
  108620. * @param impostor imposter containing the physics body and babylon object
  108621. * @param newPosition new position
  108622. * @param newRotation new rotation
  108623. */
  108624. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  108625. /**
  108626. * If this plugin is supported
  108627. * @returns true if its supported
  108628. */
  108629. isSupported(): boolean;
  108630. /**
  108631. * Sets the linear velocity of the physics body
  108632. * @param impostor imposter to set the velocity on
  108633. * @param velocity velocity to set
  108634. */
  108635. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108636. /**
  108637. * Sets the angular velocity of the physics body
  108638. * @param impostor imposter to set the velocity on
  108639. * @param velocity velocity to set
  108640. */
  108641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  108642. /**
  108643. * gets the linear velocity
  108644. * @param impostor imposter to get linear velocity from
  108645. * @returns linear velocity
  108646. */
  108647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108648. /**
  108649. * gets the angular velocity
  108650. * @param impostor imposter to get angular velocity from
  108651. * @returns angular velocity
  108652. */
  108653. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  108654. /**
  108655. * Sets the mass of physics body
  108656. * @param impostor imposter to set the mass on
  108657. * @param mass mass to set
  108658. */
  108659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  108660. /**
  108661. * Gets the mass of the physics body
  108662. * @param impostor imposter to get the mass from
  108663. * @returns mass
  108664. */
  108665. getBodyMass(impostor: PhysicsImpostor): number;
  108666. /**
  108667. * Gets friction of the impostor
  108668. * @param impostor impostor to get friction from
  108669. * @returns friction value
  108670. */
  108671. getBodyFriction(impostor: PhysicsImpostor): number;
  108672. /**
  108673. * Sets friction of the impostor
  108674. * @param impostor impostor to set friction on
  108675. * @param friction friction value
  108676. */
  108677. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108678. /**
  108679. * Gets restitution of the impostor
  108680. * @param impostor impostor to get restitution from
  108681. * @returns restitution value
  108682. */
  108683. getBodyRestitution(impostor: PhysicsImpostor): number;
  108684. /**
  108685. * Sets resitution of the impostor
  108686. * @param impostor impostor to set resitution on
  108687. * @param restitution resitution value
  108688. */
  108689. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108690. /**
  108691. * Gets pressure inside the impostor
  108692. * @param impostor impostor to get pressure from
  108693. * @returns pressure value
  108694. */
  108695. getBodyPressure(impostor: PhysicsImpostor): number;
  108696. /**
  108697. * Sets pressure inside a soft body impostor
  108698. * Cloth and rope must remain 0 pressure
  108699. * @param impostor impostor to set pressure on
  108700. * @param pressure pressure value
  108701. */
  108702. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108703. /**
  108704. * Gets stiffness of the impostor
  108705. * @param impostor impostor to get stiffness from
  108706. * @returns pressure value
  108707. */
  108708. getBodyStiffness(impostor: PhysicsImpostor): number;
  108709. /**
  108710. * Sets stiffness of the impostor
  108711. * @param impostor impostor to set stiffness on
  108712. * @param stiffness stiffness value from 0 to 1
  108713. */
  108714. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108715. /**
  108716. * Gets velocityIterations of the impostor
  108717. * @param impostor impostor to get velocity iterations from
  108718. * @returns velocityIterations value
  108719. */
  108720. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108721. /**
  108722. * Sets velocityIterations of the impostor
  108723. * @param impostor impostor to set velocity iterations on
  108724. * @param velocityIterations velocityIterations value
  108725. */
  108726. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108727. /**
  108728. * Gets positionIterations of the impostor
  108729. * @param impostor impostor to get position iterations from
  108730. * @returns positionIterations value
  108731. */
  108732. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108733. /**
  108734. * Sets positionIterations of the impostor
  108735. * @param impostor impostor to set position on
  108736. * @param positionIterations positionIterations value
  108737. */
  108738. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108739. /**
  108740. * Append an anchor to a cloth object
  108741. * @param impostor is the cloth impostor to add anchor to
  108742. * @param otherImpostor is the rigid impostor to anchor to
  108743. * @param width ratio across width from 0 to 1
  108744. * @param height ratio up height from 0 to 1
  108745. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108746. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108747. */
  108748. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108749. /**
  108750. * Append an hook to a rope object
  108751. * @param impostor is the rope impostor to add hook to
  108752. * @param otherImpostor is the rigid impostor to hook to
  108753. * @param length ratio along the rope from 0 to 1
  108754. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108755. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108756. */
  108757. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108758. /**
  108759. * Sleeps the physics body and stops it from being active
  108760. * @param impostor impostor to sleep
  108761. */
  108762. sleepBody(impostor: PhysicsImpostor): void;
  108763. /**
  108764. * Activates the physics body
  108765. * @param impostor impostor to activate
  108766. */
  108767. wakeUpBody(impostor: PhysicsImpostor): void;
  108768. /**
  108769. * Updates the distance parameters of the joint
  108770. * @param joint joint to update
  108771. * @param maxDistance maximum distance of the joint
  108772. * @param minDistance minimum distance of the joint
  108773. */
  108774. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108775. /**
  108776. * Sets a motor on the joint
  108777. * @param joint joint to set motor on
  108778. * @param speed speed of the motor
  108779. * @param maxForce maximum force of the motor
  108780. * @param motorIndex index of the motor
  108781. */
  108782. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108783. /**
  108784. * Sets the motors limit
  108785. * @param joint joint to set limit on
  108786. * @param upperLimit upper limit
  108787. * @param lowerLimit lower limit
  108788. */
  108789. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108790. /**
  108791. * Syncs the position and rotation of a mesh with the impostor
  108792. * @param mesh mesh to sync
  108793. * @param impostor impostor to update the mesh with
  108794. */
  108795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108796. /**
  108797. * Gets the radius of the impostor
  108798. * @param impostor impostor to get radius from
  108799. * @returns the radius
  108800. */
  108801. getRadius(impostor: PhysicsImpostor): number;
  108802. /**
  108803. * Gets the box size of the impostor
  108804. * @param impostor impostor to get box size from
  108805. * @param result the resulting box size
  108806. */
  108807. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108808. /**
  108809. * Disposes of the impostor
  108810. */
  108811. dispose(): void;
  108812. /**
  108813. * Does a raycast in the physics world
  108814. * @param from when should the ray start?
  108815. * @param to when should the ray end?
  108816. * @returns PhysicsRaycastResult
  108817. */
  108818. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108819. }
  108820. }
  108821. declare module BABYLON {
  108822. interface AbstractScene {
  108823. /**
  108824. * The list of reflection probes added to the scene
  108825. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108826. */
  108827. reflectionProbes: Array<ReflectionProbe>;
  108828. /**
  108829. * Removes the given reflection probe from this scene.
  108830. * @param toRemove The reflection probe to remove
  108831. * @returns The index of the removed reflection probe
  108832. */
  108833. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108834. /**
  108835. * Adds the given reflection probe to this scene.
  108836. * @param newReflectionProbe The reflection probe to add
  108837. */
  108838. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108839. }
  108840. /**
  108841. * Class used to generate realtime reflection / refraction cube textures
  108842. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108843. */
  108844. export class ReflectionProbe {
  108845. /** defines the name of the probe */
  108846. name: string;
  108847. private _scene;
  108848. private _renderTargetTexture;
  108849. private _projectionMatrix;
  108850. private _viewMatrix;
  108851. private _target;
  108852. private _add;
  108853. private _attachedMesh;
  108854. private _invertYAxis;
  108855. /** Gets or sets probe position (center of the cube map) */
  108856. position: Vector3;
  108857. /**
  108858. * Creates a new reflection probe
  108859. * @param name defines the name of the probe
  108860. * @param size defines the texture resolution (for each face)
  108861. * @param scene defines the hosting scene
  108862. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108863. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108864. */
  108865. constructor(
  108866. /** defines the name of the probe */
  108867. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108868. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108869. samples: number;
  108870. /** Gets or sets the refresh rate to use (on every frame by default) */
  108871. refreshRate: number;
  108872. /**
  108873. * Gets the hosting scene
  108874. * @returns a Scene
  108875. */
  108876. getScene(): Scene;
  108877. /** Gets the internal CubeTexture used to render to */
  108878. readonly cubeTexture: RenderTargetTexture;
  108879. /** Gets the list of meshes to render */
  108880. readonly renderList: Nullable<AbstractMesh[]>;
  108881. /**
  108882. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108883. * @param mesh defines the mesh to attach to
  108884. */
  108885. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108886. /**
  108887. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108888. * @param renderingGroupId The rendering group id corresponding to its index
  108889. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108890. */
  108891. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108892. /**
  108893. * Clean all associated resources
  108894. */
  108895. dispose(): void;
  108896. /**
  108897. * Converts the reflection probe information to a readable string for debug purpose.
  108898. * @param fullDetails Supports for multiple levels of logging within scene loading
  108899. * @returns the human readable reflection probe info
  108900. */
  108901. toString(fullDetails?: boolean): string;
  108902. /**
  108903. * Get the class name of the relfection probe.
  108904. * @returns "ReflectionProbe"
  108905. */
  108906. getClassName(): string;
  108907. /**
  108908. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108909. * @returns The JSON representation of the texture
  108910. */
  108911. serialize(): any;
  108912. /**
  108913. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108914. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108915. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108916. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108917. * @returns The parsed reflection probe if successful
  108918. */
  108919. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108920. }
  108921. }
  108922. declare module BABYLON {
  108923. /** @hidden */
  108924. export var _BabylonLoaderRegistered: boolean;
  108925. }
  108926. declare module BABYLON {
  108927. /**
  108928. * The Physically based simple base material of BJS.
  108929. *
  108930. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108931. * It is used as the base class for both the specGloss and metalRough conventions.
  108932. */
  108933. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108934. /**
  108935. * Number of Simultaneous lights allowed on the material.
  108936. */
  108937. maxSimultaneousLights: number;
  108938. /**
  108939. * If sets to true, disables all the lights affecting the material.
  108940. */
  108941. disableLighting: boolean;
  108942. /**
  108943. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108944. */
  108945. environmentTexture: BaseTexture;
  108946. /**
  108947. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108948. */
  108949. invertNormalMapX: boolean;
  108950. /**
  108951. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108952. */
  108953. invertNormalMapY: boolean;
  108954. /**
  108955. * Normal map used in the model.
  108956. */
  108957. normalTexture: BaseTexture;
  108958. /**
  108959. * Emissivie color used to self-illuminate the model.
  108960. */
  108961. emissiveColor: Color3;
  108962. /**
  108963. * Emissivie texture used to self-illuminate the model.
  108964. */
  108965. emissiveTexture: BaseTexture;
  108966. /**
  108967. * Occlusion Channel Strenght.
  108968. */
  108969. occlusionStrength: number;
  108970. /**
  108971. * Occlusion Texture of the material (adding extra occlusion effects).
  108972. */
  108973. occlusionTexture: BaseTexture;
  108974. /**
  108975. * Defines the alpha limits in alpha test mode.
  108976. */
  108977. alphaCutOff: number;
  108978. /**
  108979. * Gets the current double sided mode.
  108980. */
  108981. /**
  108982. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108983. */
  108984. doubleSided: boolean;
  108985. /**
  108986. * Stores the pre-calculated light information of a mesh in a texture.
  108987. */
  108988. lightmapTexture: BaseTexture;
  108989. /**
  108990. * If true, the light map contains occlusion information instead of lighting info.
  108991. */
  108992. useLightmapAsShadowmap: boolean;
  108993. /**
  108994. * Instantiates a new PBRMaterial instance.
  108995. *
  108996. * @param name The material name
  108997. * @param scene The scene the material will be use in.
  108998. */
  108999. constructor(name: string, scene: Scene);
  109000. getClassName(): string;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * The PBR material of BJS following the metal roughness convention.
  109006. *
  109007. * This fits to the PBR convention in the GLTF definition:
  109008. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  109009. */
  109010. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  109011. /**
  109012. * The base color has two different interpretations depending on the value of metalness.
  109013. * When the material is a metal, the base color is the specific measured reflectance value
  109014. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  109015. * of the material.
  109016. */
  109017. baseColor: Color3;
  109018. /**
  109019. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  109020. * well as opacity information in the alpha channel.
  109021. */
  109022. baseTexture: BaseTexture;
  109023. /**
  109024. * Specifies the metallic scalar value of the material.
  109025. * Can also be used to scale the metalness values of the metallic texture.
  109026. */
  109027. metallic: number;
  109028. /**
  109029. * Specifies the roughness scalar value of the material.
  109030. * Can also be used to scale the roughness values of the metallic texture.
  109031. */
  109032. roughness: number;
  109033. /**
  109034. * Texture containing both the metallic value in the B channel and the
  109035. * roughness value in the G channel to keep better precision.
  109036. */
  109037. metallicRoughnessTexture: BaseTexture;
  109038. /**
  109039. * Instantiates a new PBRMetalRoughnessMaterial instance.
  109040. *
  109041. * @param name The material name
  109042. * @param scene The scene the material will be use in.
  109043. */
  109044. constructor(name: string, scene: Scene);
  109045. /**
  109046. * Return the currrent class name of the material.
  109047. */
  109048. getClassName(): string;
  109049. /**
  109050. * Makes a duplicate of the current material.
  109051. * @param name - name to use for the new material.
  109052. */
  109053. clone(name: string): PBRMetallicRoughnessMaterial;
  109054. /**
  109055. * Serialize the material to a parsable JSON object.
  109056. */
  109057. serialize(): any;
  109058. /**
  109059. * Parses a JSON object correponding to the serialize function.
  109060. */
  109061. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  109062. }
  109063. }
  109064. declare module BABYLON {
  109065. /**
  109066. * The PBR material of BJS following the specular glossiness convention.
  109067. *
  109068. * This fits to the PBR convention in the GLTF definition:
  109069. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  109070. */
  109071. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  109072. /**
  109073. * Specifies the diffuse color of the material.
  109074. */
  109075. diffuseColor: Color3;
  109076. /**
  109077. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  109078. * channel.
  109079. */
  109080. diffuseTexture: BaseTexture;
  109081. /**
  109082. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  109083. */
  109084. specularColor: Color3;
  109085. /**
  109086. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  109087. */
  109088. glossiness: number;
  109089. /**
  109090. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  109091. */
  109092. specularGlossinessTexture: BaseTexture;
  109093. /**
  109094. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  109095. *
  109096. * @param name The material name
  109097. * @param scene The scene the material will be use in.
  109098. */
  109099. constructor(name: string, scene: Scene);
  109100. /**
  109101. * Return the currrent class name of the material.
  109102. */
  109103. getClassName(): string;
  109104. /**
  109105. * Makes a duplicate of the current material.
  109106. * @param name - name to use for the new material.
  109107. */
  109108. clone(name: string): PBRSpecularGlossinessMaterial;
  109109. /**
  109110. * Serialize the material to a parsable JSON object.
  109111. */
  109112. serialize(): any;
  109113. /**
  109114. * Parses a JSON object correponding to the serialize function.
  109115. */
  109116. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  109117. }
  109118. }
  109119. declare module BABYLON {
  109120. /**
  109121. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  109122. * It can help converting any input color in a desired output one. This can then be used to create effects
  109123. * from sepia, black and white to sixties or futuristic rendering...
  109124. *
  109125. * The only supported format is currently 3dl.
  109126. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  109127. */
  109128. export class ColorGradingTexture extends BaseTexture {
  109129. /**
  109130. * The current texture matrix. (will always be identity in color grading texture)
  109131. */
  109132. private _textureMatrix;
  109133. /**
  109134. * The texture URL.
  109135. */
  109136. url: string;
  109137. /**
  109138. * Empty line regex stored for GC.
  109139. */
  109140. private static _noneEmptyLineRegex;
  109141. private _engine;
  109142. /**
  109143. * Instantiates a ColorGradingTexture from the following parameters.
  109144. *
  109145. * @param url The location of the color gradind data (currently only supporting 3dl)
  109146. * @param scene The scene the texture will be used in
  109147. */
  109148. constructor(url: string, scene: Scene);
  109149. /**
  109150. * Returns the texture matrix used in most of the material.
  109151. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  109152. */
  109153. getTextureMatrix(): Matrix;
  109154. /**
  109155. * Occurs when the file being loaded is a .3dl LUT file.
  109156. */
  109157. private load3dlTexture;
  109158. /**
  109159. * Starts the loading process of the texture.
  109160. */
  109161. private loadTexture;
  109162. /**
  109163. * Clones the color gradind texture.
  109164. */
  109165. clone(): ColorGradingTexture;
  109166. /**
  109167. * Called during delayed load for textures.
  109168. */
  109169. delayLoad(): void;
  109170. /**
  109171. * Parses a color grading texture serialized by Babylon.
  109172. * @param parsedTexture The texture information being parsedTexture
  109173. * @param scene The scene to load the texture in
  109174. * @param rootUrl The root url of the data assets to load
  109175. * @return A color gradind texture
  109176. */
  109177. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  109178. /**
  109179. * Serializes the LUT texture to json format.
  109180. */
  109181. serialize(): any;
  109182. }
  109183. }
  109184. declare module BABYLON {
  109185. /**
  109186. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  109187. */
  109188. export class EquiRectangularCubeTexture extends BaseTexture {
  109189. /** The six faces of the cube. */
  109190. private static _FacesMapping;
  109191. private _noMipmap;
  109192. private _onLoad;
  109193. private _onError;
  109194. /** The size of the cubemap. */
  109195. private _size;
  109196. /** The buffer of the image. */
  109197. private _buffer;
  109198. /** The width of the input image. */
  109199. private _width;
  109200. /** The height of the input image. */
  109201. private _height;
  109202. /** The URL to the image. */
  109203. url: string;
  109204. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  109205. coordinatesMode: number;
  109206. /**
  109207. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  109208. * @param url The location of the image
  109209. * @param scene The scene the texture will be used in
  109210. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  109211. * @param noMipmap Forces to not generate the mipmap if true
  109212. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  109213. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  109214. * @param onLoad — defines a callback called when texture is loaded
  109215. * @param onError — defines a callback called if there is an error
  109216. */
  109217. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  109218. /**
  109219. * Load the image data, by putting the image on a canvas and extracting its buffer.
  109220. */
  109221. private loadImage;
  109222. /**
  109223. * Convert the image buffer into a cubemap and create a CubeTexture.
  109224. */
  109225. private loadTexture;
  109226. /**
  109227. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  109228. * @param buffer The ArrayBuffer that should be converted.
  109229. * @returns The buffer as Float32Array.
  109230. */
  109231. private getFloat32ArrayFromArrayBuffer;
  109232. /**
  109233. * Get the current class name of the texture useful for serialization or dynamic coding.
  109234. * @returns "EquiRectangularCubeTexture"
  109235. */
  109236. getClassName(): string;
  109237. /**
  109238. * Create a clone of the current EquiRectangularCubeTexture and return it.
  109239. * @returns A clone of the current EquiRectangularCubeTexture.
  109240. */
  109241. clone(): EquiRectangularCubeTexture;
  109242. }
  109243. }
  109244. declare module BABYLON {
  109245. /**
  109246. * Based on jsTGALoader - Javascript loader for TGA file
  109247. * By Vincent Thibault
  109248. * @see http://blog.robrowser.com/javascript-tga-loader.html
  109249. */
  109250. export class TGATools {
  109251. private static _TYPE_INDEXED;
  109252. private static _TYPE_RGB;
  109253. private static _TYPE_GREY;
  109254. private static _TYPE_RLE_INDEXED;
  109255. private static _TYPE_RLE_RGB;
  109256. private static _TYPE_RLE_GREY;
  109257. private static _ORIGIN_MASK;
  109258. private static _ORIGIN_SHIFT;
  109259. private static _ORIGIN_BL;
  109260. private static _ORIGIN_BR;
  109261. private static _ORIGIN_UL;
  109262. private static _ORIGIN_UR;
  109263. /**
  109264. * Gets the header of a TGA file
  109265. * @param data defines the TGA data
  109266. * @returns the header
  109267. */
  109268. static GetTGAHeader(data: Uint8Array): any;
  109269. /**
  109270. * Uploads TGA content to a Babylon Texture
  109271. * @hidden
  109272. */
  109273. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  109274. /** @hidden */
  109275. 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;
  109276. /** @hidden */
  109277. 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;
  109278. /** @hidden */
  109279. 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;
  109280. /** @hidden */
  109281. 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;
  109282. /** @hidden */
  109283. 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;
  109284. /** @hidden */
  109285. 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;
  109286. }
  109287. }
  109288. declare module BABYLON {
  109289. /**
  109290. * Implementation of the TGA Texture Loader.
  109291. * @hidden
  109292. */
  109293. export class _TGATextureLoader implements IInternalTextureLoader {
  109294. /**
  109295. * Defines wether the loader supports cascade loading the different faces.
  109296. */
  109297. readonly supportCascades: boolean;
  109298. /**
  109299. * This returns if the loader support the current file information.
  109300. * @param extension defines the file extension of the file being loaded
  109301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109302. * @param fallback defines the fallback internal texture if any
  109303. * @param isBase64 defines whether the texture is encoded as a base64
  109304. * @param isBuffer defines whether the texture data are stored as a buffer
  109305. * @returns true if the loader can load the specified file
  109306. */
  109307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109308. /**
  109309. * Transform the url before loading if required.
  109310. * @param rootUrl the url of the texture
  109311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109312. * @returns the transformed texture
  109313. */
  109314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109315. /**
  109316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109317. * @param rootUrl the url of the texture
  109318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109319. * @returns the fallback texture
  109320. */
  109321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109322. /**
  109323. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109324. * @param data contains the texture data
  109325. * @param texture defines the BabylonJS internal texture
  109326. * @param createPolynomials will be true if polynomials have been requested
  109327. * @param onLoad defines the callback to trigger once the texture is ready
  109328. * @param onError defines the callback to trigger in case of error
  109329. */
  109330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109331. /**
  109332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109333. * @param data contains the texture data
  109334. * @param texture defines the BabylonJS internal texture
  109335. * @param callback defines the method to call once ready to upload
  109336. */
  109337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109338. }
  109339. }
  109340. declare module BABYLON {
  109341. /**
  109342. * 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.
  109343. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109344. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109345. */
  109346. export class CustomProceduralTexture extends ProceduralTexture {
  109347. private _animate;
  109348. private _time;
  109349. private _config;
  109350. private _texturePath;
  109351. /**
  109352. * Instantiates a new Custom Procedural Texture.
  109353. * 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.
  109354. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  109355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  109356. * @param name Define the name of the texture
  109357. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  109358. * @param size Define the size of the texture to create
  109359. * @param scene Define the scene the texture belongs to
  109360. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  109361. * @param generateMipMaps Define if the texture should creates mip maps or not
  109362. */
  109363. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109364. private _loadJson;
  109365. /**
  109366. * Is the texture ready to be used ? (rendered at least once)
  109367. * @returns true if ready, otherwise, false.
  109368. */
  109369. isReady(): boolean;
  109370. /**
  109371. * Render the texture to its associated render target.
  109372. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  109373. */
  109374. render(useCameraPostProcess?: boolean): void;
  109375. /**
  109376. * Update the list of dependant textures samplers in the shader.
  109377. */
  109378. updateTextures(): void;
  109379. /**
  109380. * Update the uniform values of the procedural texture in the shader.
  109381. */
  109382. updateShaderUniforms(): void;
  109383. /**
  109384. * Define if the texture animates or not.
  109385. */
  109386. animate: boolean;
  109387. }
  109388. }
  109389. declare module BABYLON {
  109390. /** @hidden */
  109391. export var noisePixelShader: {
  109392. name: string;
  109393. shader: string;
  109394. };
  109395. }
  109396. declare module BABYLON {
  109397. /**
  109398. * Class used to generate noise procedural textures
  109399. */
  109400. export class NoiseProceduralTexture extends ProceduralTexture {
  109401. private _time;
  109402. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  109403. brightness: number;
  109404. /** Defines the number of octaves to process */
  109405. octaves: number;
  109406. /** Defines the level of persistence (0.8 by default) */
  109407. persistence: number;
  109408. /** Gets or sets animation speed factor (default is 1) */
  109409. animationSpeedFactor: number;
  109410. /**
  109411. * Creates a new NoiseProceduralTexture
  109412. * @param name defines the name fo the texture
  109413. * @param size defines the size of the texture (default is 256)
  109414. * @param scene defines the hosting scene
  109415. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  109416. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  109417. */
  109418. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  109419. private _updateShaderUniforms;
  109420. protected _getDefines(): string;
  109421. /** Generate the current state of the procedural texture */
  109422. render(useCameraPostProcess?: boolean): void;
  109423. /**
  109424. * Serializes this noise procedural texture
  109425. * @returns a serialized noise procedural texture object
  109426. */
  109427. serialize(): any;
  109428. /**
  109429. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  109430. * @param parsedTexture defines parsed texture data
  109431. * @param scene defines the current scene
  109432. * @param rootUrl defines the root URL containing noise procedural texture information
  109433. * @returns a parsed NoiseProceduralTexture
  109434. */
  109435. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  109436. }
  109437. }
  109438. declare module BABYLON {
  109439. /**
  109440. * Raw cube texture where the raw buffers are passed in
  109441. */
  109442. export class RawCubeTexture extends CubeTexture {
  109443. /**
  109444. * Creates a cube texture where the raw buffers are passed in.
  109445. * @param scene defines the scene the texture is attached to
  109446. * @param data defines the array of data to use to create each face
  109447. * @param size defines the size of the textures
  109448. * @param format defines the format of the data
  109449. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  109450. * @param generateMipMaps defines if the engine should generate the mip levels
  109451. * @param invertY defines if data must be stored with Y axis inverted
  109452. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  109453. * @param compression defines the compression used (null by default)
  109454. */
  109455. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  109456. /**
  109457. * Updates the raw cube texture.
  109458. * @param data defines the data to store
  109459. * @param format defines the data format
  109460. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  109461. * @param invertY defines if data must be stored with Y axis inverted
  109462. * @param compression defines the compression used (null by default)
  109463. * @param level defines which level of the texture to update
  109464. */
  109465. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  109466. /**
  109467. * Updates a raw cube texture with RGBD encoded data.
  109468. * @param data defines the array of data [mipmap][face] to use to create each face
  109469. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  109470. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109471. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109472. * @returns a promsie that resolves when the operation is complete
  109473. */
  109474. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  109475. /**
  109476. * Clones the raw cube texture.
  109477. * @return a new cube texture
  109478. */
  109479. clone(): CubeTexture;
  109480. /** @hidden */
  109481. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109482. }
  109483. }
  109484. declare module BABYLON {
  109485. /**
  109486. * Class used to store 3D textures containing user data
  109487. */
  109488. export class RawTexture3D extends Texture {
  109489. /** Gets or sets the texture format to use */
  109490. format: number;
  109491. private _engine;
  109492. /**
  109493. * Create a new RawTexture3D
  109494. * @param data defines the data of the texture
  109495. * @param width defines the width of the texture
  109496. * @param height defines the height of the texture
  109497. * @param depth defines the depth of the texture
  109498. * @param format defines the texture format to use
  109499. * @param scene defines the hosting scene
  109500. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  109501. * @param invertY defines if texture must be stored with Y axis inverted
  109502. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109503. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  109504. */
  109505. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  109506. /** Gets or sets the texture format to use */
  109507. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  109508. /**
  109509. * Update the texture with new data
  109510. * @param data defines the data to store in the texture
  109511. */
  109512. update(data: ArrayBufferView): void;
  109513. }
  109514. }
  109515. declare module BABYLON {
  109516. /**
  109517. * Creates a refraction texture used by refraction channel of the standard material.
  109518. * It is like a mirror but to see through a material.
  109519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109520. */
  109521. export class RefractionTexture extends RenderTargetTexture {
  109522. /**
  109523. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  109524. * 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.
  109525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109526. */
  109527. refractionPlane: Plane;
  109528. /**
  109529. * Define how deep under the surface we should see.
  109530. */
  109531. depth: number;
  109532. /**
  109533. * Creates a refraction texture used by refraction channel of the standard material.
  109534. * It is like a mirror but to see through a material.
  109535. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  109536. * @param name Define the texture name
  109537. * @param size Define the size of the underlying texture
  109538. * @param scene Define the scene the refraction belongs to
  109539. * @param generateMipMaps Define if we need to generate mips level for the refraction
  109540. */
  109541. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  109542. /**
  109543. * Clone the refraction texture.
  109544. * @returns the cloned texture
  109545. */
  109546. clone(): RefractionTexture;
  109547. /**
  109548. * Serialize the texture to a JSON representation you could use in Parse later on
  109549. * @returns the serialized JSON representation
  109550. */
  109551. serialize(): any;
  109552. }
  109553. }
  109554. declare module BABYLON {
  109555. /**
  109556. * Defines the options related to the creation of an HtmlElementTexture
  109557. */
  109558. export interface IHtmlElementTextureOptions {
  109559. /**
  109560. * Defines wether mip maps should be created or not.
  109561. */
  109562. generateMipMaps?: boolean;
  109563. /**
  109564. * Defines the sampling mode of the texture.
  109565. */
  109566. samplingMode?: number;
  109567. /**
  109568. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  109569. */
  109570. engine: Nullable<Engine>;
  109571. /**
  109572. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  109573. */
  109574. scene: Nullable<Scene>;
  109575. }
  109576. /**
  109577. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  109578. * To be as efficient as possible depending on your constraints nothing aside the first upload
  109579. * is automatically managed.
  109580. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  109581. * in your application.
  109582. *
  109583. * As the update is not automatic, you need to call them manually.
  109584. */
  109585. export class HtmlElementTexture extends BaseTexture {
  109586. /**
  109587. * The texture URL.
  109588. */
  109589. element: HTMLVideoElement | HTMLCanvasElement;
  109590. private static readonly DefaultOptions;
  109591. private _textureMatrix;
  109592. private _engine;
  109593. private _isVideo;
  109594. private _generateMipMaps;
  109595. private _samplingMode;
  109596. /**
  109597. * Instantiates a HtmlElementTexture from the following parameters.
  109598. *
  109599. * @param name Defines the name of the texture
  109600. * @param element Defines the video or canvas the texture is filled with
  109601. * @param options Defines the other none mandatory texture creation options
  109602. */
  109603. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  109604. private _createInternalTexture;
  109605. /**
  109606. * Returns the texture matrix used in most of the material.
  109607. */
  109608. getTextureMatrix(): Matrix;
  109609. /**
  109610. * Updates the content of the texture.
  109611. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  109612. */
  109613. update(invertY?: Nullable<boolean>): void;
  109614. }
  109615. }
  109616. declare module BABYLON {
  109617. /**
  109618. * Helper class to push actions to a pool of workers.
  109619. */
  109620. export class WorkerPool implements IDisposable {
  109621. private _workerInfos;
  109622. private _pendingActions;
  109623. /**
  109624. * Constructor
  109625. * @param workers Array of workers to use for actions
  109626. */
  109627. constructor(workers: Array<Worker>);
  109628. /**
  109629. * Terminates all workers and clears any pending actions.
  109630. */
  109631. dispose(): void;
  109632. /**
  109633. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109634. * pended until a worker has completed its action.
  109635. * @param action The action to perform. Call onComplete when the action is complete.
  109636. */
  109637. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109638. private _execute;
  109639. }
  109640. }
  109641. declare module BABYLON {
  109642. /**
  109643. * Configuration for Draco compression
  109644. */
  109645. export interface IDracoCompressionConfiguration {
  109646. /**
  109647. * Configuration for the decoder.
  109648. */
  109649. decoder?: {
  109650. /**
  109651. * The url to the WebAssembly module.
  109652. */
  109653. wasmUrl?: string;
  109654. /**
  109655. * The url to the WebAssembly binary.
  109656. */
  109657. wasmBinaryUrl?: string;
  109658. /**
  109659. * The url to the fallback JavaScript module.
  109660. */
  109661. fallbackUrl?: string;
  109662. };
  109663. }
  109664. /**
  109665. * Draco compression (https://google.github.io/draco/)
  109666. *
  109667. * This class wraps the Draco module.
  109668. *
  109669. * **Encoder**
  109670. *
  109671. * The encoder is not currently implemented.
  109672. *
  109673. * **Decoder**
  109674. *
  109675. * 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.
  109676. *
  109677. * To update the configuration, use the following code:
  109678. * ```javascript
  109679. * DracoCompression.Configuration = {
  109680. * decoder: {
  109681. * wasmUrl: "<url to the WebAssembly library>",
  109682. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109683. * fallbackUrl: "<url to the fallback JavaScript library>",
  109684. * }
  109685. * };
  109686. * ```
  109687. *
  109688. * 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.
  109689. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109690. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109691. *
  109692. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109693. * ```javascript
  109694. * var dracoCompression = new DracoCompression();
  109695. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109696. * [VertexBuffer.PositionKind]: 0
  109697. * });
  109698. * ```
  109699. *
  109700. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109701. */
  109702. export class DracoCompression implements IDisposable {
  109703. private _workerPoolPromise;
  109704. /**
  109705. * The configuration. Defaults to the following urls:
  109706. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109707. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109708. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109709. */
  109710. static Configuration: IDracoCompressionConfiguration;
  109711. /**
  109712. * Returns true if the decoder is available.
  109713. */
  109714. static readonly DecoderAvailable: boolean;
  109715. /**
  109716. * Default number of workers to create when creating the draco compression object.
  109717. */
  109718. static DefaultNumWorkers: number;
  109719. private static GetDefaultNumWorkers;
  109720. private static _Default;
  109721. /**
  109722. * Default instance for the draco compression object.
  109723. */
  109724. static readonly Default: DracoCompression;
  109725. /**
  109726. * Constructor
  109727. * @param numWorkers The number of workers for async operations
  109728. */
  109729. constructor(numWorkers?: number);
  109730. /**
  109731. * Stop all async operations and release resources.
  109732. */
  109733. dispose(): void;
  109734. /**
  109735. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109736. * @returns a promise that resolves when ready
  109737. */
  109738. whenReadyAsync(): Promise<void>;
  109739. /**
  109740. * Decode Draco compressed mesh data to vertex data.
  109741. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109742. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109743. * @returns A promise that resolves with the decoded vertex data
  109744. */
  109745. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109746. [kind: string]: number;
  109747. }): Promise<VertexData>;
  109748. /**
  109749. * The worker function that gets converted to a blob url to pass into a worker.
  109750. */
  109751. private static _Worker;
  109752. private _loadDecoderWasmBinaryAsync;
  109753. }
  109754. }
  109755. declare module BABYLON {
  109756. /**
  109757. * Class for building Constructive Solid Geometry
  109758. */
  109759. export class CSG {
  109760. private polygons;
  109761. /**
  109762. * The world matrix
  109763. */
  109764. matrix: Matrix;
  109765. /**
  109766. * Stores the position
  109767. */
  109768. position: Vector3;
  109769. /**
  109770. * Stores the rotation
  109771. */
  109772. rotation: Vector3;
  109773. /**
  109774. * Stores the rotation quaternion
  109775. */
  109776. rotationQuaternion: Nullable<Quaternion>;
  109777. /**
  109778. * Stores the scaling vector
  109779. */
  109780. scaling: Vector3;
  109781. /**
  109782. * Convert the Mesh to CSG
  109783. * @param mesh The Mesh to convert to CSG
  109784. * @returns A new CSG from the Mesh
  109785. */
  109786. static FromMesh(mesh: Mesh): CSG;
  109787. /**
  109788. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109789. * @param polygons Polygons used to construct a CSG solid
  109790. */
  109791. private static FromPolygons;
  109792. /**
  109793. * Clones, or makes a deep copy, of the CSG
  109794. * @returns A new CSG
  109795. */
  109796. clone(): CSG;
  109797. /**
  109798. * Unions this CSG with another CSG
  109799. * @param csg The CSG to union against this CSG
  109800. * @returns The unioned CSG
  109801. */
  109802. union(csg: CSG): CSG;
  109803. /**
  109804. * Unions this CSG with another CSG in place
  109805. * @param csg The CSG to union against this CSG
  109806. */
  109807. unionInPlace(csg: CSG): void;
  109808. /**
  109809. * Subtracts this CSG with another CSG
  109810. * @param csg The CSG to subtract against this CSG
  109811. * @returns A new CSG
  109812. */
  109813. subtract(csg: CSG): CSG;
  109814. /**
  109815. * Subtracts this CSG with another CSG in place
  109816. * @param csg The CSG to subtact against this CSG
  109817. */
  109818. subtractInPlace(csg: CSG): void;
  109819. /**
  109820. * Intersect this CSG with another CSG
  109821. * @param csg The CSG to intersect against this CSG
  109822. * @returns A new CSG
  109823. */
  109824. intersect(csg: CSG): CSG;
  109825. /**
  109826. * Intersects this CSG with another CSG in place
  109827. * @param csg The CSG to intersect against this CSG
  109828. */
  109829. intersectInPlace(csg: CSG): void;
  109830. /**
  109831. * Return a new CSG solid with solid and empty space switched. This solid is
  109832. * not modified.
  109833. * @returns A new CSG solid with solid and empty space switched
  109834. */
  109835. inverse(): CSG;
  109836. /**
  109837. * Inverses the CSG in place
  109838. */
  109839. inverseInPlace(): void;
  109840. /**
  109841. * This is used to keep meshes transformations so they can be restored
  109842. * when we build back a Babylon Mesh
  109843. * NB : All CSG operations are performed in world coordinates
  109844. * @param csg The CSG to copy the transform attributes from
  109845. * @returns This CSG
  109846. */
  109847. copyTransformAttributes(csg: CSG): CSG;
  109848. /**
  109849. * Build Raw mesh from CSG
  109850. * Coordinates here are in world space
  109851. * @param name The name of the mesh geometry
  109852. * @param scene The Scene
  109853. * @param keepSubMeshes Specifies if the submeshes should be kept
  109854. * @returns A new Mesh
  109855. */
  109856. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109857. /**
  109858. * Build Mesh from CSG taking material and transforms into account
  109859. * @param name The name of the Mesh
  109860. * @param material The material of the Mesh
  109861. * @param scene The Scene
  109862. * @param keepSubMeshes Specifies if submeshes should be kept
  109863. * @returns The new Mesh
  109864. */
  109865. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109866. }
  109867. }
  109868. declare module BABYLON {
  109869. /**
  109870. * Class used to create a trail following a mesh
  109871. */
  109872. export class TrailMesh extends Mesh {
  109873. private _generator;
  109874. private _autoStart;
  109875. private _running;
  109876. private _diameter;
  109877. private _length;
  109878. private _sectionPolygonPointsCount;
  109879. private _sectionVectors;
  109880. private _sectionNormalVectors;
  109881. private _beforeRenderObserver;
  109882. /**
  109883. * @constructor
  109884. * @param name The value used by scene.getMeshByName() to do a lookup.
  109885. * @param generator The mesh to generate a trail.
  109886. * @param scene The scene to add this mesh to.
  109887. * @param diameter Diameter of trailing mesh. Default is 1.
  109888. * @param length Length of trailing mesh. Default is 60.
  109889. * @param autoStart Automatically start trailing mesh. Default true.
  109890. */
  109891. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109892. /**
  109893. * "TrailMesh"
  109894. * @returns "TrailMesh"
  109895. */
  109896. getClassName(): string;
  109897. private _createMesh;
  109898. /**
  109899. * Start trailing mesh.
  109900. */
  109901. start(): void;
  109902. /**
  109903. * Stop trailing mesh.
  109904. */
  109905. stop(): void;
  109906. /**
  109907. * Update trailing mesh geometry.
  109908. */
  109909. update(): void;
  109910. /**
  109911. * Returns a new TrailMesh object.
  109912. * @param name is a string, the name given to the new mesh
  109913. * @param newGenerator use new generator object for cloned trail mesh
  109914. * @returns a new mesh
  109915. */
  109916. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109917. /**
  109918. * Serializes this trail mesh
  109919. * @param serializationObject object to write serialization to
  109920. */
  109921. serialize(serializationObject: any): void;
  109922. /**
  109923. * Parses a serialized trail mesh
  109924. * @param parsedMesh the serialized mesh
  109925. * @param scene the scene to create the trail mesh in
  109926. * @returns the created trail mesh
  109927. */
  109928. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109929. }
  109930. }
  109931. declare module BABYLON {
  109932. /**
  109933. * Class containing static functions to help procedurally build meshes
  109934. */
  109935. export class TorusKnotBuilder {
  109936. /**
  109937. * Creates a torus knot mesh
  109938. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109939. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109940. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109941. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109945. * @param name defines the name of the mesh
  109946. * @param options defines the options used to create the mesh
  109947. * @param scene defines the hosting scene
  109948. * @returns the torus knot mesh
  109949. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109950. */
  109951. static CreateTorusKnot(name: string, options: {
  109952. radius?: number;
  109953. tube?: number;
  109954. radialSegments?: number;
  109955. tubularSegments?: number;
  109956. p?: number;
  109957. q?: number;
  109958. updatable?: boolean;
  109959. sideOrientation?: number;
  109960. frontUVs?: Vector4;
  109961. backUVs?: Vector4;
  109962. }, scene: any): Mesh;
  109963. }
  109964. }
  109965. declare module BABYLON {
  109966. /**
  109967. * Polygon
  109968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109969. */
  109970. export class Polygon {
  109971. /**
  109972. * Creates a rectangle
  109973. * @param xmin bottom X coord
  109974. * @param ymin bottom Y coord
  109975. * @param xmax top X coord
  109976. * @param ymax top Y coord
  109977. * @returns points that make the resulting rectation
  109978. */
  109979. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109980. /**
  109981. * Creates a circle
  109982. * @param radius radius of circle
  109983. * @param cx scale in x
  109984. * @param cy scale in y
  109985. * @param numberOfSides number of sides that make up the circle
  109986. * @returns points that make the resulting circle
  109987. */
  109988. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109989. /**
  109990. * Creates a polygon from input string
  109991. * @param input Input polygon data
  109992. * @returns the parsed points
  109993. */
  109994. static Parse(input: string): Vector2[];
  109995. /**
  109996. * Starts building a polygon from x and y coordinates
  109997. * @param x x coordinate
  109998. * @param y y coordinate
  109999. * @returns the started path2
  110000. */
  110001. static StartingAt(x: number, y: number): Path2;
  110002. }
  110003. /**
  110004. * Builds a polygon
  110005. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  110006. */
  110007. export class PolygonMeshBuilder {
  110008. private _points;
  110009. private _outlinepoints;
  110010. private _holes;
  110011. private _name;
  110012. private _scene;
  110013. private _epoints;
  110014. private _eholes;
  110015. private _addToepoint;
  110016. /**
  110017. * Babylon reference to the earcut plugin.
  110018. */
  110019. bjsEarcut: any;
  110020. /**
  110021. * Creates a PolygonMeshBuilder
  110022. * @param name name of the builder
  110023. * @param contours Path of the polygon
  110024. * @param scene scene to add to when creating the mesh
  110025. * @param earcutInjection can be used to inject your own earcut reference
  110026. */
  110027. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  110028. /**
  110029. * Adds a whole within the polygon
  110030. * @param hole Array of points defining the hole
  110031. * @returns this
  110032. */
  110033. addHole(hole: Vector2[]): PolygonMeshBuilder;
  110034. /**
  110035. * Creates the polygon
  110036. * @param updatable If the mesh should be updatable
  110037. * @param depth The depth of the mesh created
  110038. * @returns the created mesh
  110039. */
  110040. build(updatable?: boolean, depth?: number): Mesh;
  110041. /**
  110042. * Creates the polygon
  110043. * @param depth The depth of the mesh created
  110044. * @returns the created VertexData
  110045. */
  110046. buildVertexData(depth?: number): VertexData;
  110047. /**
  110048. * Adds a side to the polygon
  110049. * @param positions points that make the polygon
  110050. * @param normals normals of the polygon
  110051. * @param uvs uvs of the polygon
  110052. * @param indices indices of the polygon
  110053. * @param bounds bounds of the polygon
  110054. * @param points points of the polygon
  110055. * @param depth depth of the polygon
  110056. * @param flip flip of the polygon
  110057. */
  110058. private addSide;
  110059. }
  110060. }
  110061. declare module BABYLON {
  110062. /**
  110063. * Class containing static functions to help procedurally build meshes
  110064. */
  110065. export class PolygonBuilder {
  110066. /**
  110067. * Creates a polygon mesh
  110068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110069. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  110070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110073. * * Remember you can only change the shape positions, not their number when updating a polygon
  110074. * @param name defines the name of the mesh
  110075. * @param options defines the options used to create the mesh
  110076. * @param scene defines the hosting scene
  110077. * @param earcutInjection can be used to inject your own earcut reference
  110078. * @returns the polygon mesh
  110079. */
  110080. static CreatePolygon(name: string, options: {
  110081. shape: Vector3[];
  110082. holes?: Vector3[][];
  110083. depth?: number;
  110084. faceUV?: Vector4[];
  110085. faceColors?: Color4[];
  110086. updatable?: boolean;
  110087. sideOrientation?: number;
  110088. frontUVs?: Vector4;
  110089. backUVs?: Vector4;
  110090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110091. /**
  110092. * Creates an extruded polygon mesh, with depth in the Y direction.
  110093. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  110094. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110095. * @param name defines the name of the mesh
  110096. * @param options defines the options used to create the mesh
  110097. * @param scene defines the hosting scene
  110098. * @param earcutInjection can be used to inject your own earcut reference
  110099. * @returns the polygon mesh
  110100. */
  110101. static ExtrudePolygon(name: string, options: {
  110102. shape: Vector3[];
  110103. holes?: Vector3[][];
  110104. depth?: number;
  110105. faceUV?: Vector4[];
  110106. faceColors?: Color4[];
  110107. updatable?: boolean;
  110108. sideOrientation?: number;
  110109. frontUVs?: Vector4;
  110110. backUVs?: Vector4;
  110111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110112. }
  110113. }
  110114. declare module BABYLON {
  110115. /**
  110116. * Class containing static functions to help procedurally build meshes
  110117. */
  110118. export class LatheBuilder {
  110119. /**
  110120. * Creates lathe mesh.
  110121. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110122. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  110123. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110124. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110125. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110126. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  110127. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110128. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110133. * @param name defines the name of the mesh
  110134. * @param options defines the options used to create the mesh
  110135. * @param scene defines the hosting scene
  110136. * @returns the lathe mesh
  110137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110138. */
  110139. static CreateLathe(name: string, options: {
  110140. shape: Vector3[];
  110141. radius?: number;
  110142. tessellation?: number;
  110143. clip?: number;
  110144. arc?: number;
  110145. closed?: boolean;
  110146. updatable?: boolean;
  110147. sideOrientation?: number;
  110148. frontUVs?: Vector4;
  110149. backUVs?: Vector4;
  110150. cap?: number;
  110151. invertUV?: boolean;
  110152. }, scene?: Nullable<Scene>): Mesh;
  110153. }
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * Class containing static functions to help procedurally build meshes
  110158. */
  110159. export class TubeBuilder {
  110160. /**
  110161. * Creates a tube mesh.
  110162. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110163. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110164. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110165. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110166. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110167. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  110168. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110169. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110170. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  110171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110175. * @param name defines the name of the mesh
  110176. * @param options defines the options used to create the mesh
  110177. * @param scene defines the hosting scene
  110178. * @returns the tube mesh
  110179. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110180. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110181. */
  110182. static CreateTube(name: string, options: {
  110183. path: Vector3[];
  110184. radius?: number;
  110185. tessellation?: number;
  110186. radiusFunction?: {
  110187. (i: number, distance: number): number;
  110188. };
  110189. cap?: number;
  110190. arc?: number;
  110191. updatable?: boolean;
  110192. sideOrientation?: number;
  110193. frontUVs?: Vector4;
  110194. backUVs?: Vector4;
  110195. instance?: Mesh;
  110196. invertUV?: boolean;
  110197. }, scene?: Nullable<Scene>): Mesh;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * Class containing static functions to help procedurally build meshes
  110203. */
  110204. export class IcoSphereBuilder {
  110205. /**
  110206. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110207. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110208. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  110209. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110210. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  110211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110214. * @param name defines the name of the mesh
  110215. * @param options defines the options used to create the mesh
  110216. * @param scene defines the hosting scene
  110217. * @returns the icosahedron mesh
  110218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110219. */
  110220. static CreateIcoSphere(name: string, options: {
  110221. radius?: number;
  110222. radiusX?: number;
  110223. radiusY?: number;
  110224. radiusZ?: number;
  110225. flat?: boolean;
  110226. subdivisions?: number;
  110227. sideOrientation?: number;
  110228. frontUVs?: Vector4;
  110229. backUVs?: Vector4;
  110230. updatable?: boolean;
  110231. }, scene?: Nullable<Scene>): Mesh;
  110232. }
  110233. }
  110234. declare module BABYLON {
  110235. /**
  110236. * Class containing static functions to help procedurally build meshes
  110237. */
  110238. export class DecalBuilder {
  110239. /**
  110240. * Creates a decal mesh.
  110241. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  110242. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110243. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110244. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110245. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110246. * @param name defines the name of the mesh
  110247. * @param sourceMesh defines the mesh where the decal must be applied
  110248. * @param options defines the options used to create the mesh
  110249. * @param scene defines the hosting scene
  110250. * @returns the decal mesh
  110251. * @see https://doc.babylonjs.com/how_to/decals
  110252. */
  110253. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110254. position?: Vector3;
  110255. normal?: Vector3;
  110256. size?: Vector3;
  110257. angle?: number;
  110258. }): Mesh;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Class containing static functions to help procedurally build meshes
  110264. */
  110265. export class MeshBuilder {
  110266. /**
  110267. * Creates a box mesh
  110268. * * The parameter `size` sets the size (float) of each box side (default 1)
  110269. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110270. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  110271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110275. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110276. * @param name defines the name of the mesh
  110277. * @param options defines the options used to create the mesh
  110278. * @param scene defines the hosting scene
  110279. * @returns the box mesh
  110280. */
  110281. static CreateBox(name: string, options: {
  110282. size?: number;
  110283. width?: number;
  110284. height?: number;
  110285. depth?: number;
  110286. faceUV?: Vector4[];
  110287. faceColors?: Color4[];
  110288. sideOrientation?: number;
  110289. frontUVs?: Vector4;
  110290. backUVs?: Vector4;
  110291. updatable?: boolean;
  110292. }, scene?: Nullable<Scene>): Mesh;
  110293. /**
  110294. * Creates a sphere mesh
  110295. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110296. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  110297. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110298. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  110299. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  110300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110303. * @param name defines the name of the mesh
  110304. * @param options defines the options used to create the mesh
  110305. * @param scene defines the hosting scene
  110306. * @returns the sphere mesh
  110307. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110308. */
  110309. static CreateSphere(name: string, options: {
  110310. segments?: number;
  110311. diameter?: number;
  110312. diameterX?: number;
  110313. diameterY?: number;
  110314. diameterZ?: number;
  110315. arc?: number;
  110316. slice?: number;
  110317. sideOrientation?: number;
  110318. frontUVs?: Vector4;
  110319. backUVs?: Vector4;
  110320. updatable?: boolean;
  110321. }, scene?: Nullable<Scene>): Mesh;
  110322. /**
  110323. * Creates a plane polygonal mesh. By default, this is a disc
  110324. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110325. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  110326. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  110327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110330. * @param name defines the name of the mesh
  110331. * @param options defines the options used to create the mesh
  110332. * @param scene defines the hosting scene
  110333. * @returns the plane polygonal mesh
  110334. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110335. */
  110336. static CreateDisc(name: string, options: {
  110337. radius?: number;
  110338. tessellation?: number;
  110339. arc?: number;
  110340. updatable?: boolean;
  110341. sideOrientation?: number;
  110342. frontUVs?: Vector4;
  110343. backUVs?: Vector4;
  110344. }, scene?: Nullable<Scene>): Mesh;
  110345. /**
  110346. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  110347. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  110348. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  110349. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  110350. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  110351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110354. * @param name defines the name of the mesh
  110355. * @param options defines the options used to create the mesh
  110356. * @param scene defines the hosting scene
  110357. * @returns the icosahedron mesh
  110358. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  110359. */
  110360. static CreateIcoSphere(name: string, options: {
  110361. radius?: number;
  110362. radiusX?: number;
  110363. radiusY?: number;
  110364. radiusZ?: number;
  110365. flat?: boolean;
  110366. subdivisions?: number;
  110367. sideOrientation?: number;
  110368. frontUVs?: Vector4;
  110369. backUVs?: Vector4;
  110370. updatable?: boolean;
  110371. }, scene?: Nullable<Scene>): Mesh;
  110372. /**
  110373. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110374. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110375. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110376. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110377. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  110378. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  110379. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  110380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110383. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  110384. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110385. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  110386. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110388. * @param name defines the name of the mesh
  110389. * @param options defines the options used to create the mesh
  110390. * @param scene defines the hosting scene
  110391. * @returns the ribbon mesh
  110392. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110393. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110394. */
  110395. static CreateRibbon(name: string, options: {
  110396. pathArray: Vector3[][];
  110397. closeArray?: boolean;
  110398. closePath?: boolean;
  110399. offset?: number;
  110400. updatable?: boolean;
  110401. sideOrientation?: number;
  110402. frontUVs?: Vector4;
  110403. backUVs?: Vector4;
  110404. instance?: Mesh;
  110405. invertUV?: boolean;
  110406. uvs?: Vector2[];
  110407. colors?: Color4[];
  110408. }, scene?: Nullable<Scene>): Mesh;
  110409. /**
  110410. * Creates a cylinder or a cone mesh
  110411. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110412. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110413. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  110414. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110415. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110416. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110417. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110418. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110419. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  110420. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  110421. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110422. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  110423. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  110424. * * If `enclose` is false, a ring surface is one element.
  110425. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110426. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  110427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110430. * @param name defines the name of the mesh
  110431. * @param options defines the options used to create the mesh
  110432. * @param scene defines the hosting scene
  110433. * @returns the cylinder mesh
  110434. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110435. */
  110436. static CreateCylinder(name: string, options: {
  110437. height?: number;
  110438. diameterTop?: number;
  110439. diameterBottom?: number;
  110440. diameter?: number;
  110441. tessellation?: number;
  110442. subdivisions?: number;
  110443. arc?: number;
  110444. faceColors?: Color4[];
  110445. faceUV?: Vector4[];
  110446. updatable?: boolean;
  110447. hasRings?: boolean;
  110448. enclose?: boolean;
  110449. sideOrientation?: number;
  110450. frontUVs?: Vector4;
  110451. backUVs?: Vector4;
  110452. }, scene?: Nullable<Scene>): Mesh;
  110453. /**
  110454. * Creates a torus mesh
  110455. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110456. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110457. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110461. * @param name defines the name of the mesh
  110462. * @param options defines the options used to create the mesh
  110463. * @param scene defines the hosting scene
  110464. * @returns the torus mesh
  110465. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110466. */
  110467. static CreateTorus(name: string, options: {
  110468. diameter?: number;
  110469. thickness?: number;
  110470. tessellation?: number;
  110471. updatable?: boolean;
  110472. sideOrientation?: number;
  110473. frontUVs?: Vector4;
  110474. backUVs?: Vector4;
  110475. }, scene?: Nullable<Scene>): Mesh;
  110476. /**
  110477. * Creates a torus knot mesh
  110478. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  110479. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  110480. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  110481. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  110482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110485. * @param name defines the name of the mesh
  110486. * @param options defines the options used to create the mesh
  110487. * @param scene defines the hosting scene
  110488. * @returns the torus knot mesh
  110489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  110490. */
  110491. static CreateTorusKnot(name: string, options: {
  110492. radius?: number;
  110493. tube?: number;
  110494. radialSegments?: number;
  110495. tubularSegments?: number;
  110496. p?: number;
  110497. q?: number;
  110498. updatable?: boolean;
  110499. sideOrientation?: number;
  110500. frontUVs?: Vector4;
  110501. backUVs?: Vector4;
  110502. }, scene?: Nullable<Scene>): Mesh;
  110503. /**
  110504. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110505. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  110506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110507. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110508. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110509. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110511. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  110512. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110515. * @param name defines the name of the new line system
  110516. * @param options defines the options used to create the line system
  110517. * @param scene defines the hosting scene
  110518. * @returns a new line system mesh
  110519. */
  110520. static CreateLineSystem(name: string, options: {
  110521. lines: Vector3[][];
  110522. updatable?: boolean;
  110523. instance?: Nullable<LinesMesh>;
  110524. colors?: Nullable<Color4[][]>;
  110525. useVertexAlpha?: boolean;
  110526. }, scene: Nullable<Scene>): LinesMesh;
  110527. /**
  110528. * Creates a line mesh
  110529. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  110530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110531. * * The parameter `points` is an array successive Vector3
  110532. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  110533. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110535. * * When updating an instance, remember that only point positions can change, not the number of points
  110536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110538. * @param name defines the name of the new line system
  110539. * @param options defines the options used to create the line system
  110540. * @param scene defines the hosting scene
  110541. * @returns a new line mesh
  110542. */
  110543. static CreateLines(name: string, options: {
  110544. points: Vector3[];
  110545. updatable?: boolean;
  110546. instance?: Nullable<LinesMesh>;
  110547. colors?: Color4[];
  110548. useVertexAlpha?: boolean;
  110549. }, scene?: Nullable<Scene>): LinesMesh;
  110550. /**
  110551. * Creates a dashed line mesh
  110552. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  110553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110554. * * The parameter `points` is an array successive Vector3
  110555. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110556. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110557. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110558. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  110559. * * When updating an instance, remember that only point positions can change, not the number of points
  110560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110561. * @param name defines the name of the mesh
  110562. * @param options defines the options used to create the mesh
  110563. * @param scene defines the hosting scene
  110564. * @returns the dashed line mesh
  110565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110566. */
  110567. static CreateDashedLines(name: string, options: {
  110568. points: Vector3[];
  110569. dashSize?: number;
  110570. gapSize?: number;
  110571. dashNb?: number;
  110572. updatable?: boolean;
  110573. instance?: LinesMesh;
  110574. }, scene?: Nullable<Scene>): LinesMesh;
  110575. /**
  110576. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110577. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  110578. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110579. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  110580. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110581. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110582. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  110583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110588. * @param name defines the name of the mesh
  110589. * @param options defines the options used to create the mesh
  110590. * @param scene defines the hosting scene
  110591. * @returns the extruded shape mesh
  110592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110594. */
  110595. static ExtrudeShape(name: string, options: {
  110596. shape: Vector3[];
  110597. path: Vector3[];
  110598. scale?: number;
  110599. rotation?: number;
  110600. cap?: number;
  110601. updatable?: boolean;
  110602. sideOrientation?: number;
  110603. frontUVs?: Vector4;
  110604. backUVs?: Vector4;
  110605. instance?: Mesh;
  110606. invertUV?: boolean;
  110607. }, scene?: Nullable<Scene>): Mesh;
  110608. /**
  110609. * Creates an custom extruded shape mesh.
  110610. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110611. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  110612. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110613. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  110614. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110615. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  110616. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110617. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110618. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110619. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110620. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  110621. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110624. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110626. * @param name defines the name of the mesh
  110627. * @param options defines the options used to create the mesh
  110628. * @param scene defines the hosting scene
  110629. * @returns the custom extruded shape mesh
  110630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110633. */
  110634. static ExtrudeShapeCustom(name: string, options: {
  110635. shape: Vector3[];
  110636. path: Vector3[];
  110637. scaleFunction?: any;
  110638. rotationFunction?: any;
  110639. ribbonCloseArray?: boolean;
  110640. ribbonClosePath?: boolean;
  110641. cap?: number;
  110642. updatable?: boolean;
  110643. sideOrientation?: number;
  110644. frontUVs?: Vector4;
  110645. backUVs?: Vector4;
  110646. instance?: Mesh;
  110647. invertUV?: boolean;
  110648. }, scene?: Nullable<Scene>): Mesh;
  110649. /**
  110650. * Creates lathe mesh.
  110651. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  110652. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  110653. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  110654. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  110655. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  110656. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  110657. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  110658. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110663. * @param name defines the name of the mesh
  110664. * @param options defines the options used to create the mesh
  110665. * @param scene defines the hosting scene
  110666. * @returns the lathe mesh
  110667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  110668. */
  110669. static CreateLathe(name: string, options: {
  110670. shape: Vector3[];
  110671. radius?: number;
  110672. tessellation?: number;
  110673. clip?: number;
  110674. arc?: number;
  110675. closed?: boolean;
  110676. updatable?: boolean;
  110677. sideOrientation?: number;
  110678. frontUVs?: Vector4;
  110679. backUVs?: Vector4;
  110680. cap?: number;
  110681. invertUV?: boolean;
  110682. }, scene?: Nullable<Scene>): Mesh;
  110683. /**
  110684. * Creates a plane mesh
  110685. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110686. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110687. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110691. * @param name defines the name of the mesh
  110692. * @param options defines the options used to create the mesh
  110693. * @param scene defines the hosting scene
  110694. * @returns the plane mesh
  110695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110696. */
  110697. static CreatePlane(name: string, options: {
  110698. size?: number;
  110699. width?: number;
  110700. height?: number;
  110701. sideOrientation?: number;
  110702. frontUVs?: Vector4;
  110703. backUVs?: Vector4;
  110704. updatable?: boolean;
  110705. sourcePlane?: Plane;
  110706. }, scene?: Nullable<Scene>): Mesh;
  110707. /**
  110708. * Creates a ground mesh
  110709. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110710. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110712. * @param name defines the name of the mesh
  110713. * @param options defines the options used to create the mesh
  110714. * @param scene defines the hosting scene
  110715. * @returns the ground mesh
  110716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110717. */
  110718. static CreateGround(name: string, options: {
  110719. width?: number;
  110720. height?: number;
  110721. subdivisions?: number;
  110722. subdivisionsX?: number;
  110723. subdivisionsY?: number;
  110724. updatable?: boolean;
  110725. }, scene?: Nullable<Scene>): Mesh;
  110726. /**
  110727. * Creates a tiled ground mesh
  110728. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110729. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110730. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  110731. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  110732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110733. * @param name defines the name of the mesh
  110734. * @param options defines the options used to create the mesh
  110735. * @param scene defines the hosting scene
  110736. * @returns the tiled ground mesh
  110737. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110738. */
  110739. static CreateTiledGround(name: string, options: {
  110740. xmin: number;
  110741. zmin: number;
  110742. xmax: number;
  110743. zmax: number;
  110744. subdivisions?: {
  110745. w: number;
  110746. h: number;
  110747. };
  110748. precision?: {
  110749. w: number;
  110750. h: number;
  110751. };
  110752. updatable?: boolean;
  110753. }, scene?: Nullable<Scene>): Mesh;
  110754. /**
  110755. * Creates a ground mesh from a height map
  110756. * * The parameter `url` sets the URL of the height map image resource.
  110757. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110758. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110759. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110760. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110761. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  110762. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  110763. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110765. * @param name defines the name of the mesh
  110766. * @param url defines the url to the height map
  110767. * @param options defines the options used to create the mesh
  110768. * @param scene defines the hosting scene
  110769. * @returns the ground mesh
  110770. * @see https://doc.babylonjs.com/babylon101/height_map
  110771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110772. */
  110773. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110774. width?: number;
  110775. height?: number;
  110776. subdivisions?: number;
  110777. minHeight?: number;
  110778. maxHeight?: number;
  110779. colorFilter?: Color3;
  110780. alphaFilter?: number;
  110781. updatable?: boolean;
  110782. onReady?: (mesh: GroundMesh) => void;
  110783. }, scene?: Nullable<Scene>): GroundMesh;
  110784. /**
  110785. * Creates a polygon mesh
  110786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110787. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  110788. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110791. * * Remember you can only change the shape positions, not their number when updating a polygon
  110792. * @param name defines the name of the mesh
  110793. * @param options defines the options used to create the mesh
  110794. * @param scene defines the hosting scene
  110795. * @param earcutInjection can be used to inject your own earcut reference
  110796. * @returns the polygon mesh
  110797. */
  110798. static CreatePolygon(name: string, options: {
  110799. shape: Vector3[];
  110800. holes?: Vector3[][];
  110801. depth?: number;
  110802. faceUV?: Vector4[];
  110803. faceColors?: Color4[];
  110804. updatable?: boolean;
  110805. sideOrientation?: number;
  110806. frontUVs?: Vector4;
  110807. backUVs?: Vector4;
  110808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110809. /**
  110810. * Creates an extruded polygon mesh, with depth in the Y direction.
  110811. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  110812. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110813. * @param name defines the name of the mesh
  110814. * @param options defines the options used to create the mesh
  110815. * @param scene defines the hosting scene
  110816. * @param earcutInjection can be used to inject your own earcut reference
  110817. * @returns the polygon mesh
  110818. */
  110819. static ExtrudePolygon(name: string, options: {
  110820. shape: Vector3[];
  110821. holes?: Vector3[][];
  110822. depth?: number;
  110823. faceUV?: Vector4[];
  110824. faceColors?: Color4[];
  110825. updatable?: boolean;
  110826. sideOrientation?: number;
  110827. frontUVs?: Vector4;
  110828. backUVs?: Vector4;
  110829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110830. /**
  110831. * Creates a tube mesh.
  110832. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110833. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110834. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110835. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110836. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110837. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  110838. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110839. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  110840. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  110841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110845. * @param name defines the name of the mesh
  110846. * @param options defines the options used to create the mesh
  110847. * @param scene defines the hosting scene
  110848. * @returns the tube mesh
  110849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110850. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110851. */
  110852. static CreateTube(name: string, options: {
  110853. path: Vector3[];
  110854. radius?: number;
  110855. tessellation?: number;
  110856. radiusFunction?: {
  110857. (i: number, distance: number): number;
  110858. };
  110859. cap?: number;
  110860. arc?: number;
  110861. updatable?: boolean;
  110862. sideOrientation?: number;
  110863. frontUVs?: Vector4;
  110864. backUVs?: Vector4;
  110865. instance?: Mesh;
  110866. invertUV?: boolean;
  110867. }, scene?: Nullable<Scene>): Mesh;
  110868. /**
  110869. * Creates a polyhedron mesh
  110870. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  110871. * * The parameter `size` (positive float, default 1) sets the polygon size
  110872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110873. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  110874. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  110875. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  110876. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110877. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  110878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110881. * @param name defines the name of the mesh
  110882. * @param options defines the options used to create the mesh
  110883. * @param scene defines the hosting scene
  110884. * @returns the polyhedron mesh
  110885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110886. */
  110887. static CreatePolyhedron(name: string, options: {
  110888. type?: number;
  110889. size?: number;
  110890. sizeX?: number;
  110891. sizeY?: number;
  110892. sizeZ?: number;
  110893. custom?: any;
  110894. faceUV?: Vector4[];
  110895. faceColors?: Color4[];
  110896. flat?: boolean;
  110897. updatable?: boolean;
  110898. sideOrientation?: number;
  110899. frontUVs?: Vector4;
  110900. backUVs?: Vector4;
  110901. }, scene?: Nullable<Scene>): Mesh;
  110902. /**
  110903. * Creates a decal mesh.
  110904. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  110905. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110906. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110907. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110908. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110909. * @param name defines the name of the mesh
  110910. * @param sourceMesh defines the mesh where the decal must be applied
  110911. * @param options defines the options used to create the mesh
  110912. * @param scene defines the hosting scene
  110913. * @returns the decal mesh
  110914. * @see https://doc.babylonjs.com/how_to/decals
  110915. */
  110916. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110917. position?: Vector3;
  110918. normal?: Vector3;
  110919. size?: Vector3;
  110920. angle?: number;
  110921. }): Mesh;
  110922. }
  110923. }
  110924. declare module BABYLON {
  110925. /**
  110926. * A simplifier interface for future simplification implementations
  110927. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110928. */
  110929. export interface ISimplifier {
  110930. /**
  110931. * Simplification of a given mesh according to the given settings.
  110932. * Since this requires computation, it is assumed that the function runs async.
  110933. * @param settings The settings of the simplification, including quality and distance
  110934. * @param successCallback A callback that will be called after the mesh was simplified.
  110935. * @param errorCallback in case of an error, this callback will be called. optional.
  110936. */
  110937. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110938. }
  110939. /**
  110940. * Expected simplification settings.
  110941. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110943. */
  110944. export interface ISimplificationSettings {
  110945. /**
  110946. * Gets or sets the expected quality
  110947. */
  110948. quality: number;
  110949. /**
  110950. * Gets or sets the distance when this optimized version should be used
  110951. */
  110952. distance: number;
  110953. /**
  110954. * Gets an already optimized mesh
  110955. */
  110956. optimizeMesh?: boolean;
  110957. }
  110958. /**
  110959. * Class used to specify simplification options
  110960. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110961. */
  110962. export class SimplificationSettings implements ISimplificationSettings {
  110963. /** expected quality */
  110964. quality: number;
  110965. /** distance when this optimized version should be used */
  110966. distance: number;
  110967. /** already optimized mesh */
  110968. optimizeMesh?: boolean | undefined;
  110969. /**
  110970. * Creates a SimplificationSettings
  110971. * @param quality expected quality
  110972. * @param distance distance when this optimized version should be used
  110973. * @param optimizeMesh already optimized mesh
  110974. */
  110975. constructor(
  110976. /** expected quality */
  110977. quality: number,
  110978. /** distance when this optimized version should be used */
  110979. distance: number,
  110980. /** already optimized mesh */
  110981. optimizeMesh?: boolean | undefined);
  110982. }
  110983. /**
  110984. * Interface used to define a simplification task
  110985. */
  110986. export interface ISimplificationTask {
  110987. /**
  110988. * Array of settings
  110989. */
  110990. settings: Array<ISimplificationSettings>;
  110991. /**
  110992. * Simplification type
  110993. */
  110994. simplificationType: SimplificationType;
  110995. /**
  110996. * Mesh to simplify
  110997. */
  110998. mesh: Mesh;
  110999. /**
  111000. * Callback called on success
  111001. */
  111002. successCallback?: () => void;
  111003. /**
  111004. * Defines if parallel processing can be used
  111005. */
  111006. parallelProcessing: boolean;
  111007. }
  111008. /**
  111009. * Queue used to order the simplification tasks
  111010. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111011. */
  111012. export class SimplificationQueue {
  111013. private _simplificationArray;
  111014. /**
  111015. * Gets a boolean indicating that the process is still running
  111016. */
  111017. running: boolean;
  111018. /**
  111019. * Creates a new queue
  111020. */
  111021. constructor();
  111022. /**
  111023. * Adds a new simplification task
  111024. * @param task defines a task to add
  111025. */
  111026. addTask(task: ISimplificationTask): void;
  111027. /**
  111028. * Execute next task
  111029. */
  111030. executeNext(): void;
  111031. /**
  111032. * Execute a simplification task
  111033. * @param task defines the task to run
  111034. */
  111035. runSimplification(task: ISimplificationTask): void;
  111036. private getSimplifier;
  111037. }
  111038. /**
  111039. * The implemented types of simplification
  111040. * At the moment only Quadratic Error Decimation is implemented
  111041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111042. */
  111043. export enum SimplificationType {
  111044. /** Quadratic error decimation */
  111045. QUADRATIC = 0
  111046. }
  111047. }
  111048. declare module BABYLON {
  111049. interface Scene {
  111050. /** @hidden (Backing field) */
  111051. _simplificationQueue: SimplificationQueue;
  111052. /**
  111053. * Gets or sets the simplification queue attached to the scene
  111054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  111055. */
  111056. simplificationQueue: SimplificationQueue;
  111057. }
  111058. interface Mesh {
  111059. /**
  111060. * Simplify the mesh according to the given array of settings.
  111061. * Function will return immediately and will simplify async
  111062. * @param settings a collection of simplification settings
  111063. * @param parallelProcessing should all levels calculate parallel or one after the other
  111064. * @param simplificationType the type of simplification to run
  111065. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  111066. * @returns the current mesh
  111067. */
  111068. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  111069. }
  111070. /**
  111071. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  111072. * created in a scene
  111073. */
  111074. export class SimplicationQueueSceneComponent implements ISceneComponent {
  111075. /**
  111076. * The component name helpfull to identify the component in the list of scene components.
  111077. */
  111078. readonly name: string;
  111079. /**
  111080. * The scene the component belongs to.
  111081. */
  111082. scene: Scene;
  111083. /**
  111084. * Creates a new instance of the component for the given scene
  111085. * @param scene Defines the scene to register the component in
  111086. */
  111087. constructor(scene: Scene);
  111088. /**
  111089. * Registers the component in a given scene
  111090. */
  111091. register(): void;
  111092. /**
  111093. * Rebuilds the elements related to this component in case of
  111094. * context lost for instance.
  111095. */
  111096. rebuild(): void;
  111097. /**
  111098. * Disposes the component and the associated ressources
  111099. */
  111100. dispose(): void;
  111101. private _beforeCameraUpdate;
  111102. }
  111103. }
  111104. declare module BABYLON {
  111105. /**
  111106. * Class used to enable access to IndexedDB
  111107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  111108. */
  111109. export class Database implements IOfflineProvider {
  111110. private _callbackManifestChecked;
  111111. private _currentSceneUrl;
  111112. private _db;
  111113. private _enableSceneOffline;
  111114. private _enableTexturesOffline;
  111115. private _manifestVersionFound;
  111116. private _mustUpdateRessources;
  111117. private _hasReachedQuota;
  111118. private _isSupported;
  111119. private _idbFactory;
  111120. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  111121. private static IsUASupportingBlobStorage;
  111122. /**
  111123. * Gets a boolean indicating if Database storate is enabled (off by default)
  111124. */
  111125. static IDBStorageEnabled: boolean;
  111126. /**
  111127. * Gets a boolean indicating if scene must be saved in the database
  111128. */
  111129. readonly enableSceneOffline: boolean;
  111130. /**
  111131. * Gets a boolean indicating if textures must be saved in the database
  111132. */
  111133. readonly enableTexturesOffline: boolean;
  111134. /**
  111135. * Creates a new Database
  111136. * @param urlToScene defines the url to load the scene
  111137. * @param callbackManifestChecked defines the callback to use when manifest is checked
  111138. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  111139. */
  111140. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  111141. private static _ParseURL;
  111142. private static _ReturnFullUrlLocation;
  111143. private _checkManifestFile;
  111144. /**
  111145. * Open the database and make it available
  111146. * @param successCallback defines the callback to call on success
  111147. * @param errorCallback defines the callback to call on error
  111148. */
  111149. open(successCallback: () => void, errorCallback: () => void): void;
  111150. /**
  111151. * Loads an image from the database
  111152. * @param url defines the url to load from
  111153. * @param image defines the target DOM image
  111154. */
  111155. loadImage(url: string, image: HTMLImageElement): void;
  111156. private _loadImageFromDBAsync;
  111157. private _saveImageIntoDBAsync;
  111158. private _checkVersionFromDB;
  111159. private _loadVersionFromDBAsync;
  111160. private _saveVersionIntoDBAsync;
  111161. /**
  111162. * Loads a file from database
  111163. * @param url defines the URL to load from
  111164. * @param sceneLoaded defines a callback to call on success
  111165. * @param progressCallBack defines a callback to call when progress changed
  111166. * @param errorCallback defines a callback to call on error
  111167. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  111168. */
  111169. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  111170. private _loadFileAsync;
  111171. private _saveFileAsync;
  111172. /**
  111173. * Validates if xhr data is correct
  111174. * @param xhr defines the request to validate
  111175. * @param dataType defines the expected data type
  111176. * @returns true if data is correct
  111177. */
  111178. private static _ValidateXHRData;
  111179. }
  111180. }
  111181. declare module BABYLON {
  111182. /** @hidden */
  111183. export var gpuUpdateParticlesPixelShader: {
  111184. name: string;
  111185. shader: string;
  111186. };
  111187. }
  111188. declare module BABYLON {
  111189. /** @hidden */
  111190. export var gpuUpdateParticlesVertexShader: {
  111191. name: string;
  111192. shader: string;
  111193. };
  111194. }
  111195. declare module BABYLON {
  111196. /** @hidden */
  111197. export var clipPlaneFragmentDeclaration2: {
  111198. name: string;
  111199. shader: string;
  111200. };
  111201. }
  111202. declare module BABYLON {
  111203. /** @hidden */
  111204. export var gpuRenderParticlesPixelShader: {
  111205. name: string;
  111206. shader: string;
  111207. };
  111208. }
  111209. declare module BABYLON {
  111210. /** @hidden */
  111211. export var clipPlaneVertexDeclaration2: {
  111212. name: string;
  111213. shader: string;
  111214. };
  111215. }
  111216. declare module BABYLON {
  111217. /** @hidden */
  111218. export var gpuRenderParticlesVertexShader: {
  111219. name: string;
  111220. shader: string;
  111221. };
  111222. }
  111223. declare module BABYLON {
  111224. /**
  111225. * This represents a GPU particle system in Babylon
  111226. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  111227. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  111228. */
  111229. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  111230. /**
  111231. * The layer mask we are rendering the particles through.
  111232. */
  111233. layerMask: number;
  111234. private _capacity;
  111235. private _activeCount;
  111236. private _currentActiveCount;
  111237. private _accumulatedCount;
  111238. private _renderEffect;
  111239. private _updateEffect;
  111240. private _buffer0;
  111241. private _buffer1;
  111242. private _spriteBuffer;
  111243. private _updateVAO;
  111244. private _renderVAO;
  111245. private _targetIndex;
  111246. private _sourceBuffer;
  111247. private _targetBuffer;
  111248. private _engine;
  111249. private _currentRenderId;
  111250. private _started;
  111251. private _stopped;
  111252. private _timeDelta;
  111253. private _randomTexture;
  111254. private _randomTexture2;
  111255. private _attributesStrideSize;
  111256. private _updateEffectOptions;
  111257. private _randomTextureSize;
  111258. private _actualFrame;
  111259. private readonly _rawTextureWidth;
  111260. /**
  111261. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  111262. */
  111263. static readonly IsSupported: boolean;
  111264. /**
  111265. * An event triggered when the system is disposed.
  111266. */
  111267. onDisposeObservable: Observable<GPUParticleSystem>;
  111268. /**
  111269. * Gets the maximum number of particles active at the same time.
  111270. * @returns The max number of active particles.
  111271. */
  111272. getCapacity(): number;
  111273. /**
  111274. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  111275. * to override the particles.
  111276. */
  111277. forceDepthWrite: boolean;
  111278. /**
  111279. * Gets or set the number of active particles
  111280. */
  111281. activeParticleCount: number;
  111282. private _preWarmDone;
  111283. /**
  111284. * Is this system ready to be used/rendered
  111285. * @return true if the system is ready
  111286. */
  111287. isReady(): boolean;
  111288. /**
  111289. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111290. * @returns True if it has been started, otherwise false.
  111291. */
  111292. isStarted(): boolean;
  111293. /**
  111294. * Starts the particle system and begins to emit
  111295. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111296. */
  111297. start(delay?: number): void;
  111298. /**
  111299. * Stops the particle system.
  111300. */
  111301. stop(): void;
  111302. /**
  111303. * Remove all active particles
  111304. */
  111305. reset(): void;
  111306. /**
  111307. * Returns the string "GPUParticleSystem"
  111308. * @returns a string containing the class name
  111309. */
  111310. getClassName(): string;
  111311. private _colorGradientsTexture;
  111312. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  111313. /**
  111314. * Adds a new color gradient
  111315. * @param gradient defines the gradient to use (between 0 and 1)
  111316. * @param color1 defines the color to affect to the specified gradient
  111317. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  111318. * @returns the current particle system
  111319. */
  111320. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  111321. /**
  111322. * Remove a specific color gradient
  111323. * @param gradient defines the gradient to remove
  111324. * @returns the current particle system
  111325. */
  111326. removeColorGradient(gradient: number): GPUParticleSystem;
  111327. private _angularSpeedGradientsTexture;
  111328. private _sizeGradientsTexture;
  111329. private _velocityGradientsTexture;
  111330. private _limitVelocityGradientsTexture;
  111331. private _dragGradientsTexture;
  111332. private _addFactorGradient;
  111333. /**
  111334. * Adds a new size gradient
  111335. * @param gradient defines the gradient to use (between 0 and 1)
  111336. * @param factor defines the size factor to affect to the specified gradient
  111337. * @returns the current particle system
  111338. */
  111339. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  111340. /**
  111341. * Remove a specific size gradient
  111342. * @param gradient defines the gradient to remove
  111343. * @returns the current particle system
  111344. */
  111345. removeSizeGradient(gradient: number): GPUParticleSystem;
  111346. /**
  111347. * Adds a new angular speed gradient
  111348. * @param gradient defines the gradient to use (between 0 and 1)
  111349. * @param factor defines the angular speed to affect to the specified gradient
  111350. * @returns the current particle system
  111351. */
  111352. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  111353. /**
  111354. * Remove a specific angular speed gradient
  111355. * @param gradient defines the gradient to remove
  111356. * @returns the current particle system
  111357. */
  111358. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  111359. /**
  111360. * Adds a new velocity gradient
  111361. * @param gradient defines the gradient to use (between 0 and 1)
  111362. * @param factor defines the velocity to affect to the specified gradient
  111363. * @returns the current particle system
  111364. */
  111365. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111366. /**
  111367. * Remove a specific velocity gradient
  111368. * @param gradient defines the gradient to remove
  111369. * @returns the current particle system
  111370. */
  111371. removeVelocityGradient(gradient: number): GPUParticleSystem;
  111372. /**
  111373. * Adds a new limit velocity gradient
  111374. * @param gradient defines the gradient to use (between 0 and 1)
  111375. * @param factor defines the limit velocity value to affect to the specified gradient
  111376. * @returns the current particle system
  111377. */
  111378. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  111379. /**
  111380. * Remove a specific limit velocity gradient
  111381. * @param gradient defines the gradient to remove
  111382. * @returns the current particle system
  111383. */
  111384. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  111385. /**
  111386. * Adds a new drag gradient
  111387. * @param gradient defines the gradient to use (between 0 and 1)
  111388. * @param factor defines the drag value to affect to the specified gradient
  111389. * @returns the current particle system
  111390. */
  111391. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  111392. /**
  111393. * Remove a specific drag gradient
  111394. * @param gradient defines the gradient to remove
  111395. * @returns the current particle system
  111396. */
  111397. removeDragGradient(gradient: number): GPUParticleSystem;
  111398. /**
  111399. * Not supported by GPUParticleSystem
  111400. * @param gradient defines the gradient to use (between 0 and 1)
  111401. * @param factor defines the emit rate value to affect to the specified gradient
  111402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111403. * @returns the current particle system
  111404. */
  111405. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111406. /**
  111407. * Not supported by GPUParticleSystem
  111408. * @param gradient defines the gradient to remove
  111409. * @returns the current particle system
  111410. */
  111411. removeEmitRateGradient(gradient: number): IParticleSystem;
  111412. /**
  111413. * Not supported by GPUParticleSystem
  111414. * @param gradient defines the gradient to use (between 0 and 1)
  111415. * @param factor defines the start size value to affect to the specified gradient
  111416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111417. * @returns the current particle system
  111418. */
  111419. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111420. /**
  111421. * Not supported by GPUParticleSystem
  111422. * @param gradient defines the gradient to remove
  111423. * @returns the current particle system
  111424. */
  111425. removeStartSizeGradient(gradient: number): IParticleSystem;
  111426. /**
  111427. * Not supported by GPUParticleSystem
  111428. * @param gradient defines the gradient to use (between 0 and 1)
  111429. * @param min defines the color remap minimal range
  111430. * @param max defines the color remap maximal range
  111431. * @returns the current particle system
  111432. */
  111433. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111434. /**
  111435. * Not supported by GPUParticleSystem
  111436. * @param gradient defines the gradient to remove
  111437. * @returns the current particle system
  111438. */
  111439. removeColorRemapGradient(): IParticleSystem;
  111440. /**
  111441. * Not supported by GPUParticleSystem
  111442. * @param gradient defines the gradient to use (between 0 and 1)
  111443. * @param min defines the alpha remap minimal range
  111444. * @param max defines the alpha remap maximal range
  111445. * @returns the current particle system
  111446. */
  111447. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  111448. /**
  111449. * Not supported by GPUParticleSystem
  111450. * @param gradient defines the gradient to remove
  111451. * @returns the current particle system
  111452. */
  111453. removeAlphaRemapGradient(): IParticleSystem;
  111454. /**
  111455. * Not supported by GPUParticleSystem
  111456. * @param gradient defines the gradient to use (between 0 and 1)
  111457. * @param color defines the color to affect to the specified gradient
  111458. * @returns the current particle system
  111459. */
  111460. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  111461. /**
  111462. * Not supported by GPUParticleSystem
  111463. * @param gradient defines the gradient to remove
  111464. * @returns the current particle system
  111465. */
  111466. removeRampGradient(): IParticleSystem;
  111467. /**
  111468. * Not supported by GPUParticleSystem
  111469. * @returns the list of ramp gradients
  111470. */
  111471. getRampGradients(): Nullable<Array<Color3Gradient>>;
  111472. /**
  111473. * Not supported by GPUParticleSystem
  111474. * Gets or sets a boolean indicating that ramp gradients must be used
  111475. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  111476. */
  111477. useRampGradients: boolean;
  111478. /**
  111479. * Not supported by GPUParticleSystem
  111480. * @param gradient defines the gradient to use (between 0 and 1)
  111481. * @param factor defines the life time factor to affect to the specified gradient
  111482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  111483. * @returns the current particle system
  111484. */
  111485. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  111486. /**
  111487. * Not supported by GPUParticleSystem
  111488. * @param gradient defines the gradient to remove
  111489. * @returns the current particle system
  111490. */
  111491. removeLifeTimeGradient(gradient: number): IParticleSystem;
  111492. /**
  111493. * Instantiates a GPU particle system.
  111494. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  111495. * @param name The name of the particle system
  111496. * @param options The options used to create the system
  111497. * @param scene The scene the particle system belongs to
  111498. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  111499. */
  111500. constructor(name: string, options: Partial<{
  111501. capacity: number;
  111502. randomTextureSize: number;
  111503. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  111504. protected _reset(): void;
  111505. private _createUpdateVAO;
  111506. private _createRenderVAO;
  111507. private _initialize;
  111508. /** @hidden */
  111509. _recreateUpdateEffect(): void;
  111510. /** @hidden */
  111511. _recreateRenderEffect(): void;
  111512. /**
  111513. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111514. * @param preWarm defines if we are in the pre-warmimg phase
  111515. */
  111516. animate(preWarm?: boolean): void;
  111517. private _createFactorGradientTexture;
  111518. private _createSizeGradientTexture;
  111519. private _createAngularSpeedGradientTexture;
  111520. private _createVelocityGradientTexture;
  111521. private _createLimitVelocityGradientTexture;
  111522. private _createDragGradientTexture;
  111523. private _createColorGradientTexture;
  111524. /**
  111525. * Renders the particle system in its current state
  111526. * @param preWarm defines if the system should only update the particles but not render them
  111527. * @returns the current number of particles
  111528. */
  111529. render(preWarm?: boolean): number;
  111530. /**
  111531. * Rebuilds the particle system
  111532. */
  111533. rebuild(): void;
  111534. private _releaseBuffers;
  111535. private _releaseVAOs;
  111536. /**
  111537. * Disposes the particle system and free the associated resources
  111538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111539. */
  111540. dispose(disposeTexture?: boolean): void;
  111541. /**
  111542. * Clones the particle system.
  111543. * @param name The name of the cloned object
  111544. * @param newEmitter The new emitter to use
  111545. * @returns the cloned particle system
  111546. */
  111547. clone(name: string, newEmitter: any): GPUParticleSystem;
  111548. /**
  111549. * Serializes the particle system to a JSON object.
  111550. * @returns the JSON object
  111551. */
  111552. serialize(): any;
  111553. /**
  111554. * Parses a JSON object to create a GPU particle system.
  111555. * @param parsedParticleSystem The JSON object to parse
  111556. * @param scene The scene to create the particle system in
  111557. * @param rootUrl The root url to use to load external dependencies like texture
  111558. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111559. * @returns the parsed GPU particle system
  111560. */
  111561. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  111562. }
  111563. }
  111564. declare module BABYLON {
  111565. /**
  111566. * Represents a set of particle systems working together to create a specific effect
  111567. */
  111568. export class ParticleSystemSet implements IDisposable {
  111569. private _emitterCreationOptions;
  111570. private _emitterNode;
  111571. /**
  111572. * Gets the particle system list
  111573. */
  111574. systems: IParticleSystem[];
  111575. /**
  111576. * Gets the emitter node used with this set
  111577. */
  111578. readonly emitterNode: Nullable<TransformNode>;
  111579. /**
  111580. * Creates a new emitter mesh as a sphere
  111581. * @param options defines the options used to create the sphere
  111582. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  111583. * @param scene defines the hosting scene
  111584. */
  111585. setEmitterAsSphere(options: {
  111586. diameter: number;
  111587. segments: number;
  111588. color: Color3;
  111589. }, renderingGroupId: number, scene: Scene): void;
  111590. /**
  111591. * Starts all particle systems of the set
  111592. * @param emitter defines an optional mesh to use as emitter for the particle systems
  111593. */
  111594. start(emitter?: AbstractMesh): void;
  111595. /**
  111596. * Release all associated resources
  111597. */
  111598. dispose(): void;
  111599. /**
  111600. * Serialize the set into a JSON compatible object
  111601. * @returns a JSON compatible representation of the set
  111602. */
  111603. serialize(): any;
  111604. /**
  111605. * Parse a new ParticleSystemSet from a serialized source
  111606. * @param data defines a JSON compatible representation of the set
  111607. * @param scene defines the hosting scene
  111608. * @param gpu defines if we want GPU particles or CPU particles
  111609. * @returns a new ParticleSystemSet
  111610. */
  111611. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  111612. }
  111613. }
  111614. declare module BABYLON {
  111615. /**
  111616. * This class is made for on one-liner static method to help creating particle system set.
  111617. */
  111618. export class ParticleHelper {
  111619. /**
  111620. * Gets or sets base Assets URL
  111621. */
  111622. static BaseAssetsUrl: string;
  111623. /**
  111624. * Create a default particle system that you can tweak
  111625. * @param emitter defines the emitter to use
  111626. * @param capacity defines the system capacity (default is 500 particles)
  111627. * @param scene defines the hosting scene
  111628. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  111629. * @returns the new Particle system
  111630. */
  111631. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  111632. /**
  111633. * This is the main static method (one-liner) of this helper to create different particle systems
  111634. * @param type This string represents the type to the particle system to create
  111635. * @param scene The scene where the particle system should live
  111636. * @param gpu If the system will use gpu
  111637. * @returns the ParticleSystemSet created
  111638. */
  111639. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  111640. /**
  111641. * Static function used to export a particle system to a ParticleSystemSet variable.
  111642. * Please note that the emitter shape is not exported
  111643. * @param systems defines the particle systems to export
  111644. * @returns the created particle system set
  111645. */
  111646. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  111647. }
  111648. }
  111649. declare module BABYLON {
  111650. interface Engine {
  111651. /**
  111652. * Create an effect to use with particle systems.
  111653. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  111654. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  111655. * @param uniformsNames defines a list of attribute names
  111656. * @param samplers defines an array of string used to represent textures
  111657. * @param defines defines the string containing the defines to use to compile the shaders
  111658. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  111659. * @param onCompiled defines a function to call when the effect creation is successful
  111660. * @param onError defines a function to call when the effect creation has failed
  111661. * @returns the new Effect
  111662. */
  111663. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  111664. }
  111665. interface Mesh {
  111666. /**
  111667. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  111668. * @returns an array of IParticleSystem
  111669. */
  111670. getEmittedParticleSystems(): IParticleSystem[];
  111671. /**
  111672. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  111673. * @returns an array of IParticleSystem
  111674. */
  111675. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  111676. }
  111677. /**
  111678. * @hidden
  111679. */
  111680. export var _IDoNeedToBeInTheBuild: number;
  111681. }
  111682. declare module BABYLON {
  111683. interface Scene {
  111684. /** @hidden (Backing field) */
  111685. _physicsEngine: Nullable<IPhysicsEngine>;
  111686. /**
  111687. * Gets the current physics engine
  111688. * @returns a IPhysicsEngine or null if none attached
  111689. */
  111690. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111691. /**
  111692. * Enables physics to the current scene
  111693. * @param gravity defines the scene's gravity for the physics engine
  111694. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111695. * @return a boolean indicating if the physics engine was initialized
  111696. */
  111697. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111698. /**
  111699. * Disables and disposes the physics engine associated with the scene
  111700. */
  111701. disablePhysicsEngine(): void;
  111702. /**
  111703. * Gets a boolean indicating if there is an active physics engine
  111704. * @returns a boolean indicating if there is an active physics engine
  111705. */
  111706. isPhysicsEnabled(): boolean;
  111707. /**
  111708. * Deletes a physics compound impostor
  111709. * @param compound defines the compound to delete
  111710. */
  111711. deleteCompoundImpostor(compound: any): void;
  111712. /**
  111713. * An event triggered when physic simulation is about to be run
  111714. */
  111715. onBeforePhysicsObservable: Observable<Scene>;
  111716. /**
  111717. * An event triggered when physic simulation has been done
  111718. */
  111719. onAfterPhysicsObservable: Observable<Scene>;
  111720. }
  111721. interface AbstractMesh {
  111722. /** @hidden */
  111723. _physicsImpostor: Nullable<PhysicsImpostor>;
  111724. /**
  111725. * Gets or sets impostor used for physic simulation
  111726. * @see http://doc.babylonjs.com/features/physics_engine
  111727. */
  111728. physicsImpostor: Nullable<PhysicsImpostor>;
  111729. /**
  111730. * Gets the current physics impostor
  111731. * @see http://doc.babylonjs.com/features/physics_engine
  111732. * @returns a physics impostor or null
  111733. */
  111734. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111735. /** Apply a physic impulse to the mesh
  111736. * @param force defines the force to apply
  111737. * @param contactPoint defines where to apply the force
  111738. * @returns the current mesh
  111739. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111740. */
  111741. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111742. /**
  111743. * Creates a physic joint between two meshes
  111744. * @param otherMesh defines the other mesh to use
  111745. * @param pivot1 defines the pivot to use on this mesh
  111746. * @param pivot2 defines the pivot to use on the other mesh
  111747. * @param options defines additional options (can be plugin dependent)
  111748. * @returns the current mesh
  111749. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111750. */
  111751. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111752. /** @hidden */
  111753. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111754. }
  111755. /**
  111756. * Defines the physics engine scene component responsible to manage a physics engine
  111757. */
  111758. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111759. /**
  111760. * The component name helpful to identify the component in the list of scene components.
  111761. */
  111762. readonly name: string;
  111763. /**
  111764. * The scene the component belongs to.
  111765. */
  111766. scene: Scene;
  111767. /**
  111768. * Creates a new instance of the component for the given scene
  111769. * @param scene Defines the scene to register the component in
  111770. */
  111771. constructor(scene: Scene);
  111772. /**
  111773. * Registers the component in a given scene
  111774. */
  111775. register(): void;
  111776. /**
  111777. * Rebuilds the elements related to this component in case of
  111778. * context lost for instance.
  111779. */
  111780. rebuild(): void;
  111781. /**
  111782. * Disposes the component and the associated ressources
  111783. */
  111784. dispose(): void;
  111785. }
  111786. }
  111787. declare module BABYLON {
  111788. /**
  111789. * A helper for physics simulations
  111790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111791. */
  111792. export class PhysicsHelper {
  111793. private _scene;
  111794. private _physicsEngine;
  111795. /**
  111796. * Initializes the Physics helper
  111797. * @param scene Babylon.js scene
  111798. */
  111799. constructor(scene: Scene);
  111800. /**
  111801. * Applies a radial explosion impulse
  111802. * @param origin the origin of the explosion
  111803. * @param radiusOrEventOptions the radius or the options of radial explosion
  111804. * @param strength the explosion strength
  111805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111806. * @returns A physics radial explosion event, or null
  111807. */
  111808. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111809. /**
  111810. * Applies a radial explosion force
  111811. * @param origin the origin of the explosion
  111812. * @param radiusOrEventOptions the radius or the options of radial explosion
  111813. * @param strength the explosion strength
  111814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111815. * @returns A physics radial explosion event, or null
  111816. */
  111817. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111818. /**
  111819. * Creates a gravitational field
  111820. * @param origin the origin of the explosion
  111821. * @param radiusOrEventOptions the radius or the options of radial explosion
  111822. * @param strength the explosion strength
  111823. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111824. * @returns A physics gravitational field event, or null
  111825. */
  111826. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111827. /**
  111828. * Creates a physics updraft event
  111829. * @param origin the origin of the updraft
  111830. * @param radiusOrEventOptions the radius or the options of the updraft
  111831. * @param strength the strength of the updraft
  111832. * @param height the height of the updraft
  111833. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111834. * @returns A physics updraft event, or null
  111835. */
  111836. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111837. /**
  111838. * Creates a physics vortex event
  111839. * @param origin the of the vortex
  111840. * @param radiusOrEventOptions the radius or the options of the vortex
  111841. * @param strength the strength of the vortex
  111842. * @param height the height of the vortex
  111843. * @returns a Physics vortex event, or null
  111844. * A physics vortex event or null
  111845. */
  111846. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111847. }
  111848. /**
  111849. * Represents a physics radial explosion event
  111850. */
  111851. class PhysicsRadialExplosionEvent {
  111852. private _scene;
  111853. private _options;
  111854. private _sphere;
  111855. private _dataFetched;
  111856. /**
  111857. * Initializes a radial explosioin event
  111858. * @param _scene BabylonJS scene
  111859. * @param _options The options for the vortex event
  111860. */
  111861. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111862. /**
  111863. * Returns the data related to the radial explosion event (sphere).
  111864. * @returns The radial explosion event data
  111865. */
  111866. getData(): PhysicsRadialExplosionEventData;
  111867. /**
  111868. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111869. * @param impostor A physics imposter
  111870. * @param origin the origin of the explosion
  111871. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111872. */
  111873. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111874. /**
  111875. * Triggers affecterd impostors callbacks
  111876. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111877. */
  111878. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111879. /**
  111880. * Disposes the sphere.
  111881. * @param force Specifies if the sphere should be disposed by force
  111882. */
  111883. dispose(force?: boolean): void;
  111884. /*** Helpers ***/
  111885. private _prepareSphere;
  111886. private _intersectsWithSphere;
  111887. }
  111888. /**
  111889. * Represents a gravitational field event
  111890. */
  111891. class PhysicsGravitationalFieldEvent {
  111892. private _physicsHelper;
  111893. private _scene;
  111894. private _origin;
  111895. private _options;
  111896. private _tickCallback;
  111897. private _sphere;
  111898. private _dataFetched;
  111899. /**
  111900. * Initializes the physics gravitational field event
  111901. * @param _physicsHelper A physics helper
  111902. * @param _scene BabylonJS scene
  111903. * @param _origin The origin position of the gravitational field event
  111904. * @param _options The options for the vortex event
  111905. */
  111906. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111907. /**
  111908. * Returns the data related to the gravitational field event (sphere).
  111909. * @returns A gravitational field event
  111910. */
  111911. getData(): PhysicsGravitationalFieldEventData;
  111912. /**
  111913. * Enables the gravitational field.
  111914. */
  111915. enable(): void;
  111916. /**
  111917. * Disables the gravitational field.
  111918. */
  111919. disable(): void;
  111920. /**
  111921. * Disposes the sphere.
  111922. * @param force The force to dispose from the gravitational field event
  111923. */
  111924. dispose(force?: boolean): void;
  111925. private _tick;
  111926. }
  111927. /**
  111928. * Represents a physics updraft event
  111929. */
  111930. class PhysicsUpdraftEvent {
  111931. private _scene;
  111932. private _origin;
  111933. private _options;
  111934. private _physicsEngine;
  111935. private _originTop;
  111936. private _originDirection;
  111937. private _tickCallback;
  111938. private _cylinder;
  111939. private _cylinderPosition;
  111940. private _dataFetched;
  111941. /**
  111942. * Initializes the physics updraft event
  111943. * @param _scene BabylonJS scene
  111944. * @param _origin The origin position of the updraft
  111945. * @param _options The options for the updraft event
  111946. */
  111947. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111948. /**
  111949. * Returns the data related to the updraft event (cylinder).
  111950. * @returns A physics updraft event
  111951. */
  111952. getData(): PhysicsUpdraftEventData;
  111953. /**
  111954. * Enables the updraft.
  111955. */
  111956. enable(): void;
  111957. /**
  111958. * Disables the updraft.
  111959. */
  111960. disable(): void;
  111961. /**
  111962. * Disposes the cylinder.
  111963. * @param force Specifies if the updraft should be disposed by force
  111964. */
  111965. dispose(force?: boolean): void;
  111966. private getImpostorHitData;
  111967. private _tick;
  111968. /*** Helpers ***/
  111969. private _prepareCylinder;
  111970. private _intersectsWithCylinder;
  111971. }
  111972. /**
  111973. * Represents a physics vortex event
  111974. */
  111975. class PhysicsVortexEvent {
  111976. private _scene;
  111977. private _origin;
  111978. private _options;
  111979. private _physicsEngine;
  111980. private _originTop;
  111981. private _tickCallback;
  111982. private _cylinder;
  111983. private _cylinderPosition;
  111984. private _dataFetched;
  111985. /**
  111986. * Initializes the physics vortex event
  111987. * @param _scene The BabylonJS scene
  111988. * @param _origin The origin position of the vortex
  111989. * @param _options The options for the vortex event
  111990. */
  111991. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111992. /**
  111993. * Returns the data related to the vortex event (cylinder).
  111994. * @returns The physics vortex event data
  111995. */
  111996. getData(): PhysicsVortexEventData;
  111997. /**
  111998. * Enables the vortex.
  111999. */
  112000. enable(): void;
  112001. /**
  112002. * Disables the cortex.
  112003. */
  112004. disable(): void;
  112005. /**
  112006. * Disposes the sphere.
  112007. * @param force
  112008. */
  112009. dispose(force?: boolean): void;
  112010. private getImpostorHitData;
  112011. private _tick;
  112012. /*** Helpers ***/
  112013. private _prepareCylinder;
  112014. private _intersectsWithCylinder;
  112015. }
  112016. /**
  112017. * Options fot the radial explosion event
  112018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112019. */
  112020. export class PhysicsRadialExplosionEventOptions {
  112021. /**
  112022. * The radius of the sphere for the radial explosion.
  112023. */
  112024. radius: number;
  112025. /**
  112026. * The strenth of the explosion.
  112027. */
  112028. strength: number;
  112029. /**
  112030. * The strenght of the force in correspondence to the distance of the affected object
  112031. */
  112032. falloff: PhysicsRadialImpulseFalloff;
  112033. /**
  112034. * Sphere options for the radial explosion.
  112035. */
  112036. sphere: {
  112037. segments: number;
  112038. diameter: number;
  112039. };
  112040. /**
  112041. * Sphere options for the radial explosion.
  112042. */
  112043. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  112044. }
  112045. /**
  112046. * Options fot the updraft event
  112047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112048. */
  112049. export class PhysicsUpdraftEventOptions {
  112050. /**
  112051. * The radius of the cylinder for the vortex
  112052. */
  112053. radius: number;
  112054. /**
  112055. * The strenth of the updraft.
  112056. */
  112057. strength: number;
  112058. /**
  112059. * The height of the cylinder for the updraft.
  112060. */
  112061. height: number;
  112062. /**
  112063. * The mode for the the updraft.
  112064. */
  112065. updraftMode: PhysicsUpdraftMode;
  112066. }
  112067. /**
  112068. * Options fot the vortex event
  112069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112070. */
  112071. export class PhysicsVortexEventOptions {
  112072. /**
  112073. * The radius of the cylinder for the vortex
  112074. */
  112075. radius: number;
  112076. /**
  112077. * The strenth of the vortex.
  112078. */
  112079. strength: number;
  112080. /**
  112081. * The height of the cylinder for the vortex.
  112082. */
  112083. height: number;
  112084. /**
  112085. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  112086. */
  112087. centripetalForceThreshold: number;
  112088. /**
  112089. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  112090. */
  112091. centripetalForceMultiplier: number;
  112092. /**
  112093. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  112094. */
  112095. centrifugalForceMultiplier: number;
  112096. /**
  112097. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  112098. */
  112099. updraftForceMultiplier: number;
  112100. }
  112101. /**
  112102. * The strenght of the force in correspondence to the distance of the affected object
  112103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112104. */
  112105. export enum PhysicsRadialImpulseFalloff {
  112106. /** Defines that impulse is constant in strength across it's whole radius */
  112107. Constant = 0,
  112108. /** Defines that impulse gets weaker if it's further from the origin */
  112109. Linear = 1
  112110. }
  112111. /**
  112112. * The strength of the force in correspondence to the distance of the affected object
  112113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112114. */
  112115. export enum PhysicsUpdraftMode {
  112116. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112117. Center = 0,
  112118. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112119. Perpendicular = 1
  112120. }
  112121. /**
  112122. * Interface for a physics hit data
  112123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112124. */
  112125. export interface PhysicsHitData {
  112126. /**
  112127. * The force applied at the contact point
  112128. */
  112129. force: Vector3;
  112130. /**
  112131. * The contact point
  112132. */
  112133. contactPoint: Vector3;
  112134. /**
  112135. * The distance from the origin to the contact point
  112136. */
  112137. distanceFromOrigin: number;
  112138. }
  112139. /**
  112140. * Interface for radial explosion event data
  112141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112142. */
  112143. export interface PhysicsRadialExplosionEventData {
  112144. /**
  112145. * A sphere used for the radial explosion event
  112146. */
  112147. sphere: Mesh;
  112148. }
  112149. /**
  112150. * Interface for gravitational field event data
  112151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112152. */
  112153. export interface PhysicsGravitationalFieldEventData {
  112154. /**
  112155. * A sphere mesh used for the gravitational field event
  112156. */
  112157. sphere: Mesh;
  112158. }
  112159. /**
  112160. * Interface for updraft event data
  112161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112162. */
  112163. export interface PhysicsUpdraftEventData {
  112164. /**
  112165. * A cylinder used for the updraft event
  112166. */
  112167. cylinder: Mesh;
  112168. }
  112169. /**
  112170. * Interface for vortex event data
  112171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112172. */
  112173. export interface PhysicsVortexEventData {
  112174. /**
  112175. * A cylinder used for the vortex event
  112176. */
  112177. cylinder: Mesh;
  112178. }
  112179. /**
  112180. * Interface for an affected physics impostor
  112181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  112182. */
  112183. export interface PhysicsAffectedImpostorWithData {
  112184. /**
  112185. * The impostor affected by the effect
  112186. */
  112187. impostor: PhysicsImpostor;
  112188. /**
  112189. * The data about the hit/horce from the explosion
  112190. */
  112191. hitData: PhysicsHitData;
  112192. }
  112193. }
  112194. declare module BABYLON {
  112195. /** @hidden */
  112196. export var blackAndWhitePixelShader: {
  112197. name: string;
  112198. shader: string;
  112199. };
  112200. }
  112201. declare module BABYLON {
  112202. /**
  112203. * Post process used to render in black and white
  112204. */
  112205. export class BlackAndWhitePostProcess extends PostProcess {
  112206. /**
  112207. * Linear about to convert he result to black and white (default: 1)
  112208. */
  112209. degree: number;
  112210. /**
  112211. * Creates a black and white post process
  112212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  112213. * @param name The name of the effect.
  112214. * @param options The required width/height ratio to downsize to before computing the render pass.
  112215. * @param camera The camera to apply the render pass to.
  112216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112217. * @param engine The engine which the post process will be applied. (default: current engine)
  112218. * @param reusable If the post process can be reused on the same frame. (default: false)
  112219. */
  112220. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112221. }
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * This represents a set of one or more post processes in Babylon.
  112226. * A post process can be used to apply a shader to a texture after it is rendered.
  112227. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112228. */
  112229. export class PostProcessRenderEffect {
  112230. private _postProcesses;
  112231. private _getPostProcesses;
  112232. private _singleInstance;
  112233. private _cameras;
  112234. private _indicesForCamera;
  112235. /**
  112236. * Name of the effect
  112237. * @hidden
  112238. */
  112239. _name: string;
  112240. /**
  112241. * Instantiates a post process render effect.
  112242. * A post process can be used to apply a shader to a texture after it is rendered.
  112243. * @param engine The engine the effect is tied to
  112244. * @param name The name of the effect
  112245. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  112246. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  112247. */
  112248. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  112249. /**
  112250. * Checks if all the post processes in the effect are supported.
  112251. */
  112252. readonly isSupported: boolean;
  112253. /**
  112254. * Updates the current state of the effect
  112255. * @hidden
  112256. */
  112257. _update(): void;
  112258. /**
  112259. * Attaches the effect on cameras
  112260. * @param cameras The camera to attach to.
  112261. * @hidden
  112262. */
  112263. _attachCameras(cameras: Camera): void;
  112264. /**
  112265. * Attaches the effect on cameras
  112266. * @param cameras The camera to attach to.
  112267. * @hidden
  112268. */
  112269. _attachCameras(cameras: Camera[]): void;
  112270. /**
  112271. * Detaches the effect on cameras
  112272. * @param cameras The camera to detatch from.
  112273. * @hidden
  112274. */
  112275. _detachCameras(cameras: Camera): void;
  112276. /**
  112277. * Detatches the effect on cameras
  112278. * @param cameras The camera to detatch from.
  112279. * @hidden
  112280. */
  112281. _detachCameras(cameras: Camera[]): void;
  112282. /**
  112283. * Enables the effect on given cameras
  112284. * @param cameras The camera to enable.
  112285. * @hidden
  112286. */
  112287. _enable(cameras: Camera): void;
  112288. /**
  112289. * Enables the effect on given cameras
  112290. * @param cameras The camera to enable.
  112291. * @hidden
  112292. */
  112293. _enable(cameras: Nullable<Camera[]>): void;
  112294. /**
  112295. * Disables the effect on the given cameras
  112296. * @param cameras The camera to disable.
  112297. * @hidden
  112298. */
  112299. _disable(cameras: Camera): void;
  112300. /**
  112301. * Disables the effect on the given cameras
  112302. * @param cameras The camera to disable.
  112303. * @hidden
  112304. */
  112305. _disable(cameras: Nullable<Camera[]>): void;
  112306. /**
  112307. * Gets a list of the post processes contained in the effect.
  112308. * @param camera The camera to get the post processes on.
  112309. * @returns The list of the post processes in the effect.
  112310. */
  112311. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /** @hidden */
  112316. export var extractHighlightsPixelShader: {
  112317. name: string;
  112318. shader: string;
  112319. };
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  112324. */
  112325. export class ExtractHighlightsPostProcess extends PostProcess {
  112326. /**
  112327. * The luminance threshold, pixels below this value will be set to black.
  112328. */
  112329. threshold: number;
  112330. /** @hidden */
  112331. _exposure: number;
  112332. /**
  112333. * Post process which has the input texture to be used when performing highlight extraction
  112334. * @hidden
  112335. */
  112336. _inputPostProcess: Nullable<PostProcess>;
  112337. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112338. }
  112339. }
  112340. declare module BABYLON {
  112341. /** @hidden */
  112342. export var bloomMergePixelShader: {
  112343. name: string;
  112344. shader: string;
  112345. };
  112346. }
  112347. declare module BABYLON {
  112348. /**
  112349. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112350. */
  112351. export class BloomMergePostProcess extends PostProcess {
  112352. /** Weight of the bloom to be added to the original input. */
  112353. weight: number;
  112354. /**
  112355. * Creates a new instance of @see BloomMergePostProcess
  112356. * @param name The name of the effect.
  112357. * @param originalFromInput Post process which's input will be used for the merge.
  112358. * @param blurred Blurred highlights post process which's output will be used.
  112359. * @param weight Weight of the bloom to be added to the original input.
  112360. * @param options The required width/height ratio to downsize to before computing the render pass.
  112361. * @param camera The camera to apply the render pass to.
  112362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112363. * @param engine The engine which the post process will be applied. (default: current engine)
  112364. * @param reusable If the post process can be reused on the same frame. (default: false)
  112365. * @param textureType Type of textures used when performing the post process. (default: 0)
  112366. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112367. */
  112368. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  112369. /** Weight of the bloom to be added to the original input. */
  112370. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112371. }
  112372. }
  112373. declare module BABYLON {
  112374. /**
  112375. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  112376. */
  112377. export class BloomEffect extends PostProcessRenderEffect {
  112378. private bloomScale;
  112379. /**
  112380. * @hidden Internal
  112381. */
  112382. _effects: Array<PostProcess>;
  112383. /**
  112384. * @hidden Internal
  112385. */
  112386. _downscale: ExtractHighlightsPostProcess;
  112387. private _blurX;
  112388. private _blurY;
  112389. private _merge;
  112390. /**
  112391. * The luminance threshold to find bright areas of the image to bloom.
  112392. */
  112393. threshold: number;
  112394. /**
  112395. * The strength of the bloom.
  112396. */
  112397. weight: number;
  112398. /**
  112399. * Specifies the size of the bloom blur kernel, relative to the final output size
  112400. */
  112401. kernel: number;
  112402. /**
  112403. * Creates a new instance of @see BloomEffect
  112404. * @param scene The scene the effect belongs to.
  112405. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  112406. * @param bloomKernel The size of the kernel to be used when applying the blur.
  112407. * @param bloomWeight The the strength of bloom.
  112408. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112409. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112410. */
  112411. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  112412. /**
  112413. * Disposes each of the internal effects for a given camera.
  112414. * @param camera The camera to dispose the effect on.
  112415. */
  112416. disposeEffects(camera: Camera): void;
  112417. /**
  112418. * @hidden Internal
  112419. */
  112420. _updateEffects(): void;
  112421. /**
  112422. * Internal
  112423. * @returns if all the contained post processes are ready.
  112424. * @hidden
  112425. */
  112426. _isReady(): boolean;
  112427. }
  112428. }
  112429. declare module BABYLON {
  112430. /** @hidden */
  112431. export var chromaticAberrationPixelShader: {
  112432. name: string;
  112433. shader: string;
  112434. };
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  112439. */
  112440. export class ChromaticAberrationPostProcess extends PostProcess {
  112441. /**
  112442. * The amount of seperation of rgb channels (default: 30)
  112443. */
  112444. aberrationAmount: number;
  112445. /**
  112446. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  112447. */
  112448. radialIntensity: number;
  112449. /**
  112450. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  112451. */
  112452. direction: Vector2;
  112453. /**
  112454. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  112455. */
  112456. centerPosition: Vector2;
  112457. /**
  112458. * Creates a new instance ChromaticAberrationPostProcess
  112459. * @param name The name of the effect.
  112460. * @param screenWidth The width of the screen to apply the effect on.
  112461. * @param screenHeight The height of the screen to apply the effect on.
  112462. * @param options The required width/height ratio to downsize to before computing the render pass.
  112463. * @param camera The camera to apply the render pass to.
  112464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112465. * @param engine The engine which the post process will be applied. (default: current engine)
  112466. * @param reusable If the post process can be reused on the same frame. (default: false)
  112467. * @param textureType Type of textures used when performing the post process. (default: 0)
  112468. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112469. */
  112470. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112471. }
  112472. }
  112473. declare module BABYLON {
  112474. /** @hidden */
  112475. export var circleOfConfusionPixelShader: {
  112476. name: string;
  112477. shader: string;
  112478. };
  112479. }
  112480. declare module BABYLON {
  112481. /**
  112482. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  112483. */
  112484. export class CircleOfConfusionPostProcess extends PostProcess {
  112485. /**
  112486. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  112487. */
  112488. lensSize: number;
  112489. /**
  112490. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112491. */
  112492. fStop: number;
  112493. /**
  112494. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112495. */
  112496. focusDistance: number;
  112497. /**
  112498. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  112499. */
  112500. focalLength: number;
  112501. private _depthTexture;
  112502. /**
  112503. * Creates a new instance CircleOfConfusionPostProcess
  112504. * @param name The name of the effect.
  112505. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  112506. * @param options The required width/height ratio to downsize to before computing the render pass.
  112507. * @param camera The camera to apply the render pass to.
  112508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112509. * @param engine The engine which the post process will be applied. (default: current engine)
  112510. * @param reusable If the post process can be reused on the same frame. (default: false)
  112511. * @param textureType Type of textures used when performing the post process. (default: 0)
  112512. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112513. */
  112514. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112515. /**
  112516. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  112517. */
  112518. depthTexture: RenderTargetTexture;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. /** @hidden */
  112523. export var colorCorrectionPixelShader: {
  112524. name: string;
  112525. shader: string;
  112526. };
  112527. }
  112528. declare module BABYLON {
  112529. /**
  112530. *
  112531. * This post-process allows the modification of rendered colors by using
  112532. * a 'look-up table' (LUT). This effect is also called Color Grading.
  112533. *
  112534. * The object needs to be provided an url to a texture containing the color
  112535. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  112536. * Use an image editing software to tweak the LUT to match your needs.
  112537. *
  112538. * For an example of a color LUT, see here:
  112539. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  112540. * For explanations on color grading, see here:
  112541. * @see http://udn.epicgames.com/Three/ColorGrading.html
  112542. *
  112543. */
  112544. export class ColorCorrectionPostProcess extends PostProcess {
  112545. private _colorTableTexture;
  112546. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112547. }
  112548. }
  112549. declare module BABYLON {
  112550. /** @hidden */
  112551. export var convolutionPixelShader: {
  112552. name: string;
  112553. shader: string;
  112554. };
  112555. }
  112556. declare module BABYLON {
  112557. /**
  112558. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  112559. * input texture to perform effects such as edge detection or sharpening
  112560. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112561. */
  112562. export class ConvolutionPostProcess extends PostProcess {
  112563. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112564. kernel: number[];
  112565. /**
  112566. * Creates a new instance ConvolutionPostProcess
  112567. * @param name The name of the effect.
  112568. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  112569. * @param options The required width/height ratio to downsize to before computing the render pass.
  112570. * @param camera The camera to apply the render pass to.
  112571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112572. * @param engine The engine which the post process will be applied. (default: current engine)
  112573. * @param reusable If the post process can be reused on the same frame. (default: false)
  112574. * @param textureType Type of textures used when performing the post process. (default: 0)
  112575. */
  112576. constructor(name: string,
  112577. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  112578. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112579. /**
  112580. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112581. */
  112582. static EdgeDetect0Kernel: number[];
  112583. /**
  112584. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112585. */
  112586. static EdgeDetect1Kernel: number[];
  112587. /**
  112588. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112589. */
  112590. static EdgeDetect2Kernel: number[];
  112591. /**
  112592. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112593. */
  112594. static SharpenKernel: number[];
  112595. /**
  112596. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112597. */
  112598. static EmbossKernel: number[];
  112599. /**
  112600. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  112601. */
  112602. static GaussianKernel: number[];
  112603. }
  112604. }
  112605. declare module BABYLON {
  112606. /**
  112607. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  112608. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  112609. * based on samples that have a large difference in distance than the center pixel.
  112610. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  112611. */
  112612. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  112613. direction: Vector2;
  112614. /**
  112615. * Creates a new instance CircleOfConfusionPostProcess
  112616. * @param name The name of the effect.
  112617. * @param scene The scene the effect belongs to.
  112618. * @param direction The direction the blur should be applied.
  112619. * @param kernel The size of the kernel used to blur.
  112620. * @param options The required width/height ratio to downsize to before computing the render pass.
  112621. * @param camera The camera to apply the render pass to.
  112622. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  112623. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  112624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112625. * @param engine The engine which the post process will be applied. (default: current engine)
  112626. * @param reusable If the post process can be reused on the same frame. (default: false)
  112627. * @param textureType Type of textures used when performing the post process. (default: 0)
  112628. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112629. */
  112630. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112631. }
  112632. }
  112633. declare module BABYLON {
  112634. /** @hidden */
  112635. export var depthOfFieldMergePixelShader: {
  112636. name: string;
  112637. shader: string;
  112638. };
  112639. }
  112640. declare module BABYLON {
  112641. /**
  112642. * Options to be set when merging outputs from the default pipeline.
  112643. */
  112644. export class DepthOfFieldMergePostProcessOptions {
  112645. /**
  112646. * The original image to merge on top of
  112647. */
  112648. originalFromInput: PostProcess;
  112649. /**
  112650. * Parameters to perform the merge of the depth of field effect
  112651. */
  112652. depthOfField?: {
  112653. circleOfConfusion: PostProcess;
  112654. blurSteps: Array<PostProcess>;
  112655. };
  112656. /**
  112657. * Parameters to perform the merge of bloom effect
  112658. */
  112659. bloom?: {
  112660. blurred: PostProcess;
  112661. weight: number;
  112662. };
  112663. }
  112664. /**
  112665. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  112666. */
  112667. export class DepthOfFieldMergePostProcess extends PostProcess {
  112668. private blurSteps;
  112669. /**
  112670. * Creates a new instance of DepthOfFieldMergePostProcess
  112671. * @param name The name of the effect.
  112672. * @param originalFromInput Post process which's input will be used for the merge.
  112673. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  112674. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  112675. * @param options The required width/height ratio to downsize to before computing the render pass.
  112676. * @param camera The camera to apply the render pass to.
  112677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112678. * @param engine The engine which the post process will be applied. (default: current engine)
  112679. * @param reusable If the post process can be reused on the same frame. (default: false)
  112680. * @param textureType Type of textures used when performing the post process. (default: 0)
  112681. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112682. */
  112683. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112684. /**
  112685. * Updates the effect with the current post process compile time values and recompiles the shader.
  112686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112689. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  112690. * @param onCompiled Called when the shader has been compiled.
  112691. * @param onError Called if there is an error when compiling a shader.
  112692. */
  112693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112694. }
  112695. }
  112696. declare module BABYLON {
  112697. /**
  112698. * Specifies the level of max blur that should be applied when using the depth of field effect
  112699. */
  112700. export enum DepthOfFieldEffectBlurLevel {
  112701. /**
  112702. * Subtle blur
  112703. */
  112704. Low = 0,
  112705. /**
  112706. * Medium blur
  112707. */
  112708. Medium = 1,
  112709. /**
  112710. * Large blur
  112711. */
  112712. High = 2
  112713. }
  112714. /**
  112715. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112716. */
  112717. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112718. private _circleOfConfusion;
  112719. /**
  112720. * @hidden Internal, blurs from high to low
  112721. */
  112722. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112723. private _depthOfFieldBlurY;
  112724. private _dofMerge;
  112725. /**
  112726. * @hidden Internal post processes in depth of field effect
  112727. */
  112728. _effects: Array<PostProcess>;
  112729. /**
  112730. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112731. */
  112732. focalLength: number;
  112733. /**
  112734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112735. */
  112736. fStop: number;
  112737. /**
  112738. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112739. */
  112740. focusDistance: number;
  112741. /**
  112742. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  112743. */
  112744. lensSize: number;
  112745. /**
  112746. * Creates a new instance DepthOfFieldEffect
  112747. * @param scene The scene the effect belongs to.
  112748. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  112749. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112750. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112751. */
  112752. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112753. /**
  112754. * Get the current class name of the current effet
  112755. * @returns "DepthOfFieldEffect"
  112756. */
  112757. getClassName(): string;
  112758. /**
  112759. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  112760. */
  112761. depthTexture: RenderTargetTexture;
  112762. /**
  112763. * Disposes each of the internal effects for a given camera.
  112764. * @param camera The camera to dispose the effect on.
  112765. */
  112766. disposeEffects(camera: Camera): void;
  112767. /**
  112768. * @hidden Internal
  112769. */
  112770. _updateEffects(): void;
  112771. /**
  112772. * Internal
  112773. * @returns if all the contained post processes are ready.
  112774. * @hidden
  112775. */
  112776. _isReady(): boolean;
  112777. }
  112778. }
  112779. declare module BABYLON {
  112780. /** @hidden */
  112781. export var displayPassPixelShader: {
  112782. name: string;
  112783. shader: string;
  112784. };
  112785. }
  112786. declare module BABYLON {
  112787. /**
  112788. * DisplayPassPostProcess which produces an output the same as it's input
  112789. */
  112790. export class DisplayPassPostProcess extends PostProcess {
  112791. /**
  112792. * Creates the DisplayPassPostProcess
  112793. * @param name The name of the effect.
  112794. * @param options The required width/height ratio to downsize to before computing the render pass.
  112795. * @param camera The camera to apply the render pass to.
  112796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112797. * @param engine The engine which the post process will be applied. (default: current engine)
  112798. * @param reusable If the post process can be reused on the same frame. (default: false)
  112799. */
  112800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /** @hidden */
  112805. export var filterPixelShader: {
  112806. name: string;
  112807. shader: string;
  112808. };
  112809. }
  112810. declare module BABYLON {
  112811. /**
  112812. * Applies a kernel filter to the image
  112813. */
  112814. export class FilterPostProcess extends PostProcess {
  112815. /** The matrix to be applied to the image */
  112816. kernelMatrix: Matrix;
  112817. /**
  112818. *
  112819. * @param name The name of the effect.
  112820. * @param kernelMatrix The matrix to be applied to the image
  112821. * @param options The required width/height ratio to downsize to before computing the render pass.
  112822. * @param camera The camera to apply the render pass to.
  112823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112824. * @param engine The engine which the post process will be applied. (default: current engine)
  112825. * @param reusable If the post process can be reused on the same frame. (default: false)
  112826. */
  112827. constructor(name: string,
  112828. /** The matrix to be applied to the image */
  112829. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /** @hidden */
  112834. export var fxaaPixelShader: {
  112835. name: string;
  112836. shader: string;
  112837. };
  112838. }
  112839. declare module BABYLON {
  112840. /** @hidden */
  112841. export var fxaaVertexShader: {
  112842. name: string;
  112843. shader: string;
  112844. };
  112845. }
  112846. declare module BABYLON {
  112847. /**
  112848. * Fxaa post process
  112849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112850. */
  112851. export class FxaaPostProcess extends PostProcess {
  112852. /** @hidden */
  112853. texelWidth: number;
  112854. /** @hidden */
  112855. texelHeight: number;
  112856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112857. private _getDefines;
  112858. }
  112859. }
  112860. declare module BABYLON {
  112861. /** @hidden */
  112862. export var grainPixelShader: {
  112863. name: string;
  112864. shader: string;
  112865. };
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * The GrainPostProcess adds noise to the image at mid luminance levels
  112870. */
  112871. export class GrainPostProcess extends PostProcess {
  112872. /**
  112873. * The intensity of the grain added (default: 30)
  112874. */
  112875. intensity: number;
  112876. /**
  112877. * If the grain should be randomized on every frame
  112878. */
  112879. animated: boolean;
  112880. /**
  112881. * Creates a new instance of @see GrainPostProcess
  112882. * @param name The name of the effect.
  112883. * @param options The required width/height ratio to downsize to before computing the render pass.
  112884. * @param camera The camera to apply the render pass to.
  112885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112886. * @param engine The engine which the post process will be applied. (default: current engine)
  112887. * @param reusable If the post process can be reused on the same frame. (default: false)
  112888. * @param textureType Type of textures used when performing the post process. (default: 0)
  112889. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  112890. */
  112891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112892. }
  112893. }
  112894. declare module BABYLON {
  112895. /** @hidden */
  112896. export var highlightsPixelShader: {
  112897. name: string;
  112898. shader: string;
  112899. };
  112900. }
  112901. declare module BABYLON {
  112902. /**
  112903. * Extracts highlights from the image
  112904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112905. */
  112906. export class HighlightsPostProcess extends PostProcess {
  112907. /**
  112908. * Extracts highlights from the image
  112909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112910. * @param name The name of the effect.
  112911. * @param options The required width/height ratio to downsize to before computing the render pass.
  112912. * @param camera The camera to apply the render pass to.
  112913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112914. * @param engine The engine which the post process will be applied. (default: current engine)
  112915. * @param reusable If the post process can be reused on the same frame. (default: false)
  112916. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112917. */
  112918. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112919. }
  112920. }
  112921. declare module BABYLON {
  112922. /** @hidden */
  112923. export var mrtFragmentDeclaration: {
  112924. name: string;
  112925. shader: string;
  112926. };
  112927. }
  112928. declare module BABYLON {
  112929. /** @hidden */
  112930. export var geometryPixelShader: {
  112931. name: string;
  112932. shader: string;
  112933. };
  112934. }
  112935. declare module BABYLON {
  112936. /** @hidden */
  112937. export var geometryVertexShader: {
  112938. name: string;
  112939. shader: string;
  112940. };
  112941. }
  112942. declare module BABYLON {
  112943. /**
  112944. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112945. */
  112946. export class GeometryBufferRenderer {
  112947. /**
  112948. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112949. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112950. */
  112951. static readonly POSITION_TEXTURE_TYPE: number;
  112952. /**
  112953. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112954. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112955. */
  112956. static readonly VELOCITY_TEXTURE_TYPE: number;
  112957. /**
  112958. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112959. * in order to compute objects velocities when enableVelocity is set to "true"
  112960. * @hidden
  112961. */
  112962. _previousTransformationMatrices: {
  112963. [index: number]: Matrix;
  112964. };
  112965. private _scene;
  112966. private _multiRenderTarget;
  112967. private _ratio;
  112968. private _enablePosition;
  112969. private _enableVelocity;
  112970. private _positionIndex;
  112971. private _velocityIndex;
  112972. protected _effect: Effect;
  112973. protected _cachedDefines: string;
  112974. /**
  112975. * Set the render list (meshes to be rendered) used in the G buffer.
  112976. */
  112977. renderList: Mesh[];
  112978. /**
  112979. * Gets wether or not G buffer are supported by the running hardware.
  112980. * This requires draw buffer supports
  112981. */
  112982. readonly isSupported: boolean;
  112983. /**
  112984. * Returns the index of the given texture type in the G-Buffer textures array
  112985. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112986. * @returns the index of the given texture type in the G-Buffer textures array
  112987. */
  112988. getTextureIndex(textureType: number): number;
  112989. /**
  112990. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112991. */
  112992. /**
  112993. * Sets whether or not objects positions are enabled for the G buffer.
  112994. */
  112995. enablePosition: boolean;
  112996. /**
  112997. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112998. */
  112999. /**
  113000. * Sets wether or not objects velocities are enabled for the G buffer.
  113001. */
  113002. enableVelocity: boolean;
  113003. /**
  113004. * Gets the scene associated with the buffer.
  113005. */
  113006. readonly scene: Scene;
  113007. /**
  113008. * Gets the ratio used by the buffer during its creation.
  113009. * How big is the buffer related to the main canvas.
  113010. */
  113011. readonly ratio: number;
  113012. /** @hidden */
  113013. static _SceneComponentInitialization: (scene: Scene) => void;
  113014. /**
  113015. * Creates a new G Buffer for the scene
  113016. * @param scene The scene the buffer belongs to
  113017. * @param ratio How big is the buffer related to the main canvas.
  113018. */
  113019. constructor(scene: Scene, ratio?: number);
  113020. /**
  113021. * Checks wether everything is ready to render a submesh to the G buffer.
  113022. * @param subMesh the submesh to check readiness for
  113023. * @param useInstances is the mesh drawn using instance or not
  113024. * @returns true if ready otherwise false
  113025. */
  113026. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113027. /**
  113028. * Gets the current underlying G Buffer.
  113029. * @returns the buffer
  113030. */
  113031. getGBuffer(): MultiRenderTarget;
  113032. /**
  113033. * Gets the number of samples used to render the buffer (anti aliasing).
  113034. */
  113035. /**
  113036. * Sets the number of samples used to render the buffer (anti aliasing).
  113037. */
  113038. samples: number;
  113039. /**
  113040. * Disposes the renderer and frees up associated resources.
  113041. */
  113042. dispose(): void;
  113043. protected _createRenderTargets(): void;
  113044. }
  113045. }
  113046. declare module BABYLON {
  113047. interface Scene {
  113048. /** @hidden (Backing field) */
  113049. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113050. /**
  113051. * Gets or Sets the current geometry buffer associated to the scene.
  113052. */
  113053. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  113054. /**
  113055. * Enables a GeometryBufferRender and associates it with the scene
  113056. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  113057. * @returns the GeometryBufferRenderer
  113058. */
  113059. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  113060. /**
  113061. * Disables the GeometryBufferRender associated with the scene
  113062. */
  113063. disableGeometryBufferRenderer(): void;
  113064. }
  113065. /**
  113066. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  113067. * in several rendering techniques.
  113068. */
  113069. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  113070. /**
  113071. * The component name helpful to identify the component in the list of scene components.
  113072. */
  113073. readonly name: string;
  113074. /**
  113075. * The scene the component belongs to.
  113076. */
  113077. scene: Scene;
  113078. /**
  113079. * Creates a new instance of the component for the given scene
  113080. * @param scene Defines the scene to register the component in
  113081. */
  113082. constructor(scene: Scene);
  113083. /**
  113084. * Registers the component in a given scene
  113085. */
  113086. register(): void;
  113087. /**
  113088. * Rebuilds the elements related to this component in case of
  113089. * context lost for instance.
  113090. */
  113091. rebuild(): void;
  113092. /**
  113093. * Disposes the component and the associated ressources
  113094. */
  113095. dispose(): void;
  113096. private _gatherRenderTargets;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /** @hidden */
  113101. export var motionBlurPixelShader: {
  113102. name: string;
  113103. shader: string;
  113104. };
  113105. }
  113106. declare module BABYLON {
  113107. /**
  113108. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  113109. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  113110. * As an example, all you have to do is to create the post-process:
  113111. * var mb = new BABYLON.MotionBlurPostProcess(
  113112. * 'mb', // The name of the effect.
  113113. * scene, // The scene containing the objects to blur according to their velocity.
  113114. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  113115. * camera // The camera to apply the render pass to.
  113116. * );
  113117. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  113118. */
  113119. export class MotionBlurPostProcess extends PostProcess {
  113120. /**
  113121. * Defines how much the image is blurred by the movement. Default value is equal to 1
  113122. */
  113123. motionStrength: number;
  113124. /**
  113125. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  113126. */
  113127. /**
  113128. * Sets the number of iterations to be used for motion blur quality
  113129. */
  113130. motionBlurSamples: number;
  113131. private _motionBlurSamples;
  113132. private _geometryBufferRenderer;
  113133. /**
  113134. * Creates a new instance MotionBlurPostProcess
  113135. * @param name The name of the effect.
  113136. * @param scene The scene containing the objects to blur according to their velocity.
  113137. * @param options The required width/height ratio to downsize to before computing the render pass.
  113138. * @param camera The camera to apply the render pass to.
  113139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113140. * @param engine The engine which the post process will be applied. (default: current engine)
  113141. * @param reusable If the post process can be reused on the same frame. (default: false)
  113142. * @param textureType Type of textures used when performing the post process. (default: 0)
  113143. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  113144. */
  113145. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113146. /**
  113147. * Disposes the post process.
  113148. * @param camera The camera to dispose the post process on.
  113149. */
  113150. dispose(camera?: Camera): void;
  113151. }
  113152. }
  113153. declare module BABYLON {
  113154. /** @hidden */
  113155. export var refractionPixelShader: {
  113156. name: string;
  113157. shader: string;
  113158. };
  113159. }
  113160. declare module BABYLON {
  113161. /**
  113162. * Post process which applies a refractin texture
  113163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113164. */
  113165. export class RefractionPostProcess extends PostProcess {
  113166. /** the base color of the refraction (used to taint the rendering) */
  113167. color: Color3;
  113168. /** simulated refraction depth */
  113169. depth: number;
  113170. /** the coefficient of the base color (0 to remove base color tainting) */
  113171. colorLevel: number;
  113172. private _refTexture;
  113173. private _ownRefractionTexture;
  113174. /**
  113175. * Gets or sets the refraction texture
  113176. * Please note that you are responsible for disposing the texture if you set it manually
  113177. */
  113178. refractionTexture: Texture;
  113179. /**
  113180. * Initializes the RefractionPostProcess
  113181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  113182. * @param name The name of the effect.
  113183. * @param refractionTextureUrl Url of the refraction texture to use
  113184. * @param color the base color of the refraction (used to taint the rendering)
  113185. * @param depth simulated refraction depth
  113186. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  113187. * @param camera The camera to apply the render pass to.
  113188. * @param options The required width/height ratio to downsize to before computing the render pass.
  113189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113190. * @param engine The engine which the post process will be applied. (default: current engine)
  113191. * @param reusable If the post process can be reused on the same frame. (default: false)
  113192. */
  113193. constructor(name: string, refractionTextureUrl: string,
  113194. /** the base color of the refraction (used to taint the rendering) */
  113195. color: Color3,
  113196. /** simulated refraction depth */
  113197. depth: number,
  113198. /** the coefficient of the base color (0 to remove base color tainting) */
  113199. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  113200. /**
  113201. * Disposes of the post process
  113202. * @param camera Camera to dispose post process on
  113203. */
  113204. dispose(camera: Camera): void;
  113205. }
  113206. }
  113207. declare module BABYLON {
  113208. /** @hidden */
  113209. export var sharpenPixelShader: {
  113210. name: string;
  113211. shader: string;
  113212. };
  113213. }
  113214. declare module BABYLON {
  113215. /**
  113216. * The SharpenPostProcess applies a sharpen kernel to every pixel
  113217. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  113218. */
  113219. export class SharpenPostProcess extends PostProcess {
  113220. /**
  113221. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  113222. */
  113223. colorAmount: number;
  113224. /**
  113225. * How much sharpness should be applied (default: 0.3)
  113226. */
  113227. edgeAmount: number;
  113228. /**
  113229. * Creates a new instance ConvolutionPostProcess
  113230. * @param name The name of the effect.
  113231. * @param options The required width/height ratio to downsize to before computing the render pass.
  113232. * @param camera The camera to apply the render pass to.
  113233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  113234. * @param engine The engine which the post process will be applied. (default: current engine)
  113235. * @param reusable If the post process can be reused on the same frame. (default: false)
  113236. * @param textureType Type of textures used when performing the post process. (default: 0)
  113237. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  113238. */
  113239. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  113240. }
  113241. }
  113242. declare module BABYLON {
  113243. /**
  113244. * PostProcessRenderPipeline
  113245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113246. */
  113247. export class PostProcessRenderPipeline {
  113248. private engine;
  113249. private _renderEffects;
  113250. private _renderEffectsForIsolatedPass;
  113251. /**
  113252. * List of inspectable custom properties (used by the Inspector)
  113253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113254. */
  113255. inspectableCustomProperties: IInspectable[];
  113256. /**
  113257. * @hidden
  113258. */
  113259. protected _cameras: Camera[];
  113260. /** @hidden */
  113261. _name: string;
  113262. /**
  113263. * Gets pipeline name
  113264. */
  113265. readonly name: string;
  113266. /**
  113267. * Initializes a PostProcessRenderPipeline
  113268. * @param engine engine to add the pipeline to
  113269. * @param name name of the pipeline
  113270. */
  113271. constructor(engine: Engine, name: string);
  113272. /**
  113273. * Gets the class name
  113274. * @returns "PostProcessRenderPipeline"
  113275. */
  113276. getClassName(): string;
  113277. /**
  113278. * If all the render effects in the pipeline are supported
  113279. */
  113280. readonly isSupported: boolean;
  113281. /**
  113282. * Adds an effect to the pipeline
  113283. * @param renderEffect the effect to add
  113284. */
  113285. addEffect(renderEffect: PostProcessRenderEffect): void;
  113286. /** @hidden */
  113287. _rebuild(): void;
  113288. /** @hidden */
  113289. _enableEffect(renderEffectName: string, cameras: Camera): void;
  113290. /** @hidden */
  113291. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  113292. /** @hidden */
  113293. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113294. /** @hidden */
  113295. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  113296. /** @hidden */
  113297. _attachCameras(cameras: Camera, unique: boolean): void;
  113298. /** @hidden */
  113299. _attachCameras(cameras: Camera[], unique: boolean): void;
  113300. /** @hidden */
  113301. _detachCameras(cameras: Camera): void;
  113302. /** @hidden */
  113303. _detachCameras(cameras: Nullable<Camera[]>): void;
  113304. /** @hidden */
  113305. _update(): void;
  113306. /** @hidden */
  113307. _reset(): void;
  113308. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  113309. /**
  113310. * Disposes of the pipeline
  113311. */
  113312. dispose(): void;
  113313. }
  113314. }
  113315. declare module BABYLON {
  113316. /**
  113317. * PostProcessRenderPipelineManager class
  113318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113319. */
  113320. export class PostProcessRenderPipelineManager {
  113321. private _renderPipelines;
  113322. /**
  113323. * Initializes a PostProcessRenderPipelineManager
  113324. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113325. */
  113326. constructor();
  113327. /**
  113328. * Gets the list of supported render pipelines
  113329. */
  113330. readonly supportedPipelines: PostProcessRenderPipeline[];
  113331. /**
  113332. * Adds a pipeline to the manager
  113333. * @param renderPipeline The pipeline to add
  113334. */
  113335. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  113336. /**
  113337. * Attaches a camera to the pipeline
  113338. * @param renderPipelineName The name of the pipeline to attach to
  113339. * @param cameras the camera to attach
  113340. * @param unique if the camera can be attached multiple times to the pipeline
  113341. */
  113342. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  113343. /**
  113344. * Detaches a camera from the pipeline
  113345. * @param renderPipelineName The name of the pipeline to detach from
  113346. * @param cameras the camera to detach
  113347. */
  113348. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  113349. /**
  113350. * Enables an effect by name on a pipeline
  113351. * @param renderPipelineName the name of the pipeline to enable the effect in
  113352. * @param renderEffectName the name of the effect to enable
  113353. * @param cameras the cameras that the effect should be enabled on
  113354. */
  113355. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113356. /**
  113357. * Disables an effect by name on a pipeline
  113358. * @param renderPipelineName the name of the pipeline to disable the effect in
  113359. * @param renderEffectName the name of the effect to disable
  113360. * @param cameras the cameras that the effect should be disabled on
  113361. */
  113362. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  113363. /**
  113364. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  113365. */
  113366. update(): void;
  113367. /** @hidden */
  113368. _rebuild(): void;
  113369. /**
  113370. * Disposes of the manager and pipelines
  113371. */
  113372. dispose(): void;
  113373. }
  113374. }
  113375. declare module BABYLON {
  113376. interface Scene {
  113377. /** @hidden (Backing field) */
  113378. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113379. /**
  113380. * Gets the postprocess render pipeline manager
  113381. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  113382. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113383. */
  113384. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  113385. }
  113386. /**
  113387. * Defines the Render Pipeline scene component responsible to rendering pipelines
  113388. */
  113389. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  113390. /**
  113391. * The component name helpfull to identify the component in the list of scene components.
  113392. */
  113393. readonly name: string;
  113394. /**
  113395. * The scene the component belongs to.
  113396. */
  113397. scene: Scene;
  113398. /**
  113399. * Creates a new instance of the component for the given scene
  113400. * @param scene Defines the scene to register the component in
  113401. */
  113402. constructor(scene: Scene);
  113403. /**
  113404. * Registers the component in a given scene
  113405. */
  113406. register(): void;
  113407. /**
  113408. * Rebuilds the elements related to this component in case of
  113409. * context lost for instance.
  113410. */
  113411. rebuild(): void;
  113412. /**
  113413. * Disposes the component and the associated ressources
  113414. */
  113415. dispose(): void;
  113416. private _gatherRenderTargets;
  113417. }
  113418. }
  113419. declare module BABYLON {
  113420. /**
  113421. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113422. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113423. */
  113424. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113425. private _scene;
  113426. private _camerasToBeAttached;
  113427. /**
  113428. * ID of the sharpen post process,
  113429. */
  113430. private readonly SharpenPostProcessId;
  113431. /**
  113432. * @ignore
  113433. * ID of the image processing post process;
  113434. */
  113435. readonly ImageProcessingPostProcessId: string;
  113436. /**
  113437. * @ignore
  113438. * ID of the Fast Approximate Anti-Aliasing post process;
  113439. */
  113440. readonly FxaaPostProcessId: string;
  113441. /**
  113442. * ID of the chromatic aberration post process,
  113443. */
  113444. private readonly ChromaticAberrationPostProcessId;
  113445. /**
  113446. * ID of the grain post process
  113447. */
  113448. private readonly GrainPostProcessId;
  113449. /**
  113450. * Sharpen post process which will apply a sharpen convolution to enhance edges
  113451. */
  113452. sharpen: SharpenPostProcess;
  113453. private _sharpenEffect;
  113454. private bloom;
  113455. /**
  113456. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  113457. */
  113458. depthOfField: DepthOfFieldEffect;
  113459. /**
  113460. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113461. */
  113462. fxaa: FxaaPostProcess;
  113463. /**
  113464. * Image post processing pass used to perform operations such as tone mapping or color grading.
  113465. */
  113466. imageProcessing: ImageProcessingPostProcess;
  113467. /**
  113468. * Chromatic aberration post process which will shift rgb colors in the image
  113469. */
  113470. chromaticAberration: ChromaticAberrationPostProcess;
  113471. private _chromaticAberrationEffect;
  113472. /**
  113473. * Grain post process which add noise to the image
  113474. */
  113475. grain: GrainPostProcess;
  113476. private _grainEffect;
  113477. /**
  113478. * Glow post process which adds a glow to emissive areas of the image
  113479. */
  113480. private _glowLayer;
  113481. /**
  113482. * Animations which can be used to tweak settings over a period of time
  113483. */
  113484. animations: Animation[];
  113485. private _imageProcessingConfigurationObserver;
  113486. private _sharpenEnabled;
  113487. private _bloomEnabled;
  113488. private _depthOfFieldEnabled;
  113489. private _depthOfFieldBlurLevel;
  113490. private _fxaaEnabled;
  113491. private _imageProcessingEnabled;
  113492. private _defaultPipelineTextureType;
  113493. private _bloomScale;
  113494. private _chromaticAberrationEnabled;
  113495. private _grainEnabled;
  113496. private _buildAllowed;
  113497. /**
  113498. * Gets active scene
  113499. */
  113500. readonly scene: Scene;
  113501. /**
  113502. * Enable or disable the sharpen process from the pipeline
  113503. */
  113504. sharpenEnabled: boolean;
  113505. private _resizeObserver;
  113506. private _hardwareScaleLevel;
  113507. private _bloomKernel;
  113508. /**
  113509. * Specifies the size of the bloom blur kernel, relative to the final output size
  113510. */
  113511. bloomKernel: number;
  113512. /**
  113513. * Specifies the weight of the bloom in the final rendering
  113514. */
  113515. private _bloomWeight;
  113516. /**
  113517. * Specifies the luma threshold for the area that will be blurred by the bloom
  113518. */
  113519. private _bloomThreshold;
  113520. private _hdr;
  113521. /**
  113522. * The strength of the bloom.
  113523. */
  113524. bloomWeight: number;
  113525. /**
  113526. * The strength of the bloom.
  113527. */
  113528. bloomThreshold: number;
  113529. /**
  113530. * The scale of the bloom, lower value will provide better performance.
  113531. */
  113532. bloomScale: number;
  113533. /**
  113534. * Enable or disable the bloom from the pipeline
  113535. */
  113536. bloomEnabled: boolean;
  113537. private _rebuildBloom;
  113538. /**
  113539. * If the depth of field is enabled.
  113540. */
  113541. depthOfFieldEnabled: boolean;
  113542. /**
  113543. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113544. */
  113545. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  113546. /**
  113547. * If the anti aliasing is enabled.
  113548. */
  113549. fxaaEnabled: boolean;
  113550. private _samples;
  113551. /**
  113552. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113553. */
  113554. samples: number;
  113555. /**
  113556. * If image processing is enabled.
  113557. */
  113558. imageProcessingEnabled: boolean;
  113559. /**
  113560. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  113561. */
  113562. glowLayerEnabled: boolean;
  113563. /**
  113564. * Enable or disable the chromaticAberration process from the pipeline
  113565. */
  113566. chromaticAberrationEnabled: boolean;
  113567. /**
  113568. * Enable or disable the grain process from the pipeline
  113569. */
  113570. grainEnabled: boolean;
  113571. /**
  113572. * @constructor
  113573. * @param name - The rendering pipeline name (default: "")
  113574. * @param hdr - If high dynamic range textures should be used (default: true)
  113575. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113576. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113577. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113578. */
  113579. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  113580. /**
  113581. * Get the class name
  113582. * @returns "DefaultRenderingPipeline"
  113583. */
  113584. getClassName(): string;
  113585. /**
  113586. * Force the compilation of the entire pipeline.
  113587. */
  113588. prepare(): void;
  113589. private _hasCleared;
  113590. private _prevPostProcess;
  113591. private _prevPrevPostProcess;
  113592. private _setAutoClearAndTextureSharing;
  113593. private _depthOfFieldSceneObserver;
  113594. private _buildPipeline;
  113595. private _disposePostProcesses;
  113596. /**
  113597. * Adds a camera to the pipeline
  113598. * @param camera the camera to be added
  113599. */
  113600. addCamera(camera: Camera): void;
  113601. /**
  113602. * Removes a camera from the pipeline
  113603. * @param camera the camera to remove
  113604. */
  113605. removeCamera(camera: Camera): void;
  113606. /**
  113607. * Dispose of the pipeline and stop all post processes
  113608. */
  113609. dispose(): void;
  113610. /**
  113611. * Serialize the rendering pipeline (Used when exporting)
  113612. * @returns the serialized object
  113613. */
  113614. serialize(): any;
  113615. /**
  113616. * Parse the serialized pipeline
  113617. * @param source Source pipeline.
  113618. * @param scene The scene to load the pipeline to.
  113619. * @param rootUrl The URL of the serialized pipeline.
  113620. * @returns An instantiated pipeline from the serialized object.
  113621. */
  113622. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  113623. }
  113624. }
  113625. declare module BABYLON {
  113626. /** @hidden */
  113627. export var lensHighlightsPixelShader: {
  113628. name: string;
  113629. shader: string;
  113630. };
  113631. }
  113632. declare module BABYLON {
  113633. /** @hidden */
  113634. export var depthOfFieldPixelShader: {
  113635. name: string;
  113636. shader: string;
  113637. };
  113638. }
  113639. declare module BABYLON {
  113640. /**
  113641. * BABYLON.JS Chromatic Aberration GLSL Shader
  113642. * Author: Olivier Guyot
  113643. * Separates very slightly R, G and B colors on the edges of the screen
  113644. * Inspired by Francois Tarlier & Martins Upitis
  113645. */
  113646. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  113647. /**
  113648. * @ignore
  113649. * The chromatic aberration PostProcess id in the pipeline
  113650. */
  113651. LensChromaticAberrationEffect: string;
  113652. /**
  113653. * @ignore
  113654. * The highlights enhancing PostProcess id in the pipeline
  113655. */
  113656. HighlightsEnhancingEffect: string;
  113657. /**
  113658. * @ignore
  113659. * The depth-of-field PostProcess id in the pipeline
  113660. */
  113661. LensDepthOfFieldEffect: string;
  113662. private _scene;
  113663. private _depthTexture;
  113664. private _grainTexture;
  113665. private _chromaticAberrationPostProcess;
  113666. private _highlightsPostProcess;
  113667. private _depthOfFieldPostProcess;
  113668. private _edgeBlur;
  113669. private _grainAmount;
  113670. private _chromaticAberration;
  113671. private _distortion;
  113672. private _highlightsGain;
  113673. private _highlightsThreshold;
  113674. private _dofDistance;
  113675. private _dofAperture;
  113676. private _dofDarken;
  113677. private _dofPentagon;
  113678. private _blurNoise;
  113679. /**
  113680. * @constructor
  113681. *
  113682. * Effect parameters are as follow:
  113683. * {
  113684. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113685. * edge_blur: number; // from 0 to x (1 for realism)
  113686. * distortion: number; // from 0 to x (1 for realism)
  113687. * grain_amount: number; // from 0 to 1
  113688. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113689. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113690. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113691. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113692. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113693. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113694. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113695. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113696. * }
  113697. * Note: if an effect parameter is unset, effect is disabled
  113698. *
  113699. * @param name The rendering pipeline name
  113700. * @param parameters - An object containing all parameters (see above)
  113701. * @param scene The scene linked to this pipeline
  113702. * @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)
  113703. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113704. */
  113705. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113706. /**
  113707. * Get the class name
  113708. * @returns "LensRenderingPipeline"
  113709. */
  113710. getClassName(): string;
  113711. /**
  113712. * Gets associated scene
  113713. */
  113714. readonly scene: Scene;
  113715. /**
  113716. * Gets or sets the edge blur
  113717. */
  113718. edgeBlur: number;
  113719. /**
  113720. * Gets or sets the grain amount
  113721. */
  113722. grainAmount: number;
  113723. /**
  113724. * Gets or sets the chromatic aberration amount
  113725. */
  113726. chromaticAberration: number;
  113727. /**
  113728. * Gets or sets the depth of field aperture
  113729. */
  113730. dofAperture: number;
  113731. /**
  113732. * Gets or sets the edge distortion
  113733. */
  113734. edgeDistortion: number;
  113735. /**
  113736. * Gets or sets the depth of field distortion
  113737. */
  113738. dofDistortion: number;
  113739. /**
  113740. * Gets or sets the darken out of focus amount
  113741. */
  113742. darkenOutOfFocus: number;
  113743. /**
  113744. * Gets or sets a boolean indicating if blur noise is enabled
  113745. */
  113746. blurNoise: boolean;
  113747. /**
  113748. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113749. */
  113750. pentagonBokeh: boolean;
  113751. /**
  113752. * Gets or sets the highlight grain amount
  113753. */
  113754. highlightsGain: number;
  113755. /**
  113756. * Gets or sets the highlight threshold
  113757. */
  113758. highlightsThreshold: number;
  113759. /**
  113760. * Sets the amount of blur at the edges
  113761. * @param amount blur amount
  113762. */
  113763. setEdgeBlur(amount: number): void;
  113764. /**
  113765. * Sets edge blur to 0
  113766. */
  113767. disableEdgeBlur(): void;
  113768. /**
  113769. * Sets the amout of grain
  113770. * @param amount Amount of grain
  113771. */
  113772. setGrainAmount(amount: number): void;
  113773. /**
  113774. * Set grain amount to 0
  113775. */
  113776. disableGrain(): void;
  113777. /**
  113778. * Sets the chromatic aberration amount
  113779. * @param amount amount of chromatic aberration
  113780. */
  113781. setChromaticAberration(amount: number): void;
  113782. /**
  113783. * Sets chromatic aberration amount to 0
  113784. */
  113785. disableChromaticAberration(): void;
  113786. /**
  113787. * Sets the EdgeDistortion amount
  113788. * @param amount amount of EdgeDistortion
  113789. */
  113790. setEdgeDistortion(amount: number): void;
  113791. /**
  113792. * Sets edge distortion to 0
  113793. */
  113794. disableEdgeDistortion(): void;
  113795. /**
  113796. * Sets the FocusDistance amount
  113797. * @param amount amount of FocusDistance
  113798. */
  113799. setFocusDistance(amount: number): void;
  113800. /**
  113801. * Disables depth of field
  113802. */
  113803. disableDepthOfField(): void;
  113804. /**
  113805. * Sets the Aperture amount
  113806. * @param amount amount of Aperture
  113807. */
  113808. setAperture(amount: number): void;
  113809. /**
  113810. * Sets the DarkenOutOfFocus amount
  113811. * @param amount amount of DarkenOutOfFocus
  113812. */
  113813. setDarkenOutOfFocus(amount: number): void;
  113814. private _pentagonBokehIsEnabled;
  113815. /**
  113816. * Creates a pentagon bokeh effect
  113817. */
  113818. enablePentagonBokeh(): void;
  113819. /**
  113820. * Disables the pentagon bokeh effect
  113821. */
  113822. disablePentagonBokeh(): void;
  113823. /**
  113824. * Enables noise blur
  113825. */
  113826. enableNoiseBlur(): void;
  113827. /**
  113828. * Disables noise blur
  113829. */
  113830. disableNoiseBlur(): void;
  113831. /**
  113832. * Sets the HighlightsGain amount
  113833. * @param amount amount of HighlightsGain
  113834. */
  113835. setHighlightsGain(amount: number): void;
  113836. /**
  113837. * Sets the HighlightsThreshold amount
  113838. * @param amount amount of HighlightsThreshold
  113839. */
  113840. setHighlightsThreshold(amount: number): void;
  113841. /**
  113842. * Disables highlights
  113843. */
  113844. disableHighlights(): void;
  113845. /**
  113846. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113847. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113848. */
  113849. dispose(disableDepthRender?: boolean): void;
  113850. private _createChromaticAberrationPostProcess;
  113851. private _createHighlightsPostProcess;
  113852. private _createDepthOfFieldPostProcess;
  113853. private _createGrainTexture;
  113854. }
  113855. }
  113856. declare module BABYLON {
  113857. /** @hidden */
  113858. export var ssao2PixelShader: {
  113859. name: string;
  113860. shader: string;
  113861. };
  113862. }
  113863. declare module BABYLON {
  113864. /** @hidden */
  113865. export var ssaoCombinePixelShader: {
  113866. name: string;
  113867. shader: string;
  113868. };
  113869. }
  113870. declare module BABYLON {
  113871. /**
  113872. * Render pipeline to produce ssao effect
  113873. */
  113874. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113875. /**
  113876. * @ignore
  113877. * The PassPostProcess id in the pipeline that contains the original scene color
  113878. */
  113879. SSAOOriginalSceneColorEffect: string;
  113880. /**
  113881. * @ignore
  113882. * The SSAO PostProcess id in the pipeline
  113883. */
  113884. SSAORenderEffect: string;
  113885. /**
  113886. * @ignore
  113887. * The horizontal blur PostProcess id in the pipeline
  113888. */
  113889. SSAOBlurHRenderEffect: string;
  113890. /**
  113891. * @ignore
  113892. * The vertical blur PostProcess id in the pipeline
  113893. */
  113894. SSAOBlurVRenderEffect: string;
  113895. /**
  113896. * @ignore
  113897. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113898. */
  113899. SSAOCombineRenderEffect: string;
  113900. /**
  113901. * The output strength of the SSAO post-process. Default value is 1.0.
  113902. */
  113903. totalStrength: number;
  113904. /**
  113905. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113906. */
  113907. maxZ: number;
  113908. /**
  113909. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113910. */
  113911. minZAspect: number;
  113912. private _samples;
  113913. /**
  113914. * Number of samples used for the SSAO calculations. Default value is 8
  113915. */
  113916. samples: number;
  113917. private _textureSamples;
  113918. /**
  113919. * Number of samples to use for antialiasing
  113920. */
  113921. textureSamples: number;
  113922. /**
  113923. * Ratio object used for SSAO ratio and blur ratio
  113924. */
  113925. private _ratio;
  113926. /**
  113927. * Dynamically generated sphere sampler.
  113928. */
  113929. private _sampleSphere;
  113930. /**
  113931. * Blur filter offsets
  113932. */
  113933. private _samplerOffsets;
  113934. private _expensiveBlur;
  113935. /**
  113936. * If bilateral blur should be used
  113937. */
  113938. expensiveBlur: boolean;
  113939. /**
  113940. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113941. */
  113942. radius: number;
  113943. /**
  113944. * The base color of the SSAO post-process
  113945. * The final result is "base + ssao" between [0, 1]
  113946. */
  113947. base: number;
  113948. /**
  113949. * Support test.
  113950. */
  113951. static readonly IsSupported: boolean;
  113952. private _scene;
  113953. private _depthTexture;
  113954. private _normalTexture;
  113955. private _randomTexture;
  113956. private _originalColorPostProcess;
  113957. private _ssaoPostProcess;
  113958. private _blurHPostProcess;
  113959. private _blurVPostProcess;
  113960. private _ssaoCombinePostProcess;
  113961. private _firstUpdate;
  113962. /**
  113963. * Gets active scene
  113964. */
  113965. readonly scene: Scene;
  113966. /**
  113967. * @constructor
  113968. * @param name The rendering pipeline name
  113969. * @param scene The scene linked to this pipeline
  113970. * @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 }
  113971. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113972. */
  113973. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113974. /**
  113975. * Get the class name
  113976. * @returns "SSAO2RenderingPipeline"
  113977. */
  113978. getClassName(): string;
  113979. /**
  113980. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113981. */
  113982. dispose(disableGeometryBufferRenderer?: boolean): void;
  113983. private _createBlurPostProcess;
  113984. /** @hidden */
  113985. _rebuild(): void;
  113986. private _bits;
  113987. private _radicalInverse_VdC;
  113988. private _hammersley;
  113989. private _hemisphereSample_uniform;
  113990. private _generateHemisphere;
  113991. private _createSSAOPostProcess;
  113992. private _createSSAOCombinePostProcess;
  113993. private _createRandomTexture;
  113994. /**
  113995. * Serialize the rendering pipeline (Used when exporting)
  113996. * @returns the serialized object
  113997. */
  113998. serialize(): any;
  113999. /**
  114000. * Parse the serialized pipeline
  114001. * @param source Source pipeline.
  114002. * @param scene The scene to load the pipeline to.
  114003. * @param rootUrl The URL of the serialized pipeline.
  114004. * @returns An instantiated pipeline from the serialized object.
  114005. */
  114006. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  114007. }
  114008. }
  114009. declare module BABYLON {
  114010. /** @hidden */
  114011. export var ssaoPixelShader: {
  114012. name: string;
  114013. shader: string;
  114014. };
  114015. }
  114016. declare module BABYLON {
  114017. /**
  114018. * Render pipeline to produce ssao effect
  114019. */
  114020. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  114021. /**
  114022. * @ignore
  114023. * The PassPostProcess id in the pipeline that contains the original scene color
  114024. */
  114025. SSAOOriginalSceneColorEffect: string;
  114026. /**
  114027. * @ignore
  114028. * The SSAO PostProcess id in the pipeline
  114029. */
  114030. SSAORenderEffect: string;
  114031. /**
  114032. * @ignore
  114033. * The horizontal blur PostProcess id in the pipeline
  114034. */
  114035. SSAOBlurHRenderEffect: string;
  114036. /**
  114037. * @ignore
  114038. * The vertical blur PostProcess id in the pipeline
  114039. */
  114040. SSAOBlurVRenderEffect: string;
  114041. /**
  114042. * @ignore
  114043. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114044. */
  114045. SSAOCombineRenderEffect: string;
  114046. /**
  114047. * The output strength of the SSAO post-process. Default value is 1.0.
  114048. */
  114049. totalStrength: number;
  114050. /**
  114051. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  114052. */
  114053. radius: number;
  114054. /**
  114055. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  114056. * Must not be equal to fallOff and superior to fallOff.
  114057. * Default value is 0.0075
  114058. */
  114059. area: number;
  114060. /**
  114061. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  114062. * Must not be equal to area and inferior to area.
  114063. * Default value is 0.000001
  114064. */
  114065. fallOff: number;
  114066. /**
  114067. * The base color of the SSAO post-process
  114068. * The final result is "base + ssao" between [0, 1]
  114069. */
  114070. base: number;
  114071. private _scene;
  114072. private _depthTexture;
  114073. private _randomTexture;
  114074. private _originalColorPostProcess;
  114075. private _ssaoPostProcess;
  114076. private _blurHPostProcess;
  114077. private _blurVPostProcess;
  114078. private _ssaoCombinePostProcess;
  114079. private _firstUpdate;
  114080. /**
  114081. * Gets active scene
  114082. */
  114083. readonly scene: Scene;
  114084. /**
  114085. * @constructor
  114086. * @param name - The rendering pipeline name
  114087. * @param scene - The scene linked to this pipeline
  114088. * @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 }
  114089. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  114090. */
  114091. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  114092. /**
  114093. * Get the class name
  114094. * @returns "SSAORenderingPipeline"
  114095. */
  114096. getClassName(): string;
  114097. /**
  114098. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114099. */
  114100. dispose(disableDepthRender?: boolean): void;
  114101. private _createBlurPostProcess;
  114102. /** @hidden */
  114103. _rebuild(): void;
  114104. private _createSSAOPostProcess;
  114105. private _createSSAOCombinePostProcess;
  114106. private _createRandomTexture;
  114107. }
  114108. }
  114109. declare module BABYLON {
  114110. /** @hidden */
  114111. export var standardPixelShader: {
  114112. name: string;
  114113. shader: string;
  114114. };
  114115. }
  114116. declare module BABYLON {
  114117. /**
  114118. * Standard rendering pipeline
  114119. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114120. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  114121. */
  114122. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  114123. /**
  114124. * Public members
  114125. */
  114126. /**
  114127. * Post-process which contains the original scene color before the pipeline applies all the effects
  114128. */
  114129. originalPostProcess: Nullable<PostProcess>;
  114130. /**
  114131. * Post-process used to down scale an image x4
  114132. */
  114133. downSampleX4PostProcess: Nullable<PostProcess>;
  114134. /**
  114135. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  114136. */
  114137. brightPassPostProcess: Nullable<PostProcess>;
  114138. /**
  114139. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  114140. */
  114141. blurHPostProcesses: PostProcess[];
  114142. /**
  114143. * Post-process array storing all the vertical blur post-processes used by the pipeline
  114144. */
  114145. blurVPostProcesses: PostProcess[];
  114146. /**
  114147. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  114148. */
  114149. textureAdderPostProcess: Nullable<PostProcess>;
  114150. /**
  114151. * Post-process used to create volumetric lighting effect
  114152. */
  114153. volumetricLightPostProcess: Nullable<PostProcess>;
  114154. /**
  114155. * Post-process used to smooth the previous volumetric light post-process on the X axis
  114156. */
  114157. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  114158. /**
  114159. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  114160. */
  114161. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  114162. /**
  114163. * Post-process used to merge the volumetric light effect and the real scene color
  114164. */
  114165. volumetricLightMergePostProces: Nullable<PostProcess>;
  114166. /**
  114167. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  114168. */
  114169. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  114170. /**
  114171. * Base post-process used to calculate the average luminance of the final image for HDR
  114172. */
  114173. luminancePostProcess: Nullable<PostProcess>;
  114174. /**
  114175. * Post-processes used to create down sample post-processes in order to get
  114176. * the average luminance of the final image for HDR
  114177. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  114178. */
  114179. luminanceDownSamplePostProcesses: PostProcess[];
  114180. /**
  114181. * Post-process used to create a HDR effect (light adaptation)
  114182. */
  114183. hdrPostProcess: Nullable<PostProcess>;
  114184. /**
  114185. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  114186. */
  114187. textureAdderFinalPostProcess: Nullable<PostProcess>;
  114188. /**
  114189. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  114190. */
  114191. lensFlareFinalPostProcess: Nullable<PostProcess>;
  114192. /**
  114193. * Post-process used to merge the final HDR post-process and the real scene color
  114194. */
  114195. hdrFinalPostProcess: Nullable<PostProcess>;
  114196. /**
  114197. * Post-process used to create a lens flare effect
  114198. */
  114199. lensFlarePostProcess: Nullable<PostProcess>;
  114200. /**
  114201. * Post-process that merges the result of the lens flare post-process and the real scene color
  114202. */
  114203. lensFlareComposePostProcess: Nullable<PostProcess>;
  114204. /**
  114205. * Post-process used to create a motion blur effect
  114206. */
  114207. motionBlurPostProcess: Nullable<PostProcess>;
  114208. /**
  114209. * Post-process used to create a depth of field effect
  114210. */
  114211. depthOfFieldPostProcess: Nullable<PostProcess>;
  114212. /**
  114213. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  114214. */
  114215. fxaaPostProcess: Nullable<FxaaPostProcess>;
  114216. /**
  114217. * Represents the brightness threshold in order to configure the illuminated surfaces
  114218. */
  114219. brightThreshold: number;
  114220. /**
  114221. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  114222. */
  114223. blurWidth: number;
  114224. /**
  114225. * Sets if the blur for highlighted surfaces must be only horizontal
  114226. */
  114227. horizontalBlur: boolean;
  114228. /**
  114229. * Gets the overall exposure used by the pipeline
  114230. */
  114231. /**
  114232. * Sets the overall exposure used by the pipeline
  114233. */
  114234. exposure: number;
  114235. /**
  114236. * Texture used typically to simulate "dirty" on camera lens
  114237. */
  114238. lensTexture: Nullable<Texture>;
  114239. /**
  114240. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  114241. */
  114242. volumetricLightCoefficient: number;
  114243. /**
  114244. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  114245. */
  114246. volumetricLightPower: number;
  114247. /**
  114248. * Used the set the blur intensity to smooth the volumetric lights
  114249. */
  114250. volumetricLightBlurScale: number;
  114251. /**
  114252. * Light (spot or directional) used to generate the volumetric lights rays
  114253. * The source light must have a shadow generate so the pipeline can get its
  114254. * depth map
  114255. */
  114256. sourceLight: Nullable<SpotLight | DirectionalLight>;
  114257. /**
  114258. * For eye adaptation, represents the minimum luminance the eye can see
  114259. */
  114260. hdrMinimumLuminance: number;
  114261. /**
  114262. * For eye adaptation, represents the decrease luminance speed
  114263. */
  114264. hdrDecreaseRate: number;
  114265. /**
  114266. * For eye adaptation, represents the increase luminance speed
  114267. */
  114268. hdrIncreaseRate: number;
  114269. /**
  114270. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114271. */
  114272. /**
  114273. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  114274. */
  114275. hdrAutoExposure: boolean;
  114276. /**
  114277. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  114278. */
  114279. lensColorTexture: Nullable<Texture>;
  114280. /**
  114281. * The overall strengh for the lens flare effect
  114282. */
  114283. lensFlareStrength: number;
  114284. /**
  114285. * Dispersion coefficient for lens flare ghosts
  114286. */
  114287. lensFlareGhostDispersal: number;
  114288. /**
  114289. * Main lens flare halo width
  114290. */
  114291. lensFlareHaloWidth: number;
  114292. /**
  114293. * Based on the lens distortion effect, defines how much the lens flare result
  114294. * is distorted
  114295. */
  114296. lensFlareDistortionStrength: number;
  114297. /**
  114298. * Lens star texture must be used to simulate rays on the flares and is available
  114299. * in the documentation
  114300. */
  114301. lensStarTexture: Nullable<Texture>;
  114302. /**
  114303. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  114304. * flare effect by taking account of the dirt texture
  114305. */
  114306. lensFlareDirtTexture: Nullable<Texture>;
  114307. /**
  114308. * Represents the focal length for the depth of field effect
  114309. */
  114310. depthOfFieldDistance: number;
  114311. /**
  114312. * Represents the blur intensity for the blurred part of the depth of field effect
  114313. */
  114314. depthOfFieldBlurWidth: number;
  114315. /**
  114316. * For motion blur, defines how much the image is blurred by the movement
  114317. */
  114318. motionStrength: number;
  114319. /**
  114320. * List of animations for the pipeline (IAnimatable implementation)
  114321. */
  114322. animations: Animation[];
  114323. /**
  114324. * Private members
  114325. */
  114326. private _scene;
  114327. private _currentDepthOfFieldSource;
  114328. private _basePostProcess;
  114329. private _fixedExposure;
  114330. private _currentExposure;
  114331. private _hdrAutoExposure;
  114332. private _hdrCurrentLuminance;
  114333. private _floatTextureType;
  114334. private _ratio;
  114335. private _bloomEnabled;
  114336. private _depthOfFieldEnabled;
  114337. private _vlsEnabled;
  114338. private _lensFlareEnabled;
  114339. private _hdrEnabled;
  114340. private _motionBlurEnabled;
  114341. private _fxaaEnabled;
  114342. private _motionBlurSamples;
  114343. private _volumetricLightStepsCount;
  114344. private _samples;
  114345. /**
  114346. * @ignore
  114347. * Specifies if the bloom pipeline is enabled
  114348. */
  114349. BloomEnabled: boolean;
  114350. /**
  114351. * @ignore
  114352. * Specifies if the depth of field pipeline is enabed
  114353. */
  114354. DepthOfFieldEnabled: boolean;
  114355. /**
  114356. * @ignore
  114357. * Specifies if the lens flare pipeline is enabed
  114358. */
  114359. LensFlareEnabled: boolean;
  114360. /**
  114361. * @ignore
  114362. * Specifies if the HDR pipeline is enabled
  114363. */
  114364. HDREnabled: boolean;
  114365. /**
  114366. * @ignore
  114367. * Specifies if the volumetric lights scattering effect is enabled
  114368. */
  114369. VLSEnabled: boolean;
  114370. /**
  114371. * @ignore
  114372. * Specifies if the motion blur effect is enabled
  114373. */
  114374. MotionBlurEnabled: boolean;
  114375. /**
  114376. * Specifies if anti-aliasing is enabled
  114377. */
  114378. fxaaEnabled: boolean;
  114379. /**
  114380. * Specifies the number of steps used to calculate the volumetric lights
  114381. * Typically in interval [50, 200]
  114382. */
  114383. volumetricLightStepsCount: number;
  114384. /**
  114385. * Specifies the number of samples used for the motion blur effect
  114386. * Typically in interval [16, 64]
  114387. */
  114388. motionBlurSamples: number;
  114389. /**
  114390. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  114391. */
  114392. samples: number;
  114393. /**
  114394. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  114395. * @constructor
  114396. * @param name The rendering pipeline name
  114397. * @param scene The scene linked to this pipeline
  114398. * @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)
  114399. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  114400. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114401. */
  114402. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  114403. private _buildPipeline;
  114404. private _createDownSampleX4PostProcess;
  114405. private _createBrightPassPostProcess;
  114406. private _createBlurPostProcesses;
  114407. private _createTextureAdderPostProcess;
  114408. private _createVolumetricLightPostProcess;
  114409. private _createLuminancePostProcesses;
  114410. private _createHdrPostProcess;
  114411. private _createLensFlarePostProcess;
  114412. private _createDepthOfFieldPostProcess;
  114413. private _createMotionBlurPostProcess;
  114414. private _getDepthTexture;
  114415. private _disposePostProcesses;
  114416. /**
  114417. * Dispose of the pipeline and stop all post processes
  114418. */
  114419. dispose(): void;
  114420. /**
  114421. * Serialize the rendering pipeline (Used when exporting)
  114422. * @returns the serialized object
  114423. */
  114424. serialize(): any;
  114425. /**
  114426. * Parse the serialized pipeline
  114427. * @param source Source pipeline.
  114428. * @param scene The scene to load the pipeline to.
  114429. * @param rootUrl The URL of the serialized pipeline.
  114430. * @returns An instantiated pipeline from the serialized object.
  114431. */
  114432. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  114433. /**
  114434. * Luminance steps
  114435. */
  114436. static LuminanceSteps: number;
  114437. }
  114438. }
  114439. declare module BABYLON {
  114440. /** @hidden */
  114441. export var tonemapPixelShader: {
  114442. name: string;
  114443. shader: string;
  114444. };
  114445. }
  114446. declare module BABYLON {
  114447. /** Defines operator used for tonemapping */
  114448. export enum TonemappingOperator {
  114449. /** Hable */
  114450. Hable = 0,
  114451. /** Reinhard */
  114452. Reinhard = 1,
  114453. /** HejiDawson */
  114454. HejiDawson = 2,
  114455. /** Photographic */
  114456. Photographic = 3
  114457. }
  114458. /**
  114459. * Defines a post process to apply tone mapping
  114460. */
  114461. export class TonemapPostProcess extends PostProcess {
  114462. private _operator;
  114463. /** Defines the required exposure adjustement */
  114464. exposureAdjustment: number;
  114465. /**
  114466. * Creates a new TonemapPostProcess
  114467. * @param name defines the name of the postprocess
  114468. * @param _operator defines the operator to use
  114469. * @param exposureAdjustment defines the required exposure adjustement
  114470. * @param camera defines the camera to use (can be null)
  114471. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  114472. * @param engine defines the hosting engine (can be ignore if camera is set)
  114473. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114474. */
  114475. constructor(name: string, _operator: TonemappingOperator,
  114476. /** Defines the required exposure adjustement */
  114477. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  114478. }
  114479. }
  114480. declare module BABYLON {
  114481. /** @hidden */
  114482. export var depthVertexShader: {
  114483. name: string;
  114484. shader: string;
  114485. };
  114486. }
  114487. declare module BABYLON {
  114488. /** @hidden */
  114489. export var volumetricLightScatteringPixelShader: {
  114490. name: string;
  114491. shader: string;
  114492. };
  114493. }
  114494. declare module BABYLON {
  114495. /** @hidden */
  114496. export var volumetricLightScatteringPassPixelShader: {
  114497. name: string;
  114498. shader: string;
  114499. };
  114500. }
  114501. declare module BABYLON {
  114502. /**
  114503. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  114504. */
  114505. export class VolumetricLightScatteringPostProcess extends PostProcess {
  114506. private _volumetricLightScatteringPass;
  114507. private _volumetricLightScatteringRTT;
  114508. private _viewPort;
  114509. private _screenCoordinates;
  114510. private _cachedDefines;
  114511. /**
  114512. * If not undefined, the mesh position is computed from the attached node position
  114513. */
  114514. attachedNode: {
  114515. position: Vector3;
  114516. };
  114517. /**
  114518. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  114519. */
  114520. customMeshPosition: Vector3;
  114521. /**
  114522. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  114523. */
  114524. useCustomMeshPosition: boolean;
  114525. /**
  114526. * If the post-process should inverse the light scattering direction
  114527. */
  114528. invert: boolean;
  114529. /**
  114530. * The internal mesh used by the post-process
  114531. */
  114532. mesh: Mesh;
  114533. /**
  114534. * @hidden
  114535. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  114536. */
  114537. useDiffuseColor: boolean;
  114538. /**
  114539. * Array containing the excluded meshes not rendered in the internal pass
  114540. */
  114541. excludedMeshes: AbstractMesh[];
  114542. /**
  114543. * Controls the overall intensity of the post-process
  114544. */
  114545. exposure: number;
  114546. /**
  114547. * Dissipates each sample's contribution in range [0, 1]
  114548. */
  114549. decay: number;
  114550. /**
  114551. * Controls the overall intensity of each sample
  114552. */
  114553. weight: number;
  114554. /**
  114555. * Controls the density of each sample
  114556. */
  114557. density: number;
  114558. /**
  114559. * @constructor
  114560. * @param name The post-process name
  114561. * @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)
  114562. * @param camera The camera that the post-process will be attached to
  114563. * @param mesh The mesh used to create the light scattering
  114564. * @param samples The post-process quality, default 100
  114565. * @param samplingModeThe post-process filtering mode
  114566. * @param engine The babylon engine
  114567. * @param reusable If the post-process is reusable
  114568. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  114569. */
  114570. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  114571. /**
  114572. * Returns the string "VolumetricLightScatteringPostProcess"
  114573. * @returns "VolumetricLightScatteringPostProcess"
  114574. */
  114575. getClassName(): string;
  114576. private _isReady;
  114577. /**
  114578. * Sets the new light position for light scattering effect
  114579. * @param position The new custom light position
  114580. */
  114581. setCustomMeshPosition(position: Vector3): void;
  114582. /**
  114583. * Returns the light position for light scattering effect
  114584. * @return Vector3 The custom light position
  114585. */
  114586. getCustomMeshPosition(): Vector3;
  114587. /**
  114588. * Disposes the internal assets and detaches the post-process from the camera
  114589. */
  114590. dispose(camera: Camera): void;
  114591. /**
  114592. * Returns the render target texture used by the post-process
  114593. * @return the render target texture used by the post-process
  114594. */
  114595. getPass(): RenderTargetTexture;
  114596. private _meshExcluded;
  114597. private _createPass;
  114598. private _updateMeshScreenCoordinates;
  114599. /**
  114600. * Creates a default mesh for the Volumeric Light Scattering post-process
  114601. * @param name The mesh name
  114602. * @param scene The scene where to create the mesh
  114603. * @return the default mesh
  114604. */
  114605. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  114606. }
  114607. }
  114608. declare module BABYLON {
  114609. interface Scene {
  114610. /** @hidden (Backing field) */
  114611. _boundingBoxRenderer: BoundingBoxRenderer;
  114612. /** @hidden (Backing field) */
  114613. _forceShowBoundingBoxes: boolean;
  114614. /**
  114615. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  114616. */
  114617. forceShowBoundingBoxes: boolean;
  114618. /**
  114619. * Gets the bounding box renderer associated with the scene
  114620. * @returns a BoundingBoxRenderer
  114621. */
  114622. getBoundingBoxRenderer(): BoundingBoxRenderer;
  114623. }
  114624. interface AbstractMesh {
  114625. /** @hidden (Backing field) */
  114626. _showBoundingBox: boolean;
  114627. /**
  114628. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  114629. */
  114630. showBoundingBox: boolean;
  114631. }
  114632. /**
  114633. * Component responsible of rendering the bounding box of the meshes in a scene.
  114634. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  114635. */
  114636. export class BoundingBoxRenderer implements ISceneComponent {
  114637. /**
  114638. * The component name helpfull to identify the component in the list of scene components.
  114639. */
  114640. readonly name: string;
  114641. /**
  114642. * The scene the component belongs to.
  114643. */
  114644. scene: Scene;
  114645. /**
  114646. * Color of the bounding box lines placed in front of an object
  114647. */
  114648. frontColor: Color3;
  114649. /**
  114650. * Color of the bounding box lines placed behind an object
  114651. */
  114652. backColor: Color3;
  114653. /**
  114654. * Defines if the renderer should show the back lines or not
  114655. */
  114656. showBackLines: boolean;
  114657. /**
  114658. * @hidden
  114659. */
  114660. renderList: SmartArray<BoundingBox>;
  114661. private _colorShader;
  114662. private _vertexBuffers;
  114663. private _indexBuffer;
  114664. /**
  114665. * Instantiates a new bounding box renderer in a scene.
  114666. * @param scene the scene the renderer renders in
  114667. */
  114668. constructor(scene: Scene);
  114669. /**
  114670. * Registers the component in a given scene
  114671. */
  114672. register(): void;
  114673. private _evaluateSubMesh;
  114674. private _activeMesh;
  114675. private _prepareRessources;
  114676. private _createIndexBuffer;
  114677. /**
  114678. * Rebuilds the elements related to this component in case of
  114679. * context lost for instance.
  114680. */
  114681. rebuild(): void;
  114682. /**
  114683. * @hidden
  114684. */
  114685. reset(): void;
  114686. /**
  114687. * Render the bounding boxes of a specific rendering group
  114688. * @param renderingGroupId defines the rendering group to render
  114689. */
  114690. render(renderingGroupId: number): void;
  114691. /**
  114692. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114693. * @param mesh Define the mesh to render the occlusion bounding box for
  114694. */
  114695. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114696. /**
  114697. * Dispose and release the resources attached to this renderer.
  114698. */
  114699. dispose(): void;
  114700. }
  114701. }
  114702. declare module BABYLON {
  114703. /** @hidden */
  114704. export var depthPixelShader: {
  114705. name: string;
  114706. shader: string;
  114707. };
  114708. }
  114709. declare module BABYLON {
  114710. /**
  114711. * This represents a depth renderer in Babylon.
  114712. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114713. */
  114714. export class DepthRenderer {
  114715. private _scene;
  114716. private _depthMap;
  114717. private _effect;
  114718. private _cachedDefines;
  114719. private _camera;
  114720. /**
  114721. * Specifiess that the depth renderer will only be used within
  114722. * the camera it is created for.
  114723. * This can help forcing its rendering during the camera processing.
  114724. */
  114725. useOnlyInActiveCamera: boolean;
  114726. /** @hidden */
  114727. static _SceneComponentInitialization: (scene: Scene) => void;
  114728. /**
  114729. * Instantiates a depth renderer
  114730. * @param scene The scene the renderer belongs to
  114731. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114732. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114733. */
  114734. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114735. /**
  114736. * Creates the depth rendering effect and checks if the effect is ready.
  114737. * @param subMesh The submesh to be used to render the depth map of
  114738. * @param useInstances If multiple world instances should be used
  114739. * @returns if the depth renderer is ready to render the depth map
  114740. */
  114741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114742. /**
  114743. * Gets the texture which the depth map will be written to.
  114744. * @returns The depth map texture
  114745. */
  114746. getDepthMap(): RenderTargetTexture;
  114747. /**
  114748. * Disposes of the depth renderer.
  114749. */
  114750. dispose(): void;
  114751. }
  114752. }
  114753. declare module BABYLON {
  114754. interface Scene {
  114755. /** @hidden (Backing field) */
  114756. _depthRenderer: {
  114757. [id: string]: DepthRenderer;
  114758. };
  114759. /**
  114760. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114761. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114762. * @returns the created depth renderer
  114763. */
  114764. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114765. /**
  114766. * Disables a depth renderer for a given camera
  114767. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114768. */
  114769. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114770. }
  114771. /**
  114772. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114773. * in several rendering techniques.
  114774. */
  114775. export class DepthRendererSceneComponent implements ISceneComponent {
  114776. /**
  114777. * The component name helpfull to identify the component in the list of scene components.
  114778. */
  114779. readonly name: string;
  114780. /**
  114781. * The scene the component belongs to.
  114782. */
  114783. scene: Scene;
  114784. /**
  114785. * Creates a new instance of the component for the given scene
  114786. * @param scene Defines the scene to register the component in
  114787. */
  114788. constructor(scene: Scene);
  114789. /**
  114790. * Registers the component in a given scene
  114791. */
  114792. register(): void;
  114793. /**
  114794. * Rebuilds the elements related to this component in case of
  114795. * context lost for instance.
  114796. */
  114797. rebuild(): void;
  114798. /**
  114799. * Disposes the component and the associated ressources
  114800. */
  114801. dispose(): void;
  114802. private _gatherRenderTargets;
  114803. private _gatherActiveCameraRenderTargets;
  114804. }
  114805. }
  114806. declare module BABYLON {
  114807. /** @hidden */
  114808. export var outlinePixelShader: {
  114809. name: string;
  114810. shader: string;
  114811. };
  114812. }
  114813. declare module BABYLON {
  114814. /** @hidden */
  114815. export var outlineVertexShader: {
  114816. name: string;
  114817. shader: string;
  114818. };
  114819. }
  114820. declare module BABYLON {
  114821. interface Scene {
  114822. /** @hidden */
  114823. _outlineRenderer: OutlineRenderer;
  114824. /**
  114825. * Gets the outline renderer associated with the scene
  114826. * @returns a OutlineRenderer
  114827. */
  114828. getOutlineRenderer(): OutlineRenderer;
  114829. }
  114830. interface AbstractMesh {
  114831. /** @hidden (Backing field) */
  114832. _renderOutline: boolean;
  114833. /**
  114834. * Gets or sets a boolean indicating if the outline must be rendered as well
  114835. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114836. */
  114837. renderOutline: boolean;
  114838. /** @hidden (Backing field) */
  114839. _renderOverlay: boolean;
  114840. /**
  114841. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114842. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114843. */
  114844. renderOverlay: boolean;
  114845. }
  114846. /**
  114847. * This class is responsible to draw bothe outline/overlay of meshes.
  114848. * It should not be used directly but through the available method on mesh.
  114849. */
  114850. export class OutlineRenderer implements ISceneComponent {
  114851. /**
  114852. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114853. */
  114854. private static _StencilReference;
  114855. /**
  114856. * The name of the component. Each component must have a unique name.
  114857. */
  114858. name: string;
  114859. /**
  114860. * The scene the component belongs to.
  114861. */
  114862. scene: Scene;
  114863. /**
  114864. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114865. */
  114866. zOffset: number;
  114867. private _engine;
  114868. private _effect;
  114869. private _cachedDefines;
  114870. private _savedDepthWrite;
  114871. /**
  114872. * Instantiates a new outline renderer. (There could be only one per scene).
  114873. * @param scene Defines the scene it belongs to
  114874. */
  114875. constructor(scene: Scene);
  114876. /**
  114877. * Register the component to one instance of a scene.
  114878. */
  114879. register(): void;
  114880. /**
  114881. * Rebuilds the elements related to this component in case of
  114882. * context lost for instance.
  114883. */
  114884. rebuild(): void;
  114885. /**
  114886. * Disposes the component and the associated ressources.
  114887. */
  114888. dispose(): void;
  114889. /**
  114890. * Renders the outline in the canvas.
  114891. * @param subMesh Defines the sumesh to render
  114892. * @param batch Defines the batch of meshes in case of instances
  114893. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114894. */
  114895. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114896. /**
  114897. * Returns whether or not the outline renderer is ready for a given submesh.
  114898. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114899. * @param subMesh Defines the submesh to check readyness for
  114900. * @param useInstances Defines wheter wee are trying to render instances or not
  114901. * @returns true if ready otherwise false
  114902. */
  114903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114904. private _beforeRenderingMesh;
  114905. private _afterRenderingMesh;
  114906. }
  114907. }
  114908. declare module BABYLON {
  114909. /**
  114910. * Defines the list of states available for a task inside a AssetsManager
  114911. */
  114912. export enum AssetTaskState {
  114913. /**
  114914. * Initialization
  114915. */
  114916. INIT = 0,
  114917. /**
  114918. * Running
  114919. */
  114920. RUNNING = 1,
  114921. /**
  114922. * Done
  114923. */
  114924. DONE = 2,
  114925. /**
  114926. * Error
  114927. */
  114928. ERROR = 3
  114929. }
  114930. /**
  114931. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114932. */
  114933. export abstract class AbstractAssetTask {
  114934. /**
  114935. * Task name
  114936. */ name: string;
  114937. /**
  114938. * Callback called when the task is successful
  114939. */
  114940. onSuccess: (task: any) => void;
  114941. /**
  114942. * Callback called when the task is not successful
  114943. */
  114944. onError: (task: any, message?: string, exception?: any) => void;
  114945. /**
  114946. * Creates a new AssetsManager
  114947. * @param name defines the name of the task
  114948. */
  114949. constructor(
  114950. /**
  114951. * Task name
  114952. */ name: string);
  114953. private _isCompleted;
  114954. private _taskState;
  114955. private _errorObject;
  114956. /**
  114957. * Get if the task is completed
  114958. */
  114959. readonly isCompleted: boolean;
  114960. /**
  114961. * Gets the current state of the task
  114962. */
  114963. readonly taskState: AssetTaskState;
  114964. /**
  114965. * Gets the current error object (if task is in error)
  114966. */
  114967. readonly errorObject: {
  114968. message?: string;
  114969. exception?: any;
  114970. };
  114971. /**
  114972. * Internal only
  114973. * @hidden
  114974. */
  114975. _setErrorObject(message?: string, exception?: any): void;
  114976. /**
  114977. * Execute the current task
  114978. * @param scene defines the scene where you want your assets to be loaded
  114979. * @param onSuccess is a callback called when the task is successfully executed
  114980. * @param onError is a callback called if an error occurs
  114981. */
  114982. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114983. /**
  114984. * Execute the current task
  114985. * @param scene defines the scene where you want your assets to be loaded
  114986. * @param onSuccess is a callback called when the task is successfully executed
  114987. * @param onError is a callback called if an error occurs
  114988. */
  114989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114990. /**
  114991. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114992. * This can be used with failed tasks that have the reason for failure fixed.
  114993. */
  114994. reset(): void;
  114995. private onErrorCallback;
  114996. private onDoneCallback;
  114997. }
  114998. /**
  114999. * Define the interface used by progress events raised during assets loading
  115000. */
  115001. export interface IAssetsProgressEvent {
  115002. /**
  115003. * Defines the number of remaining tasks to process
  115004. */
  115005. remainingCount: number;
  115006. /**
  115007. * Defines the total number of tasks
  115008. */
  115009. totalCount: number;
  115010. /**
  115011. * Defines the task that was just processed
  115012. */
  115013. task: AbstractAssetTask;
  115014. }
  115015. /**
  115016. * Class used to share progress information about assets loading
  115017. */
  115018. export class AssetsProgressEvent implements IAssetsProgressEvent {
  115019. /**
  115020. * Defines the number of remaining tasks to process
  115021. */
  115022. remainingCount: number;
  115023. /**
  115024. * Defines the total number of tasks
  115025. */
  115026. totalCount: number;
  115027. /**
  115028. * Defines the task that was just processed
  115029. */
  115030. task: AbstractAssetTask;
  115031. /**
  115032. * Creates a AssetsProgressEvent
  115033. * @param remainingCount defines the number of remaining tasks to process
  115034. * @param totalCount defines the total number of tasks
  115035. * @param task defines the task that was just processed
  115036. */
  115037. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  115038. }
  115039. /**
  115040. * Define a task used by AssetsManager to load meshes
  115041. */
  115042. export class MeshAssetTask extends AbstractAssetTask {
  115043. /**
  115044. * Defines the name of the task
  115045. */
  115046. name: string;
  115047. /**
  115048. * Defines the list of mesh's names you want to load
  115049. */
  115050. meshesNames: any;
  115051. /**
  115052. * Defines the root url to use as a base to load your meshes and associated resources
  115053. */
  115054. rootUrl: string;
  115055. /**
  115056. * Defines the filename of the scene to load from
  115057. */
  115058. sceneFilename: string;
  115059. /**
  115060. * Gets the list of loaded meshes
  115061. */
  115062. loadedMeshes: Array<AbstractMesh>;
  115063. /**
  115064. * Gets the list of loaded particle systems
  115065. */
  115066. loadedParticleSystems: Array<IParticleSystem>;
  115067. /**
  115068. * Gets the list of loaded skeletons
  115069. */
  115070. loadedSkeletons: Array<Skeleton>;
  115071. /**
  115072. * Gets the list of loaded animation groups
  115073. */
  115074. loadedAnimationGroups: Array<AnimationGroup>;
  115075. /**
  115076. * Callback called when the task is successful
  115077. */
  115078. onSuccess: (task: MeshAssetTask) => void;
  115079. /**
  115080. * Callback called when the task is successful
  115081. */
  115082. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  115083. /**
  115084. * Creates a new MeshAssetTask
  115085. * @param name defines the name of the task
  115086. * @param meshesNames defines the list of mesh's names you want to load
  115087. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  115088. * @param sceneFilename defines the filename of the scene to load from
  115089. */
  115090. constructor(
  115091. /**
  115092. * Defines the name of the task
  115093. */
  115094. name: string,
  115095. /**
  115096. * Defines the list of mesh's names you want to load
  115097. */
  115098. meshesNames: any,
  115099. /**
  115100. * Defines the root url to use as a base to load your meshes and associated resources
  115101. */
  115102. rootUrl: string,
  115103. /**
  115104. * Defines the filename of the scene to load from
  115105. */
  115106. sceneFilename: string);
  115107. /**
  115108. * Execute the current task
  115109. * @param scene defines the scene where you want your assets to be loaded
  115110. * @param onSuccess is a callback called when the task is successfully executed
  115111. * @param onError is a callback called if an error occurs
  115112. */
  115113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115114. }
  115115. /**
  115116. * Define a task used by AssetsManager to load text content
  115117. */
  115118. export class TextFileAssetTask extends AbstractAssetTask {
  115119. /**
  115120. * Defines the name of the task
  115121. */
  115122. name: string;
  115123. /**
  115124. * Defines the location of the file to load
  115125. */
  115126. url: string;
  115127. /**
  115128. * Gets the loaded text string
  115129. */
  115130. text: string;
  115131. /**
  115132. * Callback called when the task is successful
  115133. */
  115134. onSuccess: (task: TextFileAssetTask) => void;
  115135. /**
  115136. * Callback called when the task is successful
  115137. */
  115138. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  115139. /**
  115140. * Creates a new TextFileAssetTask object
  115141. * @param name defines the name of the task
  115142. * @param url defines the location of the file to load
  115143. */
  115144. constructor(
  115145. /**
  115146. * Defines the name of the task
  115147. */
  115148. name: string,
  115149. /**
  115150. * Defines the location of the file to load
  115151. */
  115152. url: string);
  115153. /**
  115154. * Execute the current task
  115155. * @param scene defines the scene where you want your assets to be loaded
  115156. * @param onSuccess is a callback called when the task is successfully executed
  115157. * @param onError is a callback called if an error occurs
  115158. */
  115159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115160. }
  115161. /**
  115162. * Define a task used by AssetsManager to load binary data
  115163. */
  115164. export class BinaryFileAssetTask extends AbstractAssetTask {
  115165. /**
  115166. * Defines the name of the task
  115167. */
  115168. name: string;
  115169. /**
  115170. * Defines the location of the file to load
  115171. */
  115172. url: string;
  115173. /**
  115174. * Gets the lodaded data (as an array buffer)
  115175. */
  115176. data: ArrayBuffer;
  115177. /**
  115178. * Callback called when the task is successful
  115179. */
  115180. onSuccess: (task: BinaryFileAssetTask) => void;
  115181. /**
  115182. * Callback called when the task is successful
  115183. */
  115184. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  115185. /**
  115186. * Creates a new BinaryFileAssetTask object
  115187. * @param name defines the name of the new task
  115188. * @param url defines the location of the file to load
  115189. */
  115190. constructor(
  115191. /**
  115192. * Defines the name of the task
  115193. */
  115194. name: string,
  115195. /**
  115196. * Defines the location of the file to load
  115197. */
  115198. url: string);
  115199. /**
  115200. * Execute the current task
  115201. * @param scene defines the scene where you want your assets to be loaded
  115202. * @param onSuccess is a callback called when the task is successfully executed
  115203. * @param onError is a callback called if an error occurs
  115204. */
  115205. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115206. }
  115207. /**
  115208. * Define a task used by AssetsManager to load images
  115209. */
  115210. export class ImageAssetTask extends AbstractAssetTask {
  115211. /**
  115212. * Defines the name of the task
  115213. */
  115214. name: string;
  115215. /**
  115216. * Defines the location of the image to load
  115217. */
  115218. url: string;
  115219. /**
  115220. * Gets the loaded images
  115221. */
  115222. image: HTMLImageElement;
  115223. /**
  115224. * Callback called when the task is successful
  115225. */
  115226. onSuccess: (task: ImageAssetTask) => void;
  115227. /**
  115228. * Callback called when the task is successful
  115229. */
  115230. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  115231. /**
  115232. * Creates a new ImageAssetTask
  115233. * @param name defines the name of the task
  115234. * @param url defines the location of the image to load
  115235. */
  115236. constructor(
  115237. /**
  115238. * Defines the name of the task
  115239. */
  115240. name: string,
  115241. /**
  115242. * Defines the location of the image to load
  115243. */
  115244. url: string);
  115245. /**
  115246. * Execute the current task
  115247. * @param scene defines the scene where you want your assets to be loaded
  115248. * @param onSuccess is a callback called when the task is successfully executed
  115249. * @param onError is a callback called if an error occurs
  115250. */
  115251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115252. }
  115253. /**
  115254. * Defines the interface used by texture loading tasks
  115255. */
  115256. export interface ITextureAssetTask<TEX extends BaseTexture> {
  115257. /**
  115258. * Gets the loaded texture
  115259. */
  115260. texture: TEX;
  115261. }
  115262. /**
  115263. * Define a task used by AssetsManager to load 2D textures
  115264. */
  115265. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  115266. /**
  115267. * Defines the name of the task
  115268. */
  115269. name: string;
  115270. /**
  115271. * Defines the location of the file to load
  115272. */
  115273. url: string;
  115274. /**
  115275. * Defines if mipmap should not be generated (default is false)
  115276. */
  115277. noMipmap?: boolean | undefined;
  115278. /**
  115279. * Defines if texture must be inverted on Y axis (default is false)
  115280. */
  115281. invertY?: boolean | undefined;
  115282. /**
  115283. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115284. */
  115285. samplingMode: number;
  115286. /**
  115287. * Gets the loaded texture
  115288. */
  115289. texture: Texture;
  115290. /**
  115291. * Callback called when the task is successful
  115292. */
  115293. onSuccess: (task: TextureAssetTask) => void;
  115294. /**
  115295. * Callback called when the task is successful
  115296. */
  115297. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  115298. /**
  115299. * Creates a new TextureAssetTask object
  115300. * @param name defines the name of the task
  115301. * @param url defines the location of the file to load
  115302. * @param noMipmap defines if mipmap should not be generated (default is false)
  115303. * @param invertY defines if texture must be inverted on Y axis (default is false)
  115304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115305. */
  115306. constructor(
  115307. /**
  115308. * Defines the name of the task
  115309. */
  115310. name: string,
  115311. /**
  115312. * Defines the location of the file to load
  115313. */
  115314. url: string,
  115315. /**
  115316. * Defines if mipmap should not be generated (default is false)
  115317. */
  115318. noMipmap?: boolean | undefined,
  115319. /**
  115320. * Defines if texture must be inverted on Y axis (default is false)
  115321. */
  115322. invertY?: boolean | undefined,
  115323. /**
  115324. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  115325. */
  115326. samplingMode?: number);
  115327. /**
  115328. * Execute the current task
  115329. * @param scene defines the scene where you want your assets to be loaded
  115330. * @param onSuccess is a callback called when the task is successfully executed
  115331. * @param onError is a callback called if an error occurs
  115332. */
  115333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115334. }
  115335. /**
  115336. * Define a task used by AssetsManager to load cube textures
  115337. */
  115338. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  115339. /**
  115340. * Defines the name of the task
  115341. */
  115342. name: string;
  115343. /**
  115344. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115345. */
  115346. url: string;
  115347. /**
  115348. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115349. */
  115350. extensions?: string[] | undefined;
  115351. /**
  115352. * Defines if mipmaps should not be generated (default is false)
  115353. */
  115354. noMipmap?: boolean | undefined;
  115355. /**
  115356. * Defines the explicit list of files (undefined by default)
  115357. */
  115358. files?: string[] | undefined;
  115359. /**
  115360. * Gets the loaded texture
  115361. */
  115362. texture: CubeTexture;
  115363. /**
  115364. * Callback called when the task is successful
  115365. */
  115366. onSuccess: (task: CubeTextureAssetTask) => void;
  115367. /**
  115368. * Callback called when the task is successful
  115369. */
  115370. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  115371. /**
  115372. * Creates a new CubeTextureAssetTask
  115373. * @param name defines the name of the task
  115374. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115375. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115376. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115377. * @param files defines the explicit list of files (undefined by default)
  115378. */
  115379. constructor(
  115380. /**
  115381. * Defines the name of the task
  115382. */
  115383. name: string,
  115384. /**
  115385. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  115386. */
  115387. url: string,
  115388. /**
  115389. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  115390. */
  115391. extensions?: string[] | undefined,
  115392. /**
  115393. * Defines if mipmaps should not be generated (default is false)
  115394. */
  115395. noMipmap?: boolean | undefined,
  115396. /**
  115397. * Defines the explicit list of files (undefined by default)
  115398. */
  115399. files?: string[] | undefined);
  115400. /**
  115401. * Execute the current task
  115402. * @param scene defines the scene where you want your assets to be loaded
  115403. * @param onSuccess is a callback called when the task is successfully executed
  115404. * @param onError is a callback called if an error occurs
  115405. */
  115406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115407. }
  115408. /**
  115409. * Define a task used by AssetsManager to load HDR cube textures
  115410. */
  115411. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  115412. /**
  115413. * Defines the name of the task
  115414. */
  115415. name: string;
  115416. /**
  115417. * Defines the location of the file to load
  115418. */
  115419. url: string;
  115420. /**
  115421. * Defines the desired size (the more it increases the longer the generation will be)
  115422. */
  115423. size: number;
  115424. /**
  115425. * Defines if mipmaps should not be generated (default is false)
  115426. */
  115427. noMipmap: boolean;
  115428. /**
  115429. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115430. */
  115431. generateHarmonics: boolean;
  115432. /**
  115433. * 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)
  115434. */
  115435. gammaSpace: boolean;
  115436. /**
  115437. * Internal Use Only
  115438. */
  115439. reserved: boolean;
  115440. /**
  115441. * Gets the loaded texture
  115442. */
  115443. texture: HDRCubeTexture;
  115444. /**
  115445. * Callback called when the task is successful
  115446. */
  115447. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  115448. /**
  115449. * Callback called when the task is successful
  115450. */
  115451. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  115452. /**
  115453. * Creates a new HDRCubeTextureAssetTask object
  115454. * @param name defines the name of the task
  115455. * @param url defines the location of the file to load
  115456. * @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.
  115457. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115458. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115459. * @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)
  115460. * @param reserved Internal use only
  115461. */
  115462. constructor(
  115463. /**
  115464. * Defines the name of the task
  115465. */
  115466. name: string,
  115467. /**
  115468. * Defines the location of the file to load
  115469. */
  115470. url: string,
  115471. /**
  115472. * Defines the desired size (the more it increases the longer the generation will be)
  115473. */
  115474. size: number,
  115475. /**
  115476. * Defines if mipmaps should not be generated (default is false)
  115477. */
  115478. noMipmap?: boolean,
  115479. /**
  115480. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  115481. */
  115482. generateHarmonics?: boolean,
  115483. /**
  115484. * 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)
  115485. */
  115486. gammaSpace?: boolean,
  115487. /**
  115488. * Internal Use Only
  115489. */
  115490. reserved?: boolean);
  115491. /**
  115492. * Execute the current task
  115493. * @param scene defines the scene where you want your assets to be loaded
  115494. * @param onSuccess is a callback called when the task is successfully executed
  115495. * @param onError is a callback called if an error occurs
  115496. */
  115497. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115498. }
  115499. /**
  115500. * Define a task used by AssetsManager to load Equirectangular cube textures
  115501. */
  115502. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  115503. /**
  115504. * Defines the name of the task
  115505. */
  115506. name: string;
  115507. /**
  115508. * Defines the location of the file to load
  115509. */
  115510. url: string;
  115511. /**
  115512. * Defines the desired size (the more it increases the longer the generation will be)
  115513. */
  115514. size: number;
  115515. /**
  115516. * Defines if mipmaps should not be generated (default is false)
  115517. */
  115518. noMipmap: boolean;
  115519. /**
  115520. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115521. * but the standard material would require them in Gamma space) (default is true)
  115522. */
  115523. gammaSpace: boolean;
  115524. /**
  115525. * Gets the loaded texture
  115526. */
  115527. texture: EquiRectangularCubeTexture;
  115528. /**
  115529. * Callback called when the task is successful
  115530. */
  115531. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  115532. /**
  115533. * Callback called when the task is successful
  115534. */
  115535. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  115536. /**
  115537. * Creates a new EquiRectangularCubeTextureAssetTask object
  115538. * @param name defines the name of the task
  115539. * @param url defines the location of the file to load
  115540. * @param size defines the desired size (the more it increases the longer the generation will be)
  115541. * If the size is omitted this implies you are using a preprocessed cubemap.
  115542. * @param noMipmap defines if mipmaps should not be generated (default is false)
  115543. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  115544. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  115545. * (default is true)
  115546. */
  115547. constructor(
  115548. /**
  115549. * Defines the name of the task
  115550. */
  115551. name: string,
  115552. /**
  115553. * Defines the location of the file to load
  115554. */
  115555. url: string,
  115556. /**
  115557. * Defines the desired size (the more it increases the longer the generation will be)
  115558. */
  115559. size: number,
  115560. /**
  115561. * Defines if mipmaps should not be generated (default is false)
  115562. */
  115563. noMipmap?: boolean,
  115564. /**
  115565. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  115566. * but the standard material would require them in Gamma space) (default is true)
  115567. */
  115568. gammaSpace?: boolean);
  115569. /**
  115570. * Execute the current task
  115571. * @param scene defines the scene where you want your assets to be loaded
  115572. * @param onSuccess is a callback called when the task is successfully executed
  115573. * @param onError is a callback called if an error occurs
  115574. */
  115575. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  115576. }
  115577. /**
  115578. * This class can be used to easily import assets into a scene
  115579. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  115580. */
  115581. export class AssetsManager {
  115582. private _scene;
  115583. private _isLoading;
  115584. protected _tasks: AbstractAssetTask[];
  115585. protected _waitingTasksCount: number;
  115586. protected _totalTasksCount: number;
  115587. /**
  115588. * Callback called when all tasks are processed
  115589. */
  115590. onFinish: (tasks: AbstractAssetTask[]) => void;
  115591. /**
  115592. * Callback called when a task is successful
  115593. */
  115594. onTaskSuccess: (task: AbstractAssetTask) => void;
  115595. /**
  115596. * Callback called when a task had an error
  115597. */
  115598. onTaskError: (task: AbstractAssetTask) => void;
  115599. /**
  115600. * Callback called when a task is done (whatever the result is)
  115601. */
  115602. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  115603. /**
  115604. * Observable called when all tasks are processed
  115605. */
  115606. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  115607. /**
  115608. * Observable called when a task had an error
  115609. */
  115610. onTaskErrorObservable: Observable<AbstractAssetTask>;
  115611. /**
  115612. * Observable called when all tasks were executed
  115613. */
  115614. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  115615. /**
  115616. * Observable called when a task is done (whatever the result is)
  115617. */
  115618. onProgressObservable: Observable<IAssetsProgressEvent>;
  115619. /**
  115620. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  115621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115622. */
  115623. useDefaultLoadingScreen: boolean;
  115624. /**
  115625. * Creates a new AssetsManager
  115626. * @param scene defines the scene to work on
  115627. */
  115628. constructor(scene: Scene);
  115629. /**
  115630. * Add a MeshAssetTask to the list of active tasks
  115631. * @param taskName defines the name of the new task
  115632. * @param meshesNames defines the name of meshes to load
  115633. * @param rootUrl defines the root url to use to locate files
  115634. * @param sceneFilename defines the filename of the scene file
  115635. * @returns a new MeshAssetTask object
  115636. */
  115637. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  115638. /**
  115639. * Add a TextFileAssetTask to the list of active tasks
  115640. * @param taskName defines the name of the new task
  115641. * @param url defines the url of the file to load
  115642. * @returns a new TextFileAssetTask object
  115643. */
  115644. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  115645. /**
  115646. * Add a BinaryFileAssetTask to the list of active tasks
  115647. * @param taskName defines the name of the new task
  115648. * @param url defines the url of the file to load
  115649. * @returns a new BinaryFileAssetTask object
  115650. */
  115651. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  115652. /**
  115653. * Add a ImageAssetTask to the list of active tasks
  115654. * @param taskName defines the name of the new task
  115655. * @param url defines the url of the file to load
  115656. * @returns a new ImageAssetTask object
  115657. */
  115658. addImageTask(taskName: string, url: string): ImageAssetTask;
  115659. /**
  115660. * Add a TextureAssetTask to the list of active tasks
  115661. * @param taskName defines the name of the new task
  115662. * @param url defines the url of the file to load
  115663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115664. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  115665. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115666. * @returns a new TextureAssetTask object
  115667. */
  115668. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  115669. /**
  115670. * Add a CubeTextureAssetTask to the list of active tasks
  115671. * @param taskName defines the name of the new task
  115672. * @param url defines the url of the file to load
  115673. * @param extensions defines the extension to use to load the cube map (can be null)
  115674. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115675. * @param files defines the list of files to load (can be null)
  115676. * @returns a new CubeTextureAssetTask object
  115677. */
  115678. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  115679. /**
  115680. *
  115681. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115682. * @param taskName defines the name of the new task
  115683. * @param url defines the url of the file to load
  115684. * @param size defines the size you want for the cubemap (can be null)
  115685. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115686. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115687. * @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)
  115688. * @param reserved Internal use only
  115689. * @returns a new HDRCubeTextureAssetTask object
  115690. */
  115691. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115692. /**
  115693. *
  115694. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115695. * @param taskName defines the name of the new task
  115696. * @param url defines the url of the file to load
  115697. * @param size defines the size you want for the cubemap (can be null)
  115698. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115699. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115700. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115701. * @returns a new EquiRectangularCubeTextureAssetTask object
  115702. */
  115703. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115704. /**
  115705. * Remove a task from the assets manager.
  115706. * @param task the task to remove
  115707. */
  115708. removeTask(task: AbstractAssetTask): void;
  115709. private _decreaseWaitingTasksCount;
  115710. private _runTask;
  115711. /**
  115712. * Reset the AssetsManager and remove all tasks
  115713. * @return the current instance of the AssetsManager
  115714. */
  115715. reset(): AssetsManager;
  115716. /**
  115717. * Start the loading process
  115718. * @return the current instance of the AssetsManager
  115719. */
  115720. load(): AssetsManager;
  115721. /**
  115722. * Start the loading process as an async operation
  115723. * @return a promise returning the list of failed tasks
  115724. */
  115725. loadAsync(): Promise<void>;
  115726. }
  115727. }
  115728. declare module BABYLON {
  115729. /**
  115730. * Wrapper class for promise with external resolve and reject.
  115731. */
  115732. export class Deferred<T> {
  115733. /**
  115734. * The promise associated with this deferred object.
  115735. */
  115736. readonly promise: Promise<T>;
  115737. private _resolve;
  115738. private _reject;
  115739. /**
  115740. * The resolve method of the promise associated with this deferred object.
  115741. */
  115742. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115743. /**
  115744. * The reject method of the promise associated with this deferred object.
  115745. */
  115746. readonly reject: (reason?: any) => void;
  115747. /**
  115748. * Constructor for this deferred object.
  115749. */
  115750. constructor();
  115751. }
  115752. }
  115753. declare module BABYLON {
  115754. /**
  115755. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115756. */
  115757. export class MeshExploder {
  115758. private _centerMesh;
  115759. private _meshes;
  115760. private _meshesOrigins;
  115761. private _toCenterVectors;
  115762. private _scaledDirection;
  115763. private _newPosition;
  115764. private _centerPosition;
  115765. /**
  115766. * Explodes meshes from a center mesh.
  115767. * @param meshes The meshes to explode.
  115768. * @param centerMesh The mesh to be center of explosion.
  115769. */
  115770. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115771. private _setCenterMesh;
  115772. /**
  115773. * Get class name
  115774. * @returns "MeshExploder"
  115775. */
  115776. getClassName(): string;
  115777. /**
  115778. * "Exploded meshes"
  115779. * @returns Array of meshes with the centerMesh at index 0.
  115780. */
  115781. getMeshes(): Array<Mesh>;
  115782. /**
  115783. * Explodes meshes giving a specific direction
  115784. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115785. */
  115786. explode(direction?: number): void;
  115787. }
  115788. }
  115789. declare module BABYLON {
  115790. /**
  115791. * Class used to help managing file picking and drag'n'drop
  115792. */
  115793. export class FilesInput {
  115794. /**
  115795. * List of files ready to be loaded
  115796. */
  115797. static readonly FilesToLoad: {
  115798. [key: string]: File;
  115799. };
  115800. /**
  115801. * Callback called when a file is processed
  115802. */
  115803. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115804. private _engine;
  115805. private _currentScene;
  115806. private _sceneLoadedCallback;
  115807. private _progressCallback;
  115808. private _additionalRenderLoopLogicCallback;
  115809. private _textureLoadingCallback;
  115810. private _startingProcessingFilesCallback;
  115811. private _onReloadCallback;
  115812. private _errorCallback;
  115813. private _elementToMonitor;
  115814. private _sceneFileToLoad;
  115815. private _filesToLoad;
  115816. /**
  115817. * Creates a new FilesInput
  115818. * @param engine defines the rendering engine
  115819. * @param scene defines the hosting scene
  115820. * @param sceneLoadedCallback callback called when scene is loaded
  115821. * @param progressCallback callback called to track progress
  115822. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115823. * @param textureLoadingCallback callback called when a texture is loading
  115824. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115825. * @param onReloadCallback callback called when a reload is requested
  115826. * @param errorCallback callback call if an error occurs
  115827. */
  115828. 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);
  115829. private _dragEnterHandler;
  115830. private _dragOverHandler;
  115831. private _dropHandler;
  115832. /**
  115833. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115834. * @param elementToMonitor defines the DOM element to track
  115835. */
  115836. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115837. /**
  115838. * Release all associated resources
  115839. */
  115840. dispose(): void;
  115841. private renderFunction;
  115842. private drag;
  115843. private drop;
  115844. private _traverseFolder;
  115845. private _processFiles;
  115846. /**
  115847. * Load files from a drop event
  115848. * @param event defines the drop event to use as source
  115849. */
  115850. loadFiles(event: any): void;
  115851. private _processReload;
  115852. /**
  115853. * Reload the current scene from the loaded files
  115854. */
  115855. reload(): void;
  115856. }
  115857. }
  115858. declare module BABYLON {
  115859. /**
  115860. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115862. */
  115863. export class SceneOptimization {
  115864. /**
  115865. * Defines the priority of this optimization (0 by default which means first in the list)
  115866. */
  115867. priority: number;
  115868. /**
  115869. * Gets a string describing the action executed by the current optimization
  115870. * @returns description string
  115871. */
  115872. getDescription(): string;
  115873. /**
  115874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115875. * @param scene defines the current scene where to apply this optimization
  115876. * @param optimizer defines the current optimizer
  115877. * @returns true if everything that can be done was applied
  115878. */
  115879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115880. /**
  115881. * Creates the SceneOptimization object
  115882. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115883. * @param desc defines the description associated with the optimization
  115884. */
  115885. constructor(
  115886. /**
  115887. * Defines the priority of this optimization (0 by default which means first in the list)
  115888. */
  115889. priority?: number);
  115890. }
  115891. /**
  115892. * Defines an optimization used to reduce the size of render target textures
  115893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115894. */
  115895. export class TextureOptimization extends SceneOptimization {
  115896. /**
  115897. * Defines the priority of this optimization (0 by default which means first in the list)
  115898. */
  115899. priority: number;
  115900. /**
  115901. * 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
  115902. */
  115903. maximumSize: number;
  115904. /**
  115905. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115906. */
  115907. step: number;
  115908. /**
  115909. * Gets a string describing the action executed by the current optimization
  115910. * @returns description string
  115911. */
  115912. getDescription(): string;
  115913. /**
  115914. * Creates the TextureOptimization object
  115915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115916. * @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
  115917. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115918. */
  115919. constructor(
  115920. /**
  115921. * Defines the priority of this optimization (0 by default which means first in the list)
  115922. */
  115923. priority?: number,
  115924. /**
  115925. * 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
  115926. */
  115927. maximumSize?: number,
  115928. /**
  115929. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115930. */
  115931. step?: number);
  115932. /**
  115933. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115934. * @param scene defines the current scene where to apply this optimization
  115935. * @param optimizer defines the current optimizer
  115936. * @returns true if everything that can be done was applied
  115937. */
  115938. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115939. }
  115940. /**
  115941. * Defines an optimization used to increase or decrease the rendering resolution
  115942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115943. */
  115944. export class HardwareScalingOptimization extends SceneOptimization {
  115945. /**
  115946. * Defines the priority of this optimization (0 by default which means first in the list)
  115947. */
  115948. priority: number;
  115949. /**
  115950. * Defines the maximum scale to use (2 by default)
  115951. */
  115952. maximumScale: number;
  115953. /**
  115954. * Defines the step to use between two passes (0.5 by default)
  115955. */
  115956. step: number;
  115957. private _currentScale;
  115958. private _directionOffset;
  115959. /**
  115960. * Gets a string describing the action executed by the current optimization
  115961. * @return description string
  115962. */
  115963. getDescription(): string;
  115964. /**
  115965. * Creates the HardwareScalingOptimization object
  115966. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115967. * @param maximumScale defines the maximum scale to use (2 by default)
  115968. * @param step defines the step to use between two passes (0.5 by default)
  115969. */
  115970. constructor(
  115971. /**
  115972. * Defines the priority of this optimization (0 by default which means first in the list)
  115973. */
  115974. priority?: number,
  115975. /**
  115976. * Defines the maximum scale to use (2 by default)
  115977. */
  115978. maximumScale?: number,
  115979. /**
  115980. * Defines the step to use between two passes (0.5 by default)
  115981. */
  115982. step?: number);
  115983. /**
  115984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115985. * @param scene defines the current scene where to apply this optimization
  115986. * @param optimizer defines the current optimizer
  115987. * @returns true if everything that can be done was applied
  115988. */
  115989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115990. }
  115991. /**
  115992. * Defines an optimization used to remove shadows
  115993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115994. */
  115995. export class ShadowsOptimization extends SceneOptimization {
  115996. /**
  115997. * Gets a string describing the action executed by the current optimization
  115998. * @return description string
  115999. */
  116000. getDescription(): string;
  116001. /**
  116002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116003. * @param scene defines the current scene where to apply this optimization
  116004. * @param optimizer defines the current optimizer
  116005. * @returns true if everything that can be done was applied
  116006. */
  116007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116008. }
  116009. /**
  116010. * Defines an optimization used to turn post-processes off
  116011. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116012. */
  116013. export class PostProcessesOptimization extends SceneOptimization {
  116014. /**
  116015. * Gets a string describing the action executed by the current optimization
  116016. * @return description string
  116017. */
  116018. getDescription(): string;
  116019. /**
  116020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116021. * @param scene defines the current scene where to apply this optimization
  116022. * @param optimizer defines the current optimizer
  116023. * @returns true if everything that can be done was applied
  116024. */
  116025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116026. }
  116027. /**
  116028. * Defines an optimization used to turn lens flares off
  116029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116030. */
  116031. export class LensFlaresOptimization extends SceneOptimization {
  116032. /**
  116033. * Gets a string describing the action executed by the current optimization
  116034. * @return description string
  116035. */
  116036. getDescription(): string;
  116037. /**
  116038. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116039. * @param scene defines the current scene where to apply this optimization
  116040. * @param optimizer defines the current optimizer
  116041. * @returns true if everything that can be done was applied
  116042. */
  116043. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116044. }
  116045. /**
  116046. * Defines an optimization based on user defined callback.
  116047. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116048. */
  116049. export class CustomOptimization extends SceneOptimization {
  116050. /**
  116051. * Callback called to apply the custom optimization.
  116052. */
  116053. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  116054. /**
  116055. * Callback called to get custom description
  116056. */
  116057. onGetDescription: () => string;
  116058. /**
  116059. * Gets a string describing the action executed by the current optimization
  116060. * @returns description string
  116061. */
  116062. getDescription(): string;
  116063. /**
  116064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116065. * @param scene defines the current scene where to apply this optimization
  116066. * @param optimizer defines the current optimizer
  116067. * @returns true if everything that can be done was applied
  116068. */
  116069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116070. }
  116071. /**
  116072. * Defines an optimization used to turn particles off
  116073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116074. */
  116075. export class ParticlesOptimization extends SceneOptimization {
  116076. /**
  116077. * Gets a string describing the action executed by the current optimization
  116078. * @return description string
  116079. */
  116080. getDescription(): string;
  116081. /**
  116082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116083. * @param scene defines the current scene where to apply this optimization
  116084. * @param optimizer defines the current optimizer
  116085. * @returns true if everything that can be done was applied
  116086. */
  116087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116088. }
  116089. /**
  116090. * Defines an optimization used to turn render targets off
  116091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116092. */
  116093. export class RenderTargetsOptimization extends SceneOptimization {
  116094. /**
  116095. * Gets a string describing the action executed by the current optimization
  116096. * @return description string
  116097. */
  116098. getDescription(): string;
  116099. /**
  116100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116101. * @param scene defines the current scene where to apply this optimization
  116102. * @param optimizer defines the current optimizer
  116103. * @returns true if everything that can be done was applied
  116104. */
  116105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  116106. }
  116107. /**
  116108. * Defines an optimization used to merge meshes with compatible materials
  116109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116110. */
  116111. export class MergeMeshesOptimization extends SceneOptimization {
  116112. private static _UpdateSelectionTree;
  116113. /**
  116114. * Gets or sets a boolean which defines if optimization octree has to be updated
  116115. */
  116116. /**
  116117. * Gets or sets a boolean which defines if optimization octree has to be updated
  116118. */
  116119. static UpdateSelectionTree: boolean;
  116120. /**
  116121. * Gets a string describing the action executed by the current optimization
  116122. * @return description string
  116123. */
  116124. getDescription(): string;
  116125. private _canBeMerged;
  116126. /**
  116127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  116128. * @param scene defines the current scene where to apply this optimization
  116129. * @param optimizer defines the current optimizer
  116130. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  116131. * @returns true if everything that can be done was applied
  116132. */
  116133. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  116134. }
  116135. /**
  116136. * Defines a list of options used by SceneOptimizer
  116137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116138. */
  116139. export class SceneOptimizerOptions {
  116140. /**
  116141. * Defines the target frame rate to reach (60 by default)
  116142. */
  116143. targetFrameRate: number;
  116144. /**
  116145. * Defines the interval between two checkes (2000ms by default)
  116146. */
  116147. trackerDuration: number;
  116148. /**
  116149. * Gets the list of optimizations to apply
  116150. */
  116151. optimizations: SceneOptimization[];
  116152. /**
  116153. * Creates a new list of options used by SceneOptimizer
  116154. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  116155. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  116156. */
  116157. constructor(
  116158. /**
  116159. * Defines the target frame rate to reach (60 by default)
  116160. */
  116161. targetFrameRate?: number,
  116162. /**
  116163. * Defines the interval between two checkes (2000ms by default)
  116164. */
  116165. trackerDuration?: number);
  116166. /**
  116167. * Add a new optimization
  116168. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  116169. * @returns the current SceneOptimizerOptions
  116170. */
  116171. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  116172. /**
  116173. * Add a new custom optimization
  116174. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  116175. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  116176. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  116177. * @returns the current SceneOptimizerOptions
  116178. */
  116179. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  116180. /**
  116181. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  116182. * @param targetFrameRate defines the target frame rate (60 by default)
  116183. * @returns a SceneOptimizerOptions object
  116184. */
  116185. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116186. /**
  116187. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  116188. * @param targetFrameRate defines the target frame rate (60 by default)
  116189. * @returns a SceneOptimizerOptions object
  116190. */
  116191. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116192. /**
  116193. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  116194. * @param targetFrameRate defines the target frame rate (60 by default)
  116195. * @returns a SceneOptimizerOptions object
  116196. */
  116197. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  116198. }
  116199. /**
  116200. * Class used to run optimizations in order to reach a target frame rate
  116201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  116202. */
  116203. export class SceneOptimizer implements IDisposable {
  116204. private _isRunning;
  116205. private _options;
  116206. private _scene;
  116207. private _currentPriorityLevel;
  116208. private _targetFrameRate;
  116209. private _trackerDuration;
  116210. private _currentFrameRate;
  116211. private _sceneDisposeObserver;
  116212. private _improvementMode;
  116213. /**
  116214. * Defines an observable called when the optimizer reaches the target frame rate
  116215. */
  116216. onSuccessObservable: Observable<SceneOptimizer>;
  116217. /**
  116218. * Defines an observable called when the optimizer enables an optimization
  116219. */
  116220. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  116221. /**
  116222. * Defines an observable called when the optimizer is not able to reach the target frame rate
  116223. */
  116224. onFailureObservable: Observable<SceneOptimizer>;
  116225. /**
  116226. * Gets a boolean indicating if the optimizer is in improvement mode
  116227. */
  116228. readonly isInImprovementMode: boolean;
  116229. /**
  116230. * Gets the current priority level (0 at start)
  116231. */
  116232. readonly currentPriorityLevel: number;
  116233. /**
  116234. * Gets the current frame rate checked by the SceneOptimizer
  116235. */
  116236. readonly currentFrameRate: number;
  116237. /**
  116238. * Gets or sets the current target frame rate (60 by default)
  116239. */
  116240. /**
  116241. * Gets or sets the current target frame rate (60 by default)
  116242. */
  116243. targetFrameRate: number;
  116244. /**
  116245. * Gets or sets the current interval between two checks (every 2000ms by default)
  116246. */
  116247. /**
  116248. * Gets or sets the current interval between two checks (every 2000ms by default)
  116249. */
  116250. trackerDuration: number;
  116251. /**
  116252. * Gets the list of active optimizations
  116253. */
  116254. readonly optimizations: SceneOptimization[];
  116255. /**
  116256. * Creates a new SceneOptimizer
  116257. * @param scene defines the scene to work on
  116258. * @param options defines the options to use with the SceneOptimizer
  116259. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  116260. * @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)
  116261. */
  116262. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  116263. /**
  116264. * Stops the current optimizer
  116265. */
  116266. stop(): void;
  116267. /**
  116268. * Reset the optimizer to initial step (current priority level = 0)
  116269. */
  116270. reset(): void;
  116271. /**
  116272. * Start the optimizer. By default it will try to reach a specific framerate
  116273. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  116274. */
  116275. start(): void;
  116276. private _checkCurrentState;
  116277. /**
  116278. * Release all resources
  116279. */
  116280. dispose(): void;
  116281. /**
  116282. * Helper function to create a SceneOptimizer with one single line of code
  116283. * @param scene defines the scene to work on
  116284. * @param options defines the options to use with the SceneOptimizer
  116285. * @param onSuccess defines a callback to call on success
  116286. * @param onFailure defines a callback to call on failure
  116287. * @returns the new SceneOptimizer object
  116288. */
  116289. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  116290. }
  116291. }
  116292. declare module BABYLON {
  116293. /**
  116294. * Class used to serialize a scene into a string
  116295. */
  116296. export class SceneSerializer {
  116297. /**
  116298. * Clear cache used by a previous serialization
  116299. */
  116300. static ClearCache(): void;
  116301. /**
  116302. * Serialize a scene into a JSON compatible object
  116303. * @param scene defines the scene to serialize
  116304. * @returns a JSON compatible object
  116305. */
  116306. static Serialize(scene: Scene): any;
  116307. /**
  116308. * Serialize a mesh into a JSON compatible object
  116309. * @param toSerialize defines the mesh to serialize
  116310. * @param withParents defines if parents must be serialized as well
  116311. * @param withChildren defines if children must be serialized as well
  116312. * @returns a JSON compatible object
  116313. */
  116314. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  116315. }
  116316. }
  116317. declare module BABYLON {
  116318. /**
  116319. * Class used to host texture specific utilities
  116320. */
  116321. export class TextureTools {
  116322. /**
  116323. * Uses the GPU to create a copy texture rescaled at a given size
  116324. * @param texture Texture to copy from
  116325. * @param width defines the desired width
  116326. * @param height defines the desired height
  116327. * @param useBilinearMode defines if bilinear mode has to be used
  116328. * @return the generated texture
  116329. */
  116330. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  116331. }
  116332. }
  116333. declare module BABYLON {
  116334. /**
  116335. * This represents the different options avilable for the video capture.
  116336. */
  116337. export interface VideoRecorderOptions {
  116338. /** Defines the mime type of the video */
  116339. mimeType: string;
  116340. /** Defines the video the video should be recorded at */
  116341. fps: number;
  116342. /** Defines the chunk size for the recording data */
  116343. recordChunckSize: number;
  116344. /** The audio tracks to attach to the record */
  116345. audioTracks?: MediaStreamTrack[];
  116346. }
  116347. /**
  116348. * This can helps recording videos from BabylonJS.
  116349. * This is based on the available WebRTC functionalities of the browser.
  116350. *
  116351. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  116352. */
  116353. export class VideoRecorder {
  116354. private static readonly _defaultOptions;
  116355. /**
  116356. * Returns wehther or not the VideoRecorder is available in your browser.
  116357. * @param engine Defines the Babylon Engine to check the support for
  116358. * @returns true if supported otherwise false
  116359. */
  116360. static IsSupported(engine: Engine): boolean;
  116361. private readonly _options;
  116362. private _canvas;
  116363. private _mediaRecorder;
  116364. private _recordedChunks;
  116365. private _fileName;
  116366. private _resolve;
  116367. private _reject;
  116368. /**
  116369. * True wether a recording is already in progress.
  116370. */
  116371. readonly isRecording: boolean;
  116372. /**
  116373. * Create a new VideoCapture object which can help converting what you see in Babylon to
  116374. * a video file.
  116375. * @param engine Defines the BabylonJS Engine you wish to record
  116376. * @param options Defines options that can be used to customized the capture
  116377. */
  116378. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  116379. /**
  116380. * Stops the current recording before the default capture timeout passed in the startRecording
  116381. * functions.
  116382. */
  116383. stopRecording(): void;
  116384. /**
  116385. * Starts recording the canvas for a max duration specified in parameters.
  116386. * @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.
  116387. * @param maxDuration Defines the maximum recording time in seconds.
  116388. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  116389. * @return a promise callback at the end of the recording with the video data in Blob.
  116390. */
  116391. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  116392. /**
  116393. * Releases internal resources used during the recording.
  116394. */
  116395. dispose(): void;
  116396. private _handleDataAvailable;
  116397. private _handleError;
  116398. private _handleStop;
  116399. }
  116400. }
  116401. declare module BABYLON {
  116402. /**
  116403. * Class containing a set of static utilities functions for screenshots
  116404. */
  116405. export class ScreenshotTools {
  116406. /**
  116407. * Captures a screenshot of the current rendering
  116408. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116409. * @param engine defines the rendering engine
  116410. * @param camera defines the source camera
  116411. * @param size This parameter can be set to a single number or to an object with the
  116412. * following (optional) properties: precision, width, height. If a single number is passed,
  116413. * it will be used for both width and height. If an object is passed, the screenshot size
  116414. * will be derived from the parameters. The precision property is a multiplier allowing
  116415. * rendering at a higher or lower resolution
  116416. * @param successCallback defines the callback receives a single parameter which contains the
  116417. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116418. * src parameter of an <img> to display it
  116419. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116420. * Check your browser for supported MIME types
  116421. */
  116422. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  116423. /**
  116424. * Generates an image screenshot from the specified camera.
  116425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  116426. * @param engine The engine to use for rendering
  116427. * @param camera The camera to use for rendering
  116428. * @param size This parameter can be set to a single number or to an object with the
  116429. * following (optional) properties: precision, width, height. If a single number is passed,
  116430. * it will be used for both width and height. If an object is passed, the screenshot size
  116431. * will be derived from the parameters. The precision property is a multiplier allowing
  116432. * rendering at a higher or lower resolution
  116433. * @param successCallback The callback receives a single parameter which contains the
  116434. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116435. * src parameter of an <img> to display it
  116436. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116437. * Check your browser for supported MIME types
  116438. * @param samples Texture samples (default: 1)
  116439. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116440. * @param fileName A name for for the downloaded file.
  116441. */
  116442. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116443. }
  116444. }
  116445. declare module BABYLON {
  116446. /**
  116447. * A cursor which tracks a point on a path
  116448. */
  116449. export class PathCursor {
  116450. private path;
  116451. /**
  116452. * Stores path cursor callbacks for when an onchange event is triggered
  116453. */
  116454. private _onchange;
  116455. /**
  116456. * The value of the path cursor
  116457. */
  116458. value: number;
  116459. /**
  116460. * The animation array of the path cursor
  116461. */
  116462. animations: Animation[];
  116463. /**
  116464. * Initializes the path cursor
  116465. * @param path The path to track
  116466. */
  116467. constructor(path: Path2);
  116468. /**
  116469. * Gets the cursor point on the path
  116470. * @returns A point on the path cursor at the cursor location
  116471. */
  116472. getPoint(): Vector3;
  116473. /**
  116474. * Moves the cursor ahead by the step amount
  116475. * @param step The amount to move the cursor forward
  116476. * @returns This path cursor
  116477. */
  116478. moveAhead(step?: number): PathCursor;
  116479. /**
  116480. * Moves the cursor behind by the step amount
  116481. * @param step The amount to move the cursor back
  116482. * @returns This path cursor
  116483. */
  116484. moveBack(step?: number): PathCursor;
  116485. /**
  116486. * Moves the cursor by the step amount
  116487. * If the step amount is greater than one, an exception is thrown
  116488. * @param step The amount to move the cursor
  116489. * @returns This path cursor
  116490. */
  116491. move(step: number): PathCursor;
  116492. /**
  116493. * Ensures that the value is limited between zero and one
  116494. * @returns This path cursor
  116495. */
  116496. private ensureLimits;
  116497. /**
  116498. * Runs onchange callbacks on change (used by the animation engine)
  116499. * @returns This path cursor
  116500. */
  116501. private raiseOnChange;
  116502. /**
  116503. * Executes a function on change
  116504. * @param f A path cursor onchange callback
  116505. * @returns This path cursor
  116506. */
  116507. onchange(f: (cursor: PathCursor) => void): PathCursor;
  116508. }
  116509. }
  116510. declare module BABYLON {
  116511. /** @hidden */
  116512. export var blurPixelShader: {
  116513. name: string;
  116514. shader: string;
  116515. };
  116516. }
  116517. declare module BABYLON {
  116518. /** @hidden */
  116519. export var bones300Declaration: {
  116520. name: string;
  116521. shader: string;
  116522. };
  116523. }
  116524. declare module BABYLON {
  116525. /** @hidden */
  116526. export var instances300Declaration: {
  116527. name: string;
  116528. shader: string;
  116529. };
  116530. }
  116531. declare module BABYLON {
  116532. /** @hidden */
  116533. export var pointCloudVertexDeclaration: {
  116534. name: string;
  116535. shader: string;
  116536. };
  116537. }
  116538. // Mixins
  116539. interface Window {
  116540. mozIndexedDB: IDBFactory;
  116541. webkitIndexedDB: IDBFactory;
  116542. msIndexedDB: IDBFactory;
  116543. webkitURL: typeof URL;
  116544. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  116545. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  116546. WebGLRenderingContext: WebGLRenderingContext;
  116547. MSGesture: MSGesture;
  116548. CANNON: any;
  116549. AudioContext: AudioContext;
  116550. webkitAudioContext: AudioContext;
  116551. PointerEvent: any;
  116552. Math: Math;
  116553. Uint8Array: Uint8ArrayConstructor;
  116554. Float32Array: Float32ArrayConstructor;
  116555. mozURL: typeof URL;
  116556. msURL: typeof URL;
  116557. VRFrameData: any; // WebVR, from specs 1.1
  116558. DracoDecoderModule: any;
  116559. setImmediate(handler: (...args: any[]) => void): number;
  116560. }
  116561. interface HTMLCanvasElement {
  116562. requestPointerLock(): void;
  116563. msRequestPointerLock?(): void;
  116564. mozRequestPointerLock?(): void;
  116565. webkitRequestPointerLock?(): void;
  116566. /** Track wether a record is in progress */
  116567. isRecording: boolean;
  116568. /** Capture Stream method defined by some browsers */
  116569. captureStream(fps?: number): MediaStream;
  116570. }
  116571. interface CanvasRenderingContext2D {
  116572. msImageSmoothingEnabled: boolean;
  116573. }
  116574. interface MouseEvent {
  116575. mozMovementX: number;
  116576. mozMovementY: number;
  116577. webkitMovementX: number;
  116578. webkitMovementY: number;
  116579. msMovementX: number;
  116580. msMovementY: number;
  116581. }
  116582. interface Navigator {
  116583. mozGetVRDevices: (any: any) => any;
  116584. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116585. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116586. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  116587. webkitGetGamepads(): Gamepad[];
  116588. msGetGamepads(): Gamepad[];
  116589. webkitGamepads(): Gamepad[];
  116590. }
  116591. interface HTMLVideoElement {
  116592. mozSrcObject: any;
  116593. }
  116594. interface Math {
  116595. fround(x: number): number;
  116596. imul(a: number, b: number): number;
  116597. }
  116598. interface WebGLRenderingContext {
  116599. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  116600. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  116601. vertexAttribDivisor(index: number, divisor: number): void;
  116602. createVertexArray(): any;
  116603. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  116604. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  116605. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  116606. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  116607. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  116608. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  116609. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  116610. // Queries
  116611. createQuery(): WebGLQuery;
  116612. deleteQuery(query: WebGLQuery): void;
  116613. beginQuery(target: number, query: WebGLQuery): void;
  116614. endQuery(target: number): void;
  116615. getQueryParameter(query: WebGLQuery, pname: number): any;
  116616. getQuery(target: number, pname: number): any;
  116617. MAX_SAMPLES: number;
  116618. RGBA8: number;
  116619. READ_FRAMEBUFFER: number;
  116620. DRAW_FRAMEBUFFER: number;
  116621. UNIFORM_BUFFER: number;
  116622. HALF_FLOAT_OES: number;
  116623. RGBA16F: number;
  116624. RGBA32F: number;
  116625. R32F: number;
  116626. RG32F: number;
  116627. RGB32F: number;
  116628. R16F: number;
  116629. RG16F: number;
  116630. RGB16F: number;
  116631. RED: number;
  116632. RG: number;
  116633. R8: number;
  116634. RG8: number;
  116635. UNSIGNED_INT_24_8: number;
  116636. DEPTH24_STENCIL8: number;
  116637. /* Multiple Render Targets */
  116638. drawBuffers(buffers: number[]): void;
  116639. readBuffer(src: number): void;
  116640. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  116641. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  116642. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  116643. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  116644. // Occlusion Query
  116645. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  116646. ANY_SAMPLES_PASSED: number;
  116647. QUERY_RESULT_AVAILABLE: number;
  116648. QUERY_RESULT: number;
  116649. }
  116650. interface WebGLProgram {
  116651. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  116652. }
  116653. interface EXT_disjoint_timer_query {
  116654. QUERY_COUNTER_BITS_EXT: number;
  116655. TIME_ELAPSED_EXT: number;
  116656. TIMESTAMP_EXT: number;
  116657. GPU_DISJOINT_EXT: number;
  116658. QUERY_RESULT_EXT: number;
  116659. QUERY_RESULT_AVAILABLE_EXT: number;
  116660. queryCounterEXT(query: WebGLQuery, target: number): void;
  116661. createQueryEXT(): WebGLQuery;
  116662. beginQueryEXT(target: number, query: WebGLQuery): void;
  116663. endQueryEXT(target: number): void;
  116664. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  116665. deleteQueryEXT(query: WebGLQuery): void;
  116666. }
  116667. interface WebGLUniformLocation {
  116668. _currentState: any;
  116669. }
  116670. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116671. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116672. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116673. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116674. interface WebGLRenderingContext {
  116675. readonly RASTERIZER_DISCARD: number;
  116676. readonly DEPTH_COMPONENT24: number;
  116677. readonly TEXTURE_3D: number;
  116678. readonly TEXTURE_2D_ARRAY: number;
  116679. readonly TEXTURE_COMPARE_FUNC: number;
  116680. readonly TEXTURE_COMPARE_MODE: number;
  116681. readonly COMPARE_REF_TO_TEXTURE: number;
  116682. readonly TEXTURE_WRAP_R: number;
  116683. readonly HALF_FLOAT: number;
  116684. readonly RGB8: number;
  116685. readonly RED_INTEGER: number;
  116686. readonly RG_INTEGER: number;
  116687. readonly RGB_INTEGER: number;
  116688. readonly RGBA_INTEGER: number;
  116689. readonly R8_SNORM: number;
  116690. readonly RG8_SNORM: number;
  116691. readonly RGB8_SNORM: number;
  116692. readonly RGBA8_SNORM: number;
  116693. readonly R8I: number;
  116694. readonly RG8I: number;
  116695. readonly RGB8I: number;
  116696. readonly RGBA8I: number;
  116697. readonly R8UI: number;
  116698. readonly RG8UI: number;
  116699. readonly RGB8UI: number;
  116700. readonly RGBA8UI: number;
  116701. readonly R16I: number;
  116702. readonly RG16I: number;
  116703. readonly RGB16I: number;
  116704. readonly RGBA16I: number;
  116705. readonly R16UI: number;
  116706. readonly RG16UI: number;
  116707. readonly RGB16UI: number;
  116708. readonly RGBA16UI: number;
  116709. readonly R32I: number;
  116710. readonly RG32I: number;
  116711. readonly RGB32I: number;
  116712. readonly RGBA32I: number;
  116713. readonly R32UI: number;
  116714. readonly RG32UI: number;
  116715. readonly RGB32UI: number;
  116716. readonly RGBA32UI: number;
  116717. readonly RGB10_A2UI: number;
  116718. readonly R11F_G11F_B10F: number;
  116719. readonly RGB9_E5: number;
  116720. readonly RGB10_A2: number;
  116721. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116722. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116723. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116724. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116725. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116726. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116727. 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;
  116728. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116729. readonly TRANSFORM_FEEDBACK: number;
  116730. readonly INTERLEAVED_ATTRIBS: number;
  116731. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116732. createTransformFeedback(): WebGLTransformFeedback;
  116733. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116734. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116735. beginTransformFeedback(primitiveMode: number): void;
  116736. endTransformFeedback(): void;
  116737. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116738. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116739. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116740. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116741. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116742. }
  116743. interface ImageBitmap {
  116744. readonly width: number;
  116745. readonly height: number;
  116746. close(): void;
  116747. }
  116748. interface WebGLQuery extends WebGLObject {
  116749. }
  116750. declare var WebGLQuery: {
  116751. prototype: WebGLQuery;
  116752. new(): WebGLQuery;
  116753. };
  116754. interface WebGLSampler extends WebGLObject {
  116755. }
  116756. declare var WebGLSampler: {
  116757. prototype: WebGLSampler;
  116758. new(): WebGLSampler;
  116759. };
  116760. interface WebGLSync extends WebGLObject {
  116761. }
  116762. declare var WebGLSync: {
  116763. prototype: WebGLSync;
  116764. new(): WebGLSync;
  116765. };
  116766. interface WebGLTransformFeedback extends WebGLObject {
  116767. }
  116768. declare var WebGLTransformFeedback: {
  116769. prototype: WebGLTransformFeedback;
  116770. new(): WebGLTransformFeedback;
  116771. };
  116772. interface WebGLVertexArrayObject extends WebGLObject {
  116773. }
  116774. declare var WebGLVertexArrayObject: {
  116775. prototype: WebGLVertexArrayObject;
  116776. new(): WebGLVertexArrayObject;
  116777. };
  116778. // Type definitions for WebVR API
  116779. // Project: https://w3c.github.io/webvr/
  116780. // Definitions by: six a <https://github.com/lostfictions>
  116781. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116782. interface VRDisplay extends EventTarget {
  116783. /**
  116784. * Dictionary of capabilities describing the VRDisplay.
  116785. */
  116786. readonly capabilities: VRDisplayCapabilities;
  116787. /**
  116788. * z-depth defining the far plane of the eye view frustum
  116789. * enables mapping of values in the render target depth
  116790. * attachment to scene coordinates. Initially set to 10000.0.
  116791. */
  116792. depthFar: number;
  116793. /**
  116794. * z-depth defining the near plane of the eye view frustum
  116795. * enables mapping of values in the render target depth
  116796. * attachment to scene coordinates. Initially set to 0.01.
  116797. */
  116798. depthNear: number;
  116799. /**
  116800. * An identifier for this distinct VRDisplay. Used as an
  116801. * association point in the Gamepad API.
  116802. */
  116803. readonly displayId: number;
  116804. /**
  116805. * A display name, a user-readable name identifying it.
  116806. */
  116807. readonly displayName: string;
  116808. readonly isConnected: boolean;
  116809. readonly isPresenting: boolean;
  116810. /**
  116811. * If this VRDisplay supports room-scale experiences, the optional
  116812. * stage attribute contains details on the room-scale parameters.
  116813. */
  116814. readonly stageParameters: VRStageParameters | null;
  116815. /**
  116816. * Passing the value returned by `requestAnimationFrame` to
  116817. * `cancelAnimationFrame` will unregister the callback.
  116818. * @param handle Define the hanle of the request to cancel
  116819. */
  116820. cancelAnimationFrame(handle: number): void;
  116821. /**
  116822. * Stops presenting to the VRDisplay.
  116823. * @returns a promise to know when it stopped
  116824. */
  116825. exitPresent(): Promise<void>;
  116826. /**
  116827. * Return the current VREyeParameters for the given eye.
  116828. * @param whichEye Define the eye we want the parameter for
  116829. * @returns the eye parameters
  116830. */
  116831. getEyeParameters(whichEye: string): VREyeParameters;
  116832. /**
  116833. * Populates the passed VRFrameData with the information required to render
  116834. * the current frame.
  116835. * @param frameData Define the data structure to populate
  116836. * @returns true if ok otherwise false
  116837. */
  116838. getFrameData(frameData: VRFrameData): boolean;
  116839. /**
  116840. * Get the layers currently being presented.
  116841. * @returns the list of VR layers
  116842. */
  116843. getLayers(): VRLayer[];
  116844. /**
  116845. * Return a VRPose containing the future predicted pose of the VRDisplay
  116846. * when the current frame will be presented. The value returned will not
  116847. * change until JavaScript has returned control to the browser.
  116848. *
  116849. * The VRPose will contain the position, orientation, velocity,
  116850. * and acceleration of each of these properties.
  116851. * @returns the pose object
  116852. */
  116853. getPose(): VRPose;
  116854. /**
  116855. * Return the current instantaneous pose of the VRDisplay, with no
  116856. * prediction applied.
  116857. * @returns the current instantaneous pose
  116858. */
  116859. getImmediatePose(): VRPose;
  116860. /**
  116861. * The callback passed to `requestAnimationFrame` will be called
  116862. * any time a new frame should be rendered. When the VRDisplay is
  116863. * presenting the callback will be called at the native refresh
  116864. * rate of the HMD. When not presenting this function acts
  116865. * identically to how window.requestAnimationFrame acts. Content should
  116866. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116867. * asynchronously from other displays and at differing refresh rates.
  116868. * @param callback Define the eaction to run next frame
  116869. * @returns the request handle it
  116870. */
  116871. requestAnimationFrame(callback: FrameRequestCallback): number;
  116872. /**
  116873. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116874. * Repeat calls while already presenting will update the VRLayers being displayed.
  116875. * @param layers Define the list of layer to present
  116876. * @returns a promise to know when the request has been fulfilled
  116877. */
  116878. requestPresent(layers: VRLayer[]): Promise<void>;
  116879. /**
  116880. * Reset the pose for this display, treating its current position and
  116881. * orientation as the "origin/zero" values. VRPose.position,
  116882. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116883. * updated when calling resetPose(). This should be called in only
  116884. * sitting-space experiences.
  116885. */
  116886. resetPose(): void;
  116887. /**
  116888. * The VRLayer provided to the VRDisplay will be captured and presented
  116889. * in the HMD. Calling this function has the same effect on the source
  116890. * canvas as any other operation that uses its source image, and canvases
  116891. * created without preserveDrawingBuffer set to true will be cleared.
  116892. * @param pose Define the pose to submit
  116893. */
  116894. submitFrame(pose?: VRPose): void;
  116895. }
  116896. declare var VRDisplay: {
  116897. prototype: VRDisplay;
  116898. new(): VRDisplay;
  116899. };
  116900. interface VRLayer {
  116901. leftBounds?: number[] | Float32Array | null;
  116902. rightBounds?: number[] | Float32Array | null;
  116903. source?: HTMLCanvasElement | null;
  116904. }
  116905. interface VRDisplayCapabilities {
  116906. readonly canPresent: boolean;
  116907. readonly hasExternalDisplay: boolean;
  116908. readonly hasOrientation: boolean;
  116909. readonly hasPosition: boolean;
  116910. readonly maxLayers: number;
  116911. }
  116912. interface VREyeParameters {
  116913. /** @deprecated */
  116914. readonly fieldOfView: VRFieldOfView;
  116915. readonly offset: Float32Array;
  116916. readonly renderHeight: number;
  116917. readonly renderWidth: number;
  116918. }
  116919. interface VRFieldOfView {
  116920. readonly downDegrees: number;
  116921. readonly leftDegrees: number;
  116922. readonly rightDegrees: number;
  116923. readonly upDegrees: number;
  116924. }
  116925. interface VRFrameData {
  116926. readonly leftProjectionMatrix: Float32Array;
  116927. readonly leftViewMatrix: Float32Array;
  116928. readonly pose: VRPose;
  116929. readonly rightProjectionMatrix: Float32Array;
  116930. readonly rightViewMatrix: Float32Array;
  116931. readonly timestamp: number;
  116932. }
  116933. interface VRPose {
  116934. readonly angularAcceleration: Float32Array | null;
  116935. readonly angularVelocity: Float32Array | null;
  116936. readonly linearAcceleration: Float32Array | null;
  116937. readonly linearVelocity: Float32Array | null;
  116938. readonly orientation: Float32Array | null;
  116939. readonly position: Float32Array | null;
  116940. readonly timestamp: number;
  116941. }
  116942. interface VRStageParameters {
  116943. sittingToStandingTransform?: Float32Array;
  116944. sizeX?: number;
  116945. sizeY?: number;
  116946. }
  116947. interface Navigator {
  116948. getVRDisplays(): Promise<VRDisplay[]>;
  116949. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116950. }
  116951. interface Window {
  116952. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116953. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116954. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116955. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116956. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116957. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116958. }
  116959. interface Gamepad {
  116960. readonly displayId: number;
  116961. }
  116962. interface XRDevice {
  116963. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116964. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116965. }
  116966. interface XRSession {
  116967. getInputSources(): Array<any>;
  116968. baseLayer: XRWebGLLayer;
  116969. requestFrameOfReference(type: string): Promise<void>;
  116970. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116971. end(): Promise<void>;
  116972. requestAnimationFrame: Function;
  116973. addEventListener: Function;
  116974. }
  116975. interface XRSessionCreationOptions {
  116976. outputContext?: WebGLRenderingContext | null;
  116977. immersive?: boolean;
  116978. environmentIntegration?: boolean;
  116979. }
  116980. interface XRLayer {
  116981. getViewport: Function;
  116982. framebufferWidth: number;
  116983. framebufferHeight: number;
  116984. }
  116985. interface XRView {
  116986. projectionMatrix: Float32Array;
  116987. }
  116988. interface XRFrame {
  116989. getDevicePose: Function;
  116990. getInputPose: Function;
  116991. views: Array<XRView>;
  116992. baseLayer: XRLayer;
  116993. }
  116994. interface XRFrameOfReference {
  116995. }
  116996. interface XRWebGLLayer extends XRLayer {
  116997. framebuffer: WebGLFramebuffer;
  116998. }
  116999. declare var XRWebGLLayer: {
  117000. prototype: XRWebGLLayer;
  117001. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  117002. };